diff --git a/docs/commands/data.json b/docs/commands/data.json index 1e3c26ee6..128b87660 100644 --- a/docs/commands/data.json +++ b/docs/commands/data.json @@ -536,12 +536,14 @@ { "arg": "-a, --personal-access-token ", "description": "Personal access token associated with your Azure DevOps token; falls back to azure_devops.access_token in your spk config", - "required": true + "required": true, + "inherit": "azure_devops.access_token" }, { "arg": "-o, --org-name ", "description": "Your Azure DevOps organization name; falls back to azure_devops.org in your spk config", - "required": true + "required": true, + "inherit": "azure_devops.org" }, { "arg": "--target-branch", diff --git a/src/commands/service/create-revision.decorator.json b/src/commands/service/create-revision.decorator.json index 6ae321a93..0b7dfa5ea 100644 --- a/src/commands/service/create-revision.decorator.json +++ b/src/commands/service/create-revision.decorator.json @@ -24,12 +24,14 @@ { "arg": "-a, --personal-access-token ", "description": "Personal access token associated with your Azure DevOps token; falls back to azure_devops.access_token in your spk config", - "required": true + "required": true, + "inherit": "azure_devops.access_token" }, { "arg": "-o, --org-name ", "description": "Your Azure DevOps organization name; falls back to azure_devops.org in your spk config", - "required": true + "required": true, + "inherit": "azure_devops.org" }, { "arg": "--target-branch", diff --git a/src/commands/service/create-revision.ts b/src/commands/service/create-revision.ts index 1d3c57f9a..be4050036 100644 --- a/src/commands/service/create-revision.ts +++ b/src/commands/service/create-revision.ts @@ -4,6 +4,7 @@ import { Bedrock, Config } from "../../config"; import { build as buildCmd, exit as exitCmd, + populateInheritValueFromConfig, validateForRequiredValues, } from "../../lib/commandBuilder"; import { createPullRequest } from "../../lib/git/azure"; @@ -125,10 +126,7 @@ export const makePullRequest = async ( }; const populateValues = async (opts: CommandOptions): Promise => { - const { azure_devops } = Config(); - opts.orgName = opts.orgName || azure_devops?.org; - opts.personalAccessToken = - opts.personalAccessToken || azure_devops?.access_token; + populateInheritValueFromConfig(decorator, Config(), opts); // Default the remote to the git origin opts.remoteUrl = await getRemoteUrl(opts.remoteUrl); @@ -136,15 +134,7 @@ const populateValues = async (opts: CommandOptions): Promise => { // default pull request source branch to the current branch opts.sourceBranch = await getSourceBranch(opts.sourceBranch); - const errors = validateForRequiredValues(decorator, { - orgName: opts.orgName, - personalAccessToken: opts.personalAccessToken, - remoteUrl: opts.remoteUrl, - sourceBranch: opts.sourceBranch, - }); - if (errors.length > 0) { - throw Error("missing required values"); - } + validateForRequiredValues(decorator, opts, true); return { // validateForRequiredValues confirm that sourceBranch has value