Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions src/commands/ring/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,14 @@ export const execute = async (
projectPath: string,
exitFn: (status: number) => Promise<void>
): Promise<void> => {
if (!hasValue(ringName)) {
logError(
buildError(
try {
if (!hasValue(ringName)) {
throw buildError(
errorStatusCode.VALIDATION_ERR,
"ring-create-cmd-err-name-missing"
)
);
await exitFn(1);
return;
}
);
}

try {
logger.info(`Project path: ${projectPath}`);

dns.assertIsValid("<ring-name>", ringName);
Expand All @@ -91,14 +87,8 @@ export const execute = async (
await exitFn(0);
} catch (err) {
logError(
buildError(
errorStatusCode.CMD_EXE_ERR,
{
errorKey: "ring-create-cmd-failed",
values: [ringName],
},
err
)
// cannot include ring name in error message because it may not be defined.
buildError(errorStatusCode.CMD_EXE_ERR, "ring-create-cmd-failed", err)
);
await exitFn(1);
}
Expand Down
22 changes: 9 additions & 13 deletions src/commands/ring/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ export const execute = async (
projectPath: string,
exitFn: (status: number) => Promise<void>
): Promise<void> => {
if (!hasValue(ringName)) {
await exitFn(1);
return;
}

try {
if (!hasValue(ringName)) {
throw buildError(
errorStatusCode.VALIDATION_ERR,
"ring-delete-cmd-err-name-missing"
);
}

logger.info(`Project path: ${projectPath}`);

// Check if bedrock config exists, if not, warn and exit
Expand All @@ -65,14 +67,8 @@ export const execute = async (
await exitFn(0);
} catch (err) {
logError(
buildError(
errorStatusCode.EXE_FLOW_ERR,
{
errorKey: "ring-delete-cmd-failed",
values: [ringName],
},
err
)
// cannot include ring name in error message because it may not be defined.
buildError(errorStatusCode.EXE_FLOW_ERR, "ring-delete-cmd-failed", err)
);
await exitFn(1);
}
Expand Down
18 changes: 9 additions & 9 deletions src/commands/ring/set-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ export const execute = async (
projectPath: string,
exitFn: (status: number) => Promise<void>
): Promise<void> => {
if (!hasValue(ringName)) {
await exitFn(1);
return;
}

try {
if (!hasValue(ringName)) {
throw buildError(
errorStatusCode.VALIDATION_ERR,
"ring-set-default-cmd-err-name-missing"
);
}

logger.info(`Project path: ${projectPath}`);

checkDependencies(projectPath);
Expand All @@ -55,12 +57,10 @@ export const execute = async (
await exitFn(0);
} catch (err) {
logError(
// cannot include ring name in error message because it may not be defined.
buildError(
errorStatusCode.EXE_FLOW_ERR,
{
errorKey: "ring-set-default-cmd-failed",
values: [ringName],
},
"ring-set-default-cmd-failed",
err
)
);
Expand Down
22 changes: 13 additions & 9 deletions src/lib/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,20 @@
"var-group-add-with-key-vault-err-missing-provider": "Could not add variable group with key vault because Azure KeyVault provider data was not configured",
"var-group-create-data-err": "Could not create variable group data.",

"ring-create-cmd-failed": "Error occurred while creating ring: {0}",
"ring-create-cmd-failed": "Could not create ring: {0}.",
"ring-create-cmd-err-name-missing": "Could not execute this command because ring name was not provided. Provide a ring name.",
"ring-create-cmd-err-ring-exists": "Could not create ring {0} in project {1} because it already exists. Provide a different name.",
"ring-create-cmd-err-dependency": "Please run `spk project init` command before running this command to initialize the project.",
"ring-delete-cmd-err-dependency": "Please run `spk project init` command before running this command to initialize the project.",
"ring-set-default-cmd-err-dependency": "Please run `spk project init` command before running this command to initialize the project.",
"ring-create-cmd-err-name-missing": "No ring name was provided. Provide a ring name",
"ring-delete-cmd-failed": "Error occurred while deleting ring: {0}.",
"ring-set-default-cmd-failed": "Error occurred while setting default ring: {0}",

"variable-group-create-cmd-failed": "Error occurred while creating variable group.",
"ring-create-cmd-err-dependency": "Configuration information was missing. Run `spk project init` command to initialize them.",

"ring-set-default-cmd-failed": "Could not set default ring: {0}.",
"ring-set-default-cmd-err-name-missing": "Could not execute this command because ring name was not provided. Provide a ring name.",
"ring-set-default-cmd-err-dependency": "Configuration information was missing. Run `spk project init` command to initialize them.",

"ring-delete-cmd-failed": "Could not delete ring: {0}.",
"ring-delete-cmd-err-name-missing": "Could not execute this command because ring name was not provided. Provide a ring name.",
"ring-delete-cmd-err-dependency": "Configuration information was missing. Run `spk project init` command to initialize them.",

"variable-group-create-cmd-failed": "Could not create variable group.",
"variable-group-create-cmd-err-create": "Could not load variable group. The variable group type '{0}' is not supported. Only 'Vsts' and 'AzureKeyVault' are valid types and case sensitive.",
"variable-group-create-cmd-err-access-token": "Provide a value for {0}.",
"variable-group-create-cmd-err-project-missing": "Provide a value for {0}.",
Expand Down