Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 933746d

Browse files
[FEATURE] simplify option values inherit from config.yaml for service create rev cmd (#507)
Co-authored-by: Yvonne Radsmikham <[email protected]>
1 parent b5d2773 commit 933746d

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

docs/commands/data.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,14 @@
536536
{
537537
"arg": "-a, --personal-access-token <personal-access-token>",
538538
"description": "Personal access token associated with your Azure DevOps token; falls back to azure_devops.access_token in your spk config",
539-
"required": true
539+
"required": true,
540+
"inherit": "azure_devops.access_token"
540541
},
541542
{
542543
"arg": "-o, --org-name <organization-name>",
543544
"description": "Your Azure DevOps organization name; falls back to azure_devops.org in your spk config",
544-
"required": true
545+
"required": true,
546+
"inherit": "azure_devops.org"
545547
},
546548
{
547549
"arg": "--target-branch",

src/commands/service/create-revision.decorator.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
{
2525
"arg": "-a, --personal-access-token <personal-access-token>",
2626
"description": "Personal access token associated with your Azure DevOps token; falls back to azure_devops.access_token in your spk config",
27-
"required": true
27+
"required": true,
28+
"inherit": "azure_devops.access_token"
2829
},
2930
{
3031
"arg": "-o, --org-name <organization-name>",
3132
"description": "Your Azure DevOps organization name; falls back to azure_devops.org in your spk config",
32-
"required": true
33+
"required": true,
34+
"inherit": "azure_devops.org"
3335
},
3436
{
3537
"arg": "--target-branch",

src/commands/service/create-revision.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Bedrock, Config } from "../../config";
44
import {
55
build as buildCmd,
66
exit as exitCmd,
7+
populateInheritValueFromConfig,
78
validateForRequiredValues,
89
} from "../../lib/commandBuilder";
910
import { createPullRequest } from "../../lib/git/azure";
@@ -125,26 +126,15 @@ export const makePullRequest = async (
125126
};
126127

127128
const populateValues = async (opts: CommandOptions): Promise<CommandValues> => {
128-
const { azure_devops } = Config();
129-
opts.orgName = opts.orgName || azure_devops?.org;
130-
opts.personalAccessToken =
131-
opts.personalAccessToken || azure_devops?.access_token;
129+
populateInheritValueFromConfig(decorator, Config(), opts);
132130

133131
// Default the remote to the git origin
134132
opts.remoteUrl = await getRemoteUrl(opts.remoteUrl);
135133

136134
// default pull request source branch to the current branch
137135
opts.sourceBranch = await getSourceBranch(opts.sourceBranch);
138136

139-
const errors = validateForRequiredValues(decorator, {
140-
orgName: opts.orgName,
141-
personalAccessToken: opts.personalAccessToken,
142-
remoteUrl: opts.remoteUrl,
143-
sourceBranch: opts.sourceBranch,
144-
});
145-
if (errors.length > 0) {
146-
throw Error("missing required values");
147-
}
137+
validateForRequiredValues(decorator, opts, true);
148138

149139
return {
150140
// validateForRequiredValues confirm that sourceBranch has value

0 commit comments

Comments
 (0)