Skip to content

Commit 032964b

Browse files
kaizenccmrgrainmergify[bot]
authored
chore(cli): more accurate message to garbage collection prompt (#32178)
Should look like this: ``` Found 1 image to delete based off of the following criteria: - images have been isolated for > 0 days - images were created > 0 days ago Delete this batch (yes/no/delete-all)? ``` Instead of this: ``` Found 1 assets to delete based off of the following criteria: - assets have been isolated for > 0 days - assets were created > 0 days ago Delete this batch (yes/no/delete-all)? ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --------- Co-authored-by: Momo Kornher <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 82a0c6b commit 032964b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/aws-cdk/lib/api/garbage-collection/garbage-collector.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export class GarbageCollector {
284284
debug(`${untaggables.length} assets to untag`);
285285

286286
if (this.permissionToDelete && deletables.length > 0) {
287-
await this.confirmationPrompt(printer, deletables);
287+
await this.confirmationPrompt(printer, deletables, 'image');
288288
await this.parallelDeleteEcr(ecr, repo, deletables, printer);
289289
}
290290

@@ -360,7 +360,7 @@ export class GarbageCollector {
360360
debug(`${untaggables.length} assets to untag`);
361361

362362
if (this.permissionToDelete && deletables.length > 0) {
363-
await this.confirmationPrompt(printer, deletables);
363+
await this.confirmationPrompt(printer, deletables, 'object');
364364
await this.parallelDeleteS3(s3, bucket, deletables, printer);
365365
}
366366

@@ -713,12 +713,16 @@ export class GarbageCollector {
713713
} while (continuationToken);
714714
}
715715

716-
private async confirmationPrompt(printer: ProgressPrinter, deletables: GcAsset[]) {
716+
private async confirmationPrompt(printer: ProgressPrinter, deletables: GcAsset[], type: string) {
717+
const pluralize = (name: string, count: number): string => {
718+
return count === 1 ? name : `${name}s`;
719+
};
720+
717721
if (this.confirm) {
718722
const message = [
719-
`Found ${deletables.length} assets to delete based off of the following criteria:`,
720-
`- assets have been isolated for > ${this.props.rollbackBufferDays} days`,
721-
`- assets were created > ${this.props.createdBufferDays} days ago`,
723+
`Found ${deletables.length} ${pluralize(type, deletables.length)} to delete based off of the following criteria:`,
724+
`- ${type}s have been isolated for > ${this.props.rollbackBufferDays} days`,
725+
`- ${type}s were created > ${this.props.createdBufferDays} days ago`,
722726
'',
723727
'Delete this batch (yes/no/delete-all)?',
724728
].join('\n');

0 commit comments

Comments
 (0)