Skip to content

Commit

Permalink
feat(cli-lib): add missing deploy options (#25042)
Browse files Browse the repository at this point in the history
Add missing deploy options to the cdk cli lib.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
abelmokadem authored Apr 18, 2023
1 parent d8267b7 commit ac40aed
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/@aws-cdk/cli-lib-alpha/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export class AwsCdkCli implements IAwsCdkCli {
...renderBooleanArg('previous-parameters', options.usePreviousParameters),
...renderBooleanArg('rollback', options.rollback),
...renderBooleanArg('staging', options.staging),
...renderBooleanArg('asset-parallelism', options.assetParallelism),
...renderBooleanArg('asset-prebuild', options.assetPrebuild),
...renderNumberArg('concurrency', options.concurrency),
...options.reuseAssets ? renderArrayArg('--reuse-assets', options.reuseAssets) : [],
...options.notificationArns ? renderArrayArg('--notification-arns', options.notificationArns) : [],
...options.parameters ? renderMapArrayArg('--parameters', options.parameters) : [],
Expand Down Expand Up @@ -257,6 +260,14 @@ function renderBooleanArg(arg: string, value?: boolean): string[] {
}
}

function renderNumberArg(arg: string, value?: number): string[] {
if (typeof value === 'undefined') {
return [];
}

return [`--${arg}`, value.toString(10)];
}

/**
* Run code from a different working directory
*/
Expand Down
21 changes: 21 additions & 0 deletions packages/@aws-cdk/cli-lib-alpha/lib/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ export interface DeployOptions extends SharedOptions {
* @default StackActivityProgress.EVENTS
*/
readonly progress?: StackActivityProgress;

/**
* Maximum number of simultaneous deployments (dependency permitting) to execute.
*
* @default 1
*/
readonly concurrency?: number;

/**
* Whether to build/publish assets in parallel.
*
* @default false
*/
readonly assetParallelism?: boolean;

/**
* Whether to build all assets before deploying the first stack (useful for failing Docker builds)
*
* @default true
*/
readonly assetPrebuild?: boolean;
}

/**
Expand Down
25 changes: 25 additions & 0 deletions packages/@aws-cdk/cli-lib-alpha/test/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ describe('deploy', () => {
versionReporting: true,
usePreviousParameters: true,
progress: StackActivityProgress.BAR,
concurrency: 5,
assetParallelism: true,
assetPrebuild: true,
});

// THEN
Expand All @@ -83,6 +86,9 @@ describe('deploy', () => {
'--previous-parameters',
'--no-rollback',
'--no-staging',
'--asset-parallelism',
'--asset-prebuild',
'--concurrency', '5',
'--reuse-assets', 'asset1234',
'--reuse-assets', 'asset5678',
'--outputs-file', 'outputs.json',
Expand Down Expand Up @@ -204,6 +210,25 @@ describe('deploy', () => {
expect.anything(),
);
});

test('can parse number arguments', async () => {
// WHEN
await cdk.deploy({
stacks: ['Stack1'],
concurrency: 5,
});

// THEN
expect(jest.mocked(cli.exec)).toHaveBeenCalledWith(
[
'deploy',
'--concurrency', '5',
'--progress', 'events',
'Stack1',
],
expect.anything(),
);
});
});

describe('synth', () => {
Expand Down

0 comments on commit ac40aed

Please sign in to comment.