This repository was archived by the owner on Apr 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Append variable group to manifest-generation.yaml #453
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fc921f9
Add variable group to existing manifest-generation.yaml
91b63c6
Update integration tests
3f2f4e7
Adding files for append variable group
c029d41
Merge branch 'master' into edaena-vg
samiyaakhtar 686a526
Add unit test file
22b722f
Merge branch 'edaena-vg' of github.com:CatalystCode/spk into edaena-vg
4278e27
Update test mock function
e4acce9
Merge branch 'master' into edaena-vg
samiyaakhtar b41130b
Update unit test
95a5496
Merge branch 'edaena-vg' of github.com:CatalystCode/spk into edaena-vg
ee32608
Merge branch 'master' into edaena-vg
dennisseah 97b4fff
Merge branch 'master' into edaena-vg
samiyaakhtar 3dacea9
updates
1b2080c
Merge branch 'master' into edaena-vg
edaena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "command": "append-variable-group <variable-group-name>", | ||
| "alias": "avg", | ||
| "description": "Appends the name of an existing variable group to the current manifest-generation.yaml file." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { execute } from "./append-variable-group"; | ||
| import * as fileutils from "../../lib/fileutils"; | ||
|
|
||
| describe("Test execute function", () => { | ||
| it("missing variable group name", async () => { | ||
| const exitFn = jest.fn(); | ||
| await execute("my-path", "", exitFn); | ||
| expect(exitFn).toBeCalledTimes(1); | ||
| expect(exitFn.mock.calls).toEqual([[1]]); | ||
| }); | ||
| it("appends variable group", async () => { | ||
| const exitFn = jest.fn(); | ||
| spyOn(fileutils, "appendVariableGroupToPipelineYaml"); | ||
| await execute("my-path", "my-vg", exitFn); | ||
| expect(exitFn).toBeCalledTimes(1); | ||
| expect(exitFn.mock.calls).toEqual([[0]]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import commander from "commander"; | ||
| import { build as buildCmd, exit as exitCmd } from "../../lib/commandBuilder"; | ||
| import { RENDER_HLD_PIPELINE_FILENAME } from "../../lib/constants"; | ||
| import { appendVariableGroupToPipelineYaml } from "../../lib/fileutils"; | ||
| import { logger } from "../../logger"; | ||
| import decorator from "./append-variable-group.decorator.json"; | ||
|
|
||
| /** | ||
| * Executes the command, can call exit function with 0 or 1 | ||
| * when command completed successfully or failed respectively. | ||
| * | ||
| * @param hldRepoPath The hld repository path | ||
| * @param variableGroupName The variable group name | ||
| * @param exitFn exit function | ||
| */ | ||
| export const execute = async ( | ||
| hldRepoPath: string, | ||
| variableGroupName: string, | ||
| exitFn: (status: number) => Promise<void> | ||
| ): Promise<void> => { | ||
| if (!variableGroupName) { | ||
| logger.error("Variable group name is missing."); | ||
| await exitFn(1); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| appendVariableGroupToPipelineYaml( | ||
| hldRepoPath, | ||
| RENDER_HLD_PIPELINE_FILENAME, | ||
| variableGroupName | ||
| ); | ||
| await exitFn(0); | ||
| } catch (err) { | ||
| logger.error(`Error occurred while appending variable group.`); | ||
| logger.error(err); | ||
| await exitFn(1); | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * Adds the init command to the commander command object | ||
| * @param command Commander command object to decorate | ||
| */ | ||
| export const commandDecorator = (command: commander.Command): void => { | ||
| buildCmd(command, decorator).action(async (variableGroupName: string) => { | ||
| const hldRepoPath = process.cwd(); | ||
| await execute(hldRepoPath, variableGroupName, async (status: number) => { | ||
| await exitCmd(logger, process.exit, status); | ||
| }); | ||
| }); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.