Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Change error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Edaena Salinas authored and Edaena Salinas committed Apr 24, 2020
1 parent 05fd607 commit e1926e3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 25 deletions.
11 changes: 5 additions & 6 deletions src/commands/project/append-variable-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const checkDependencies = (projectPath: string): void => {
if (fileInfo.exist === false) {
throw buildError(
errorStatusCode.VALIDATION_ERR,
"project-append-variable-group-cmd-err-dependency"
"project-append-variable-group-cmd-err-bedrock-yaml-missing"
);
}
};
Expand Down Expand Up @@ -121,12 +121,11 @@ export const execute = async (
opts: CommandOptions,
exitFn: (status: number) => Promise<void>
): Promise<void> => {
if (!hasValue(variableGroupName)) {
await exitFn(1);
return;
}

try {
if (!hasValue(variableGroupName)) {
throw buildError(errorStatusCode.CMD_EXE_ERR);
}

checkDependencies(projectPath);
const values = validateValues(opts);

Expand Down
2 changes: 1 addition & 1 deletion src/commands/project/create-variable-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const checkDependencies = (projectPath: string): void => {
if (fileInfo.exist === false) {
throw buildError(
errorStatusCode.VALIDATION_ERR,
"project-create-variable-group-cmd-err-dependency"
"project-create-variable-group-cmd-err-bedrock-yaml-missing"
);
}
};
Expand Down
7 changes: 5 additions & 2 deletions src/lib/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@
"var-group-add-err-vars-missing": "Could not add variable group because variables were not configured.",
"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.",
"var-group-has-var-group-err": "Could not get variable group, {1} information in project, {0}.",
"var-group-delete-var-group-err": "Could not delete variable group, {1} information in project, {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.",
Expand All @@ -258,13 +260,14 @@
"project-create-variable-group-cmd-err-root-invalid": "Project root path is not valid. Provide a valid root path.",
"project-create-variable-group-cmd-err-variable-group-invalid": "Variable group name is not valid. Provide a valid variable group name.",
"project-create-variable-group-cmd-err-file-missing": "The file '{0}' does not exist in project '{1}'.",
"project-create-variable-group-cmd-err-dependency": "Please run `spk project init` command before running this command to initialize the project.",
"project-create-variable-group-cmd-err-bedrock-yaml-missing": "Bedrock.yaml file was not found. Run spk project init command to initialize the project.",

"project-init-cmd-failed": "Project init was not successfully executed.",

"project-append-variable-group-cmd-failed": "Append variable group was not successfully executed.",
"project-append-variable-group-cmd-err-dependency": "Please run `spk project init` command before running this command to initialize the project.",
"project-append-variable-group-cmd-err-bedrock-yaml-missing": "Bedrock.yaml file was not found. Run spk project init command to initialize the project.",
"project-append-variable-group-cmd-err-variable-group-invalid": "Could not add variable group '{0}' to the project. Check that the variable group exists in the Azure DevOps project '{1}/{2}'.",
"project-append-variable-group-cmd-err-variable-group-missing": "No value for variable group name was given. Provide a variable group name.",

"service-install-build-pipeline-cmd-failed": "Service install build pipeline was not successfully executed.",
"service-install-build-pipeline-cmd-pipeline-creation-err": "Error occurred when creating pipeline '{0}'. See the error details.",
Expand Down
54 changes: 38 additions & 16 deletions src/lib/pipelines/variableGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,27 @@ export const deleteVariableGroup = async (
opts: AzureDevOpsOpts,
name: string
): Promise<boolean> => {
const taskClient = await getTaskAgentApi(opts);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const project = opts.project!;

const groups = await taskClient.getVariableGroups(project, name);
if (groups && groups.length > 0 && groups[0].id) {
await taskClient.deleteVariableGroup(project, groups[0].id);
return true;
try {
const taskClient = await getTaskAgentApi(opts);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const project = opts.project!;

const groups = await taskClient.getVariableGroups(project, name);
if (groups && groups.length > 0 && groups[0].id) {
await taskClient.deleteVariableGroup(project, groups[0].id);
return true;
}
return false;
} catch (err) {
throw buildError(
errorStatusCode.AZURE_VARIABLE_GROUP_ERR,
{
errorKey: "var-group-delete-var-group-err",
values: [opts.project!, name],
},
err
);
}
return false;
};

/**
Expand All @@ -296,13 +307,24 @@ export const hasVariableGroup = async (
opts: AzureDevOpsOpts,
name: string
): Promise<boolean> => {
const taskClient = await getTaskAgentApi(opts);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const project = opts.project!;
try {
const taskClient = await getTaskAgentApi(opts);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const project = opts.project!;

const groups = await taskClient.getVariableGroups(project, name);
if (groups && groups.length > 0 && groups[0].name) {
return groups[0].name === name;
const groups = await taskClient.getVariableGroups(project, name);
if (groups && groups.length > 0 && groups[0].name) {
return groups[0].name === name;
}
return false;
} catch (err) {
throw buildError(
errorStatusCode.AZURE_VARIABLE_GROUP_ERR,
{
errorKey: "var-group-has-var-group-err",
values: [opts.project!, name],
},
err
);
}
return false;
};

0 comments on commit e1926e3

Please sign in to comment.