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 all 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
7 changes: 5 additions & 2 deletions src/commands/deployment/onboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ describe("onboard", () => {
expect(true).toBe(false);
} catch (err) {
expect(err.message).toBe(
"the following argument is required: \n -l / --storage-location"
getErrorMessage("introspect-onboard-cmd-location-missing")
);
}
});
Expand All @@ -334,7 +334,10 @@ describe("onboard", () => {
expect(true).toBe(false);
} catch (err) {
expect(err.message).toBe(
"Storage account testaccount access keys in resource group testResourceGroup is not defined"
getErrorMessage({
errorKey: "introspect-onboard-cmd-get-storage-access-key-err",
values: ["testaccount", "testResourceGroup"],
})
);
}
});
Expand Down
23 changes: 17 additions & 6 deletions src/commands/deployment/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
populateInheritValueFromConfig,
validateForRequiredValues,
} from "../../lib/commandBuilder";
import { build as buildError, log as logError } from "../../lib/errorBuilder";
import { errorStatusCode } from "../../lib/errorStatusCode";
import { logger } from "../../logger";
import { AzureAccessOpts, ConfigYaml } from "../../types";
import decorator from "./onboard.decorator.json";
Expand Down Expand Up @@ -109,6 +111,7 @@ export const setConfiguration = (
fs.writeFileSync(defaultConfigFile(), jsonData);
return true;
} catch (err) {
// TOFIX: write some comments on why this error can be ignore
logger.error(
`Unable to set storage account and table names in configuration file. \n ${err}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this error can be ignored?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just added a TOFIX on why this error can be ignored. It is ignored. I do not change anything. Can you elaborate on your question? thanks

);
Expand All @@ -135,8 +138,9 @@ export const validateAndCreateStorageAccount = async (
// Storage account does not exist so create it.
if (isExist === false) {
if (!values.storageLocation) {
throw new Error(
"the following argument is required: \n -l / --storage-location"
throw buildError(
errorStatusCode.VALIDATION_ERR,
"introspect-onboard-cmd-location-missing"
);
}
const storageAccount = await createStorageAccount(
Expand Down Expand Up @@ -169,9 +173,10 @@ export const getStorageAccessKey = async (
);

if (accessKey === undefined) {
throw new Error(
`Storage account ${values.storageAccountName} access keys in resource group ${values.storageResourceGroupName} is not defined`
);
throw buildError(errorStatusCode.ENV_SETTING_ERR, {
errorKey: "introspect-onboard-cmd-get-storage-access-key-err",
values: [values.storageAccountName, values.storageResourceGroupName],
});
}
return accessKey;
};
Expand Down Expand Up @@ -248,7 +253,13 @@ export const execute = async (
);
await exitFn(0);
} catch (err) {
logger.error(err);
logError(
buildError(
errorStatusCode.CMD_EXE_ERR,
"introspect-onboard-cmd-failed",
err
)
);
await exitFn(1);
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/lib/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
"introspect-create-cmd-p1-missing-values": "Values for image-tag, commit-id and service options were missing. They are required for updating the details of source pipeline. Provide them.",
"introspect-create-cmd-p2-missing-values": "Values for p2, hld-commit-id, image-tag and env options were missing. They are required For updating the details of image tag release pipeline. Provide them.",

"introspect-onboard-cmd-failed": "Deployment onboard command was not successfully executed.",
"introspect-onboard-cmd-location-missing": "Value for --storage-location was missing. Provide it.",
"introspect-onboard-cmd-get-storage-access-key-err": "Could not get storage access key for account, {0} in resource group {1}.",

"introspect-validate-cmd-failed": "Deployment validate command was not successfully executed.",
"introspect-validate-cmd-valid-err": "Validation failed. Missing configuration: {0}",
"introspect-validate-cmd-missing-vals": "Configuration for introspection storage account and DevOps pipeline to execute this command were missing. Initialize the spk tool with the right configuration",
Expand Down