Skip to content

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Jan 15, 2025

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


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Jan 15, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team January 15, 2025 00:13
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 15, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation added the pr/needs-cli-test-run This PR needs CLI tests run against it. label Jan 15, 2025
@mrgrain mrgrain marked this pull request as ready for review January 15, 2025 00:16
@mrgrain mrgrain requested a review from a team as a code owner January 15, 2025 00:16
@mrgrain mrgrain force-pushed the mrgrain/chore/stack-selectors branch from 694e142 to 14a313e Compare January 15, 2025 00:16
@mrgrain mrgrain changed the title feat(toolkit): new and improved stack selection chore(toolkit): new and improved stack selection Jan 15, 2025
@aws-cdk-automation
Copy link
Collaborator

The pull request linter fails with the following errors:

❌ CLI code has changed. A maintainer must run the code through the testing pipeline (git fetch origin pull/32928/head && git push -f origin FETCH_HEAD:test-main-pipeline), then add the 'pr-linter/cli-integ-tested' label when the pipeline succeeds.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

@mrgrain mrgrain merged commit f3f8802 into mrgrain/toolkit-poc Jan 15, 2025
10 of 14 checks passed
@mrgrain mrgrain deleted the mrgrain/chore/stack-selectors branch January 15, 2025 09:42
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2 pr/needs-cli-test-run This PR needs CLI tests run against it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants