-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cli): collate existing files into new deployments api (#33094)
### Reason for this change Cleaning up the CLI code base in preparation for splitting out the library parts. It's currently quite hard to reason about the existing api code as its spread across many files and deep subpath imports. This change attempts to partly rectify the situation by grouping files with strong interdependencies together and creating a unified import location. The change deliberately gives up on potential feature reusability of some helpers in order to create locality. ### Description of changes Collating existing files and APIs into a new submodule `api/deployments`. Updated imports accordingly. No functional changes. ### Describe any new or updated permissions being added n/a ### Description of how you validated changes exiting tests ### 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*
- Loading branch information
Showing
43 changed files
with
233 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/aws-cdk/lib/api/util/checks.ts → ...ges/aws-cdk/lib/api/deployments/checks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export type DeploymentMethod = DirectDeploymentMethod | ChangeSetDeploymentMethod; | ||
|
||
export interface DirectDeploymentMethod { | ||
readonly method: 'direct'; | ||
} | ||
|
||
export interface ChangeSetDeploymentMethod { | ||
readonly method: 'change-set'; | ||
|
||
/** | ||
* Whether to execute the changeset or leave it in review. | ||
* | ||
* @default true | ||
*/ | ||
readonly execute?: boolean; | ||
|
||
/** | ||
* Optional name to use for the CloudFormation change set. | ||
* If not provided, a name will be generated automatically. | ||
*/ | ||
readonly changeSetName?: string; | ||
|
||
/** | ||
* Indicates if the change set imports resources that already exist. | ||
* | ||
* @default false | ||
*/ | ||
readonly importExistingResources?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ToolkitError } from '../../toolkit/error'; | ||
|
||
export type DeployStackResult = | ||
| SuccessfulDeployStackResult | ||
| NeedRollbackFirstDeployStackResult | ||
| ReplacementRequiresRollbackStackResult | ||
; | ||
|
||
/** Successfully deployed a stack */ | ||
export interface SuccessfulDeployStackResult { | ||
readonly type: 'did-deploy-stack'; | ||
readonly noOp: boolean; | ||
readonly outputs: { [name: string]: string }; | ||
readonly stackArn: string; | ||
} | ||
|
||
/** The stack is currently in a failpaused state, and needs to be rolled back before the deployment */ | ||
export interface NeedRollbackFirstDeployStackResult { | ||
readonly type: 'failpaused-need-rollback-first'; | ||
readonly reason: 'not-norollback' | 'replacement'; | ||
readonly status: string; | ||
} | ||
|
||
/** The upcoming change has a replacement, which requires deploying with --rollback */ | ||
export interface ReplacementRequiresRollbackStackResult { | ||
readonly type: 'replacement-requires-rollback'; | ||
} | ||
|
||
export function assertIsSuccessfulDeployStackResult(x: DeployStackResult): asserts x is SuccessfulDeployStackResult { | ||
if (x.type !== 'did-deploy-stack') { | ||
throw new ToolkitError(`Unexpected deployStack result. This should not happen: ${JSON.stringify(x)}. If you are seeing this error, please report it at https://github.com/aws/aws-cdk/issues/new/choose.`); | ||
} | ||
} |
Oops, something went wrong.