Skip to content

Commit c6585ad

Browse files
authored
fix(cli): deprecate "bootstrap-stack-name" in favor of "toolkit-stack-name" for gc command (#795)
Fixes #385 Elsewhere we are consistently naming this property `toolkit-stack-name`, so this PR aligns `gc` with the rest of the CLI world. We may have better options here, like making `toolkit-stack-name` a global option, but this is an easy fix for now. Does not break users by maintaining `bootstrap-stack-name` as an alias of `toolkit-stack-name` for `gc`. However `bootstrap-stack-name` is marked as deprecated and will be removed when we GA garbage collection. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
1 parent 98a1bfa commit c6585ad

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

packages/aws-cdk/lib/cli/cli-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ export async function makeConfig(): Promise<CliConfig> {
110110
'rollback-buffer-days': { type: 'number', desc: 'Delete assets that have been marked as isolated for this many days', default: 0 },
111111
'created-buffer-days': { type: 'number', desc: 'Never delete assets younger than this (in days)', default: 1 },
112112
'confirm': { type: 'boolean', desc: 'Confirm via manual prompt before deletion', default: true },
113-
'bootstrap-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit"', requiresArg: true },
113+
'toolkit-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit"', requiresArg: true, conflicts: 'bootstrap-stack-name' },
114+
'bootstrap-stack-name': { type: 'string', desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit" (deprecated, use --toolkit-stack-name)', deprecated: 'use --toolkit-stack-name', requiresArg: true, conflicts: 'toolkit-stack-name' }, // TODO: remove when garbage collection is GA
114115
},
115116
},
116117
'flags': {

packages/aws-cdk/lib/cli/cli-type-registry.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,18 @@
322322
"desc": "Confirm via manual prompt before deletion",
323323
"default": true
324324
},
325-
"bootstrap-stack-name": {
325+
"toolkit-stack-name": {
326326
"type": "string",
327327
"desc": "The name of the CDK toolkit stack, if different from the default \"CDKToolkit\"",
328-
"requiresArg": true
328+
"requiresArg": true,
329+
"conflicts": "bootstrap-stack-name"
330+
},
331+
"bootstrap-stack-name": {
332+
"type": "string",
333+
"desc": "The name of the CDK toolkit stack, if different from the default \"CDKToolkit\" (deprecated, use --toolkit-stack-name)",
334+
"deprecated": "use --toolkit-stack-name",
335+
"requiresArg": true,
336+
"conflicts": "toolkit-stack-name"
329337
}
330338
}
331339
},

packages/aws-cdk/lib/cli/cli.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,15 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
442442
if (!configuration.settings.get(['unstable']).includes('gc')) {
443443
throw new ToolkitError('Unstable feature use: \'gc\' is unstable. It must be opted in via \'--unstable\', e.g. \'cdk gc --unstable=gc\'');
444444
}
445+
if (args.bootstrapStackName) {
446+
await ioHost.defaults.warn('--bootstrap-stack-name is deprecated and will be removed when gc is GA. Use --toolkit-stack-name.');
447+
}
445448
return cli.garbageCollect(args.ENVIRONMENTS, {
446449
action: args.action,
447450
type: args.type,
448451
rollbackBufferDays: args['rollback-buffer-days'],
449452
createdBufferDays: args['created-buffer-days'],
450-
bootstrapStackName: args.bootstrapStackName,
453+
bootstrapStackName: args.toolkitStackName ?? args.bootstrapStackName,
451454
confirm: args.confirm,
452455
});
453456

packages/aws-cdk/lib/cli/convert-to-user-input.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export function convertYargsToUserInput(args: any): UserInput {
8989
rollbackBufferDays: args.rollbackBufferDays,
9090
createdBufferDays: args.createdBufferDays,
9191
confirm: args.confirm,
92+
toolkitStackName: args.toolkitStackName,
9293
bootstrapStackName: args.bootstrapStackName,
9394
ENVIRONMENTS: args.ENVIRONMENTS,
9495
};
@@ -373,6 +374,7 @@ export function convertConfigToUserInput(config: any): UserInput {
373374
rollbackBufferDays: config.gc?.rollbackBufferDays,
374375
createdBufferDays: config.gc?.createdBufferDays,
375376
confirm: config.gc?.confirm,
377+
toolkitStackName: config.gc?.toolkitStackName,
376378
bootstrapStackName: config.gc?.bootstrapStackName,
377379
};
378380
const flagsOptions = {

packages/aws-cdk/lib/cli/parse-command-line-arguments.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,20 @@ export function parseCommandLineArguments(args: Array<string>): any {
345345
type: 'boolean',
346346
desc: 'Confirm via manual prompt before deletion',
347347
})
348-
.option('bootstrap-stack-name', {
348+
.option('toolkit-stack-name', {
349349
default: undefined,
350350
type: 'string',
351351
desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit"',
352352
requiresArg: true,
353+
conflicts: 'bootstrap-stack-name',
354+
})
355+
.option('bootstrap-stack-name', {
356+
default: undefined,
357+
type: 'string',
358+
desc: 'The name of the CDK toolkit stack, if different from the default "CDKToolkit" (deprecated, use --toolkit-stack-name)',
359+
deprecated: 'use --toolkit-stack-name',
360+
requiresArg: true,
361+
conflicts: 'toolkit-stack-name',
353362
}),
354363
)
355364
.command('flags [FLAGNAME..]', 'View and toggle feature flags.', (yargs: Argv) =>

packages/aws-cdk/lib/cli/user-input.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,14 @@ export interface GcOptions {
601601
*
602602
* @default - undefined
603603
*/
604+
readonly toolkitStackName?: string;
605+
606+
/**
607+
* The name of the CDK toolkit stack, if different from the default "CDKToolkit" (deprecated, use --toolkit-stack-name)
608+
*
609+
* @deprecated use --toolkit-stack-name
610+
* @default - undefined
611+
*/
604612
readonly bootstrapStackName?: string;
605613

606614
/**

0 commit comments

Comments
 (0)