Commit f3f8802
authored
chore(toolkit): new and improved stack selection (#32928)
### Reason for this change
New unified, public stack selector interface. This was previously a mix
of `StackSelector` and options.
It was also very hard to follow.
### Summary of existing usage
```
## Stacks for list: diff and defineEnvironments
ALL+
=> ALL, error when none exists
- fail if no stacks at all
- Always ALL stacks
## listStacks.ts: Not Selector
ALL+, MATCH
=> ALL, or match by pattern with upstream
- fail if no stacks at all
- if patterns that, otherwise ALL
- Always extend Upstream
## Single: Not a Selector, used by metadata
MUST_MATCH_ONE
=> Exactly 1, matched by pattern, errors for various out of bounds
- fail if no stacks at all
- single pattern
- no extend, no default
- Custom: Exception if more than 1
- Via stack collection: will fail if not at least 1
## Destroy: Selector, used by: Destroy in extension Deploy
From deploy: Exactly 1 matched by pattern, exclusive
MUST_MATCH_ONE
From destroy: many is fine
ALL+, MUST_MATCH, ONLY_ONE
Bug: if no top level stacks and --all
cdk destroy --all vs cdk destroy "*/*"
No stack found in the main cloud assembly. Use "list" to print manifest
Are you sure you want to delete: LocalStage/NetworkStack, DevStage/NetworkStack (y/n)? n
Bug:
cdk destroy unknown
Are you sure you want to delete: (y/n)?
Selected:
| MAIN (not empty, extended)
| MATCH (can be empty, extended)
| EXACTLY ONE
- fail if no stack at all
- maybe MAIN, with throw
- otherwise patterns
- otherwise exactly 1
- extends both
- can be matching none
## Diff: Selector, used by: Diff, Synth
Wants: at least 1
Possible bug: synth/diff if no top-level and no patterns
Auto:
| MATCH (extended, must match)
| MAIN (not empty, not extended)
- fail if no stack at all
- never all top-level
- pattern if provided (extended)
- otherwise Main (not extended)
- Custom: Not none if patterns
### Diff
ALL+, MUST_MATCH, ONLY_ONE
Wants Exactly 1 of template path
Bug?: When top-level is empty
cdk diff "*/*" -> finds both
cdk diff "*" -> finds none
cdk diff -> 0 stacks with differences (bug!!!)
### Synth
ALL+, MUST_MATCH
More than one doesn't really matter
Bug if top-level is empty
Supply a stack id () to display its template. -> list in () is empty
## Deploy: Selector, used by: Deploy, Rollback, Import
- Custom: Not none if patterns
### Deploy
ALL+, MAIN+, MUST_MATCH, ONLY_ONE
Bug: Empty top level and "cdk deploy --all"
Wants: at least 1
- OPTION: fail if no stack at all
- OPTION: Extends
- selector: all or patterns or exactly 1
- Custom: Not none
### Rollback
ALL+, MAIN+, MUST_MATCH, ONLY_ONE
Wants: at least 1
- fail if no stack at all
- selector: all or patterns or exactly 1
- no extend
- Custom: Not none
### Import
MUST_MATCH_ONE, ONLY_ONE
Wants: Exactly 1
- fail if no stack at all
- selector: all or patterns or exactly 1
- no extend
- Custom: more then one
```
### Checklist
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*1 parent 613a874 commit f3f8802
File tree
4 files changed
+158
-49
lines changed- packages
- @aws-cdk/toolkit/lib
- api/cloud-assembly
- aws-cdk/lib/api/cxapp
4 files changed
+158
-49
lines changedLines changed: 99 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
| |||
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
12 | 110 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
223 | | - | |
224 | | - | |
| 222 | + | |
225 | 223 | | |
226 | | - | |
227 | 224 | | |
228 | 225 | | |
229 | 226 | | |
| |||
321 | 318 | | |
322 | 319 | | |
323 | 320 | | |
324 | | - | |
| 321 | + | |
325 | 322 | | |
326 | 323 | | |
327 | 324 | | |
| |||
454 | 451 | | |
455 | 452 | | |
456 | 453 | | |
457 | | - | |
| 454 | + | |
458 | 455 | | |
459 | 456 | | |
460 | 457 | | |
| |||
474 | 471 | | |
475 | 472 | | |
476 | 473 | | |
477 | | - | |
| 474 | + | |
478 | 475 | | |
479 | 476 | | |
480 | 477 | | |
| |||
523 | 520 | | |
524 | 521 | | |
525 | 522 | | |
526 | | - | |
527 | | - | |
528 | 523 | | |
529 | 524 | | |
530 | 525 | | |
| |||
533 | 528 | | |
534 | 529 | | |
535 | 530 | | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | 531 | | |
548 | 532 | | |
549 | 533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
17 | 18 | | |
18 | | - | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 22 | + | |
25 | 23 | | |
26 | | - | |
| 24 | + | |
27 | 25 | | |
28 | 26 | | |
29 | | - | |
| 27 | + | |
| 28 | + | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | | - | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
40 | | - | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
| |||
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
63 | 78 | | |
64 | 79 | | |
65 | 80 | | |
66 | 81 | | |
67 | 82 | | |
68 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
69 | 89 | | |
70 | 90 | | |
| 91 | + | |
71 | 92 | | |
72 | 93 | | |
73 | 94 | | |
74 | 95 | | |
75 | | - | |
76 | | - | |
| 96 | + | |
| 97 | + | |
77 | 98 | | |
78 | 99 | | |
79 | 100 | | |
80 | 101 | | |
81 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
82 | 109 | | |
83 | | - | |
| 110 | + | |
84 | 111 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
245 | | - | |
| 244 | + | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| |||
0 commit comments