Skip to content

Commit aef22c4

Browse files
author
Cliff Odijk
committed
de stackSelector elementen verwijderd
1 parent f9e5f18 commit aef22c4

8 files changed

Lines changed: 10 additions & 240 deletions

File tree

.projenrc.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ const project = new GitHubActionTypeScriptProject({
4545
description: 'github token',
4646
required: true,
4747
},
48-
stackSelectorPatterns: {
49-
description:
50-
'Comma delimited list of stack selector patterns. Use this to control which stages/stacks to diff. By default all stages & stacks are diffed\n\n' +
51-
'@see https://github.com/aws/aws-cdk-cli/tree/main/packages/%40aws-cdk/toolkit-lib#stack-selection',
52-
required: false,
53-
default: '',
54-
},
55-
stackSelectionStrategy: {
56-
description: [
57-
'Used in combination with "stackSelectorPatterns" to control which stacks to diff.',
58-
'',
59-
'Valid values are "all-stacks", "main-assembly", "only-single", "pattern-match",',
60-
'"pattern-must-match", "pattern-must-match-single"',
61-
'',
62-
'@default pattern-must-match if "stackSelectorPatterns" is provided, otherwise "all-stacks"',
63-
'@see https://github.com/aws/aws-cdk-cli/tree/main/packages/%40aws-cdk/toolkit-lib#stack-selection',
64-
].join('\n'),
65-
default: 'all-stacks',
66-
required: false,
67-
},
6848
cdkOutDirs: {
6949
description: [
7050
'Glob pattern to find CDK output directories to diff.',

action.yml

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 2 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/action.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
getInput,
3-
getMultilineInput,
43
debug,
54
} from '@actions/core';
65
import * as github from '@actions/github';
@@ -98,21 +97,10 @@ export async function run() {
9897
const inputs: Inputs = {
9998
title: getInput('title') || undefined,
10099
githubToken: getInput('githubToken'),
101-
stackSelectorPatterns: getMultilineInput('stackSelectorPatterns'),
102-
stackSelectionStrategy: getInput('stackSelectionStrategy', {
103-
required: true,
104-
}),
105100
baseRef: baseRef,
106101
diffMethod: getInput('diffMethod', { required: true }),
107102
};
108103

109-
if (
110-
inputs.stackSelectorPatterns.length > 0 &&
111-
inputs.stackSelectionStrategy === 'all-stacks'
112-
) {
113-
inputs.stackSelectionStrategy = 'pattern-must-match';
114-
}
115-
116104
debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`);
117105

118106
const octokit = github.getOctokit(inputs.githubToken);

src/inputs.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@ export interface Inputs {
77
*/
88
githubToken: string;
99

10-
/**
11-
* List of stack selector patterns
12-
*
13-
* @default - show diff for all stages
14-
*/
15-
stackSelectorPatterns: string[];
16-
17-
/**
18-
* Used in combination with 'stackSelectorPatterns' to control which stacks to diff.
19-
*
20-
* Valid values are 'all-stacks', 'main-assembly', 'only-single', 'pattern-match',
21-
* 'pattern-must-match', 'pattern-must-match-single'
22-
*
23-
* @see https://github.com/aws/aws-cdk-cli/tree/main/packages/%40aws-cdk/toolkit-lib#stack-selection
24-
* @default pattern-must-match if 'stackSelectorPatterns is provided, otherwise 'all-stacks'
25-
*/
26-
stackSelectionStrategy: string;
27-
2810
/**
2911
* The method to create a stack diff.
3012
*

src/stage-processor.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { TemplateDiff, formatDifferences } from '@aws-cdk/cloudformation-diff';
66
import { CloudAssembly } from '@aws-cdk/cx-api';
77
import {
88
DiffMethod,
9-
StackSelectionStrategy,
10-
StackSelector,
119
Toolkit,
1210
} from '@aws-cdk/toolkit-lib';
1311
import type { RequestError, OctokitResponse } from '@octokit/types';
@@ -154,19 +152,7 @@ export class AssemblyProcessor {
154152
},
155153
);
156154

157-
const selector: StackSelector =
158-
this.options.stackSelectorPatterns.length > 0
159-
? {
160-
strategy: this.options
161-
.stackSelectionStrategy as StackSelectionStrategy,
162-
patterns: this.options.stackSelectorPatterns,
163-
}
164-
: {
165-
strategy: this.options
166-
.stackSelectionStrategy as StackSelectionStrategy,
167-
};
168155
const diffResult = await this.options.toolkit.diff(assemblySource, {
169-
stacks: selector,
170156
method: this.options.diffMethod,
171157
});
172158

test/stage-processor.test.ts

Lines changed: 7 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ describe('StageProcessor', () => {
118118
'cdk.out/SomeStage-test-stack.template.json',
119119
),
120120
failOnDestructiveChanges: true,
121-
stackSelectorPatterns: [],
122-
stackSelectionStrategy: 'all-stacks',
123121
noFailOnDestructiveChanges: [],
124122
});
125123
await processor.processStages();
@@ -155,8 +153,6 @@ describe('StageProcessor', () => {
155153
'cdk.out/SomeStage-test-stack.template.json',
156154
),
157155
failOnDestructiveChanges: true,
158-
stackSelectorPatterns: [],
159-
stackSelectionStrategy: 'all-stacks',
160156
noFailOnDestructiveChanges: [],
161157
});
162158
await processor.processStages();
@@ -192,11 +188,9 @@ describe('StageProcessor', () => {
192188
'cdk.out/SomeStage-test-stack.template.json',
193189
),
194190
failOnDestructiveChanges: true,
195-
stackSelectorPatterns: [],
196-
stackSelectionStrategy: 'all-stacks',
197191
noFailOnDestructiveChanges: [],
198192
});
199-
await processor.processStages(['SomeStage']);
193+
await processor.processStages();
200194
const p = (processor as any).stageComments;
201195
expect(p).toEqual({
202196
SomeStage: expect.any(Object),
@@ -230,11 +224,9 @@ describe('StageProcessor', () => {
230224
'cdk.out/SomeStage-test-stack.template.json',
231225
),
232226
failOnDestructiveChanges: true,
233-
stackSelectorPatterns: [],
234-
stackSelectionStrategy: 'all-stacks',
235227
noFailOnDestructiveChanges: [],
236228
});
237-
await processor.processStages(['SomeStage']);
229+
await processor.processStages();
238230
await processor.commentStages(new Comments({} as any, {} as any));
239231
expect(createCommentMock).toHaveBeenCalledTimes(1);
240232
expect(findPreviousMock).toHaveBeenCalledTimes(1);
@@ -264,132 +256,15 @@ describe('StageProcessor', () => {
264256
'cdk.out/SomeStage-test-stack.template.json',
265257
),
266258
failOnDestructiveChanges: true,
267-
stackSelectorPatterns: [],
268-
stackSelectionStrategy: 'all-stacks',
269259
noFailOnDestructiveChanges: [],
270260
});
271261
findPreviousMock.mockResolvedValue(1);
272-
await processor.processStages(['SomeStage']);
262+
await processor.processStages();
273263
await processor.commentStages(new Comments({} as any, {} as any));
274264
expect(findPreviousMock).toHaveBeenCalledTimes(1);
275265
expect(createCommentMock).toHaveBeenCalledTimes(0);
276266
expect(updateCommentMock).toHaveBeenCalledTimes(1);
277267
});
278-
279-
test('filter stages', async () => {
280-
mockOutDir = {
281-
'SomeStage-test-stack.template.json': JSON.stringify({
282-
Resources: {
283-
MyRole: {
284-
Type: 'AWS::IAM::Role',
285-
Properties: {
286-
RoleName: 'MyCustomName2',
287-
},
288-
},
289-
},
290-
}),
291-
'manifest.json': JSON.stringify({
292-
version: '36.0.0',
293-
artifacts: {
294-
'assembly-SomeOtherStage': {
295-
type: 'cdk:cloud-assembly',
296-
properties: {
297-
directoryName: 'assembly-SomeOtherStage',
298-
displayName: 'SomeOtherStage',
299-
},
300-
},
301-
'assembly-SomeStage': {
302-
type: 'cdk:cloud-assembly',
303-
properties: {
304-
directoryName: 'assembly-SomeStage',
305-
displayName: 'SomeStage',
306-
},
307-
},
308-
},
309-
}),
310-
['assembly-SomeOtherStage']: {
311-
['manifest.json']: JSON.stringify({
312-
version: '36.0.0',
313-
artifacts: {
314-
'SomeOtherStage-test-stack': {
315-
type: 'aws:cloudformation:stack',
316-
environment: 'aws://unknown-account/unknown-region',
317-
properties: {
318-
templateFile: 'SomeOtherStage-test-stack.template.json',
319-
validateOnSynth: false,
320-
stackName: 'SomeOtherStage-test-stack',
321-
},
322-
displayName: 'SomeOtherStage/test-stack',
323-
},
324-
},
325-
}),
326-
['SomeOtherStage-test-stack.template.json']: JSON.stringify({
327-
Resources: {
328-
MyRole: {
329-
Type: 'AWS::IAM::Role',
330-
Properties: {
331-
RoleName: 'MyCustomName',
332-
},
333-
},
334-
},
335-
}),
336-
},
337-
['assembly-SomeStage']: {
338-
['manifest.json']: JSON.stringify({
339-
version: '36.0.0',
340-
artifacts: {
341-
'SomeStage-test-stack': {
342-
type: 'aws:cloudformation:stack',
343-
environment: 'aws://unknown-account/unknown-region',
344-
properties: {
345-
templateFile: 'SomeStage-test-stack.template.json',
346-
validateOnSynth: false,
347-
stackName: 'SomeStage-test-stack',
348-
},
349-
displayName: 'SomeStage/test-stack',
350-
},
351-
},
352-
}),
353-
['SomeStage-test-stack.template.json']: JSON.stringify({
354-
Resources: {
355-
MyRole: {
356-
Type: 'AWS::IAM::Role',
357-
Properties: {
358-
RoleName: 'MyCustomName',
359-
},
360-
},
361-
},
362-
}),
363-
},
364-
};
365-
mock({
366-
'cdk.out': mockOutDir,
367-
node_modules: mock.load(path.join(__dirname, '..', 'node_modules')),
368-
});
369-
const processor = new AssemblyProcessor({
370-
toolkit,
371-
allowedDestroyTypes: [],
372-
cdkOutDir: 'cdk.out',
373-
diffMethod: DiffMethod.LocalFile(
374-
'cdk.out/SomeStage-test-stack.template.json',
375-
),
376-
failOnDestructiveChanges: true,
377-
stackSelectorPatterns: ['!SomeOtherStage/*'],
378-
stackSelectionStrategy: 'pattern-must-match',
379-
noFailOnDestructiveChanges: [],
380-
});
381-
await processor.processStages();
382-
const p = (processor as any).stageComments;
383-
expect(p).toEqual({
384-
SomeStage: expect.any(Object),
385-
});
386-
expect(
387-
p.SomeStage.stackComments['SomeStage/test-stack'].length,
388-
).not.toEqual(0);
389-
expect(p.SomeStage.stackComments['SomeOtherStage/test-stack']).toEqual(
390-
undefined,
391-
);
392-
});
393268
});
394269

395270
describe('default stage', () => {
@@ -447,8 +322,6 @@ describe('default stage', () => {
447322
'cdk.out/SomeStage-test-stack.template.json',
448323
),
449324
failOnDestructiveChanges: true,
450-
stackSelectorPatterns: [],
451-
stackSelectionStrategy: 'all-stacks',
452325
noFailOnDestructiveChanges: [],
453326
});
454327
await processor.processStages();
@@ -504,8 +377,6 @@ function setupCommentTest(): AssemblyProcessor {
504377
cdkOutDir: 'cdk.out',
505378
diffMethod: DiffMethod.TemplateOnly(),
506379
failOnDestructiveChanges: true,
507-
stackSelectorPatterns: [],
508-
stackSelectionStrategy: 'all-stacks',
509380
noFailOnDestructiveChanges: [],
510381
});
511382
}
@@ -514,7 +385,7 @@ describe('stack comments', () => {
514385
findPreviousMock.mockResolvedValue(1);
515386
updateCommentMock.mockRejectedValueOnce(requestError(422));
516387
const processor = setupCommentTest();
517-
await processor.processStages(['SomeStage']);
388+
await processor.processStages();
518389
await processor.commentStages(new Comments({} as any, {} as any));
519390
expect(findPreviousMock).toHaveBeenCalledTimes(11);
520391
expect(createCommentMock).toHaveBeenCalledTimes(0);
@@ -527,7 +398,7 @@ describe('stack comments', () => {
527398
requestError(400, 'Some other error failed'),
528399
);
529400
const processor = setupCommentTest();
530-
await processor.processStages(['SomeStage']);
401+
await processor.processStages();
531402
await expect(
532403
processor.commentStages(new Comments({} as any, {} as any)),
533404
).rejects.toThrow(/Validation Error/);
@@ -543,7 +414,7 @@ describe('stack comments', () => {
543414
requestError(400, 'Some other error failed'),
544415
);
545416
const processor = setupCommentTest();
546-
await processor.processStages(['SomeStage']);
417+
await processor.processStages();
547418
await expect(
548419
processor.commentStages(new Comments({} as any, {} as any)),
549420
).rejects.toThrow(/Validation Error/);
@@ -558,7 +429,7 @@ describe('stack comments', () => {
558429
updateCommentMock.mockRejectedValueOnce(requestError(422));
559430
updateCommentMock.mockRejectedValueOnce(requestError(422));
560431
const processor = setupCommentTest();
561-
await processor.processStages(['SomeStage']);
432+
await processor.processStages();
562433
await expect(
563434
processor.commentStages(new Comments({} as any, {} as any)),
564435
).rejects.toThrow(/Comment for stack SomeStage\/my-stack1 is too long/);

0 commit comments

Comments
 (0)