generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 69
fix(cli): hotswap is reporting and running changes that don't happen #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/hotswap.ts
This file contains hidden or 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,30 @@ | ||
| import type { PropertyDifference, Resource } from '@aws-cdk/cloudformation-diff'; | ||
|
|
||
| /** | ||
| * Represents a change in a resource | ||
| */ | ||
| export interface ResourceChange { | ||
| /** | ||
| * The logical ID of the resource which is being changed | ||
| */ | ||
| readonly logicalId: string; | ||
| /** | ||
| * The value the resource is being updated from | ||
| */ | ||
| readonly oldValue: Resource; | ||
| /** | ||
| * The value the resource is being updated to | ||
| */ | ||
| readonly newValue: Resource; | ||
| /** | ||
| * The changes made to the resource properties | ||
| */ | ||
| readonly propertyUpdates: Record<string, PropertyDifference<unknown>>; | ||
| } | ||
|
|
||
| export interface HotswappableChange { | ||
| /** | ||
| * The resource change that is causing the hotswap. | ||
| */ | ||
| readonly cause: ResourceChange; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,24 +1,35 @@ | ||
| import type { PropertyDifference, Resource } from '@aws-cdk/cloudformation-diff'; | ||
| import type { PropertyDifference } from '@aws-cdk/cloudformation-diff'; | ||
| import type { HotswappableChange, ResourceChange } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/hotswap'; | ||
| import { ToolkitError } from '../../toolkit/error'; | ||
| import type { SDK } from '../aws-auth'; | ||
|
|
||
| export const ICON = '✨'; | ||
|
|
||
| export interface HotswappableChange { | ||
| export interface HotswapOperation { | ||
| /** | ||
| * Marks the operation as hotswappable | ||
| */ | ||
| readonly hotswappable: true; | ||
| readonly resourceType: string; | ||
| readonly propsChanged: Array<string>; | ||
|
|
||
| /** | ||
| * The name of the service being hotswapped. | ||
| * Used to set a custom User-Agent for SDK calls. | ||
| */ | ||
| readonly service: string; | ||
|
|
||
| /** | ||
| * Description of the change that is applied as part of the operation | ||
| */ | ||
| readonly change: HotswappableChange; | ||
|
|
||
| /** | ||
| * The names of the resources being hotswapped. | ||
| */ | ||
| readonly resourceNames: string[]; | ||
|
|
||
| /** | ||
| * Applies the hotswap operation | ||
| */ | ||
| readonly apply: (sdk: SDK) => Promise<void>; | ||
| } | ||
|
|
||
|
|
@@ -41,10 +52,10 @@ export interface NonHotswappableChange { | |
| readonly hotswapOnlyVisible?: boolean; | ||
| } | ||
|
|
||
| export type ChangeHotswapResult = Array<HotswappableChange | NonHotswappableChange>; | ||
| export type ChangeHotswapResult = Array<HotswapOperation | NonHotswappableChange>; | ||
|
|
||
| export interface ClassifiedResourceChanges { | ||
| hotswappableChanges: HotswappableChange[]; | ||
| hotswappableChanges: HotswapOperation[]; | ||
| nonHotswappableChanges: NonHotswappableChange[]; | ||
| } | ||
|
|
||
|
|
@@ -65,38 +76,6 @@ export enum HotswapMode { | |
| FULL_DEPLOYMENT = 'full-deployment', | ||
| } | ||
|
|
||
| /** | ||
| * Represents a change that can be hotswapped. | ||
| */ | ||
| export class HotswappableChangeCandidate { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a class, but was never used as one. It's now an interface as it should be. |
||
| /** | ||
| * The logical ID of the resource which is being changed | ||
| */ | ||
| public readonly logicalId: string; | ||
|
|
||
| /** | ||
| * The value the resource is being updated from | ||
| */ | ||
| public readonly oldValue: Resource; | ||
|
|
||
| /** | ||
| * The value the resource is being updated to | ||
| */ | ||
| public readonly newValue: Resource; | ||
|
|
||
| /** | ||
| * The changes made to the resource properties | ||
| */ | ||
| public readonly propertyUpdates: PropDiffs; | ||
|
|
||
| public constructor(logicalId: string, oldValue: Resource, newValue: Resource, propertyUpdates: PropDiffs) { | ||
| this.logicalId = logicalId; | ||
| this.oldValue = oldValue; | ||
| this.newValue = newValue; | ||
| this.propertyUpdates = propertyUpdates; | ||
| } | ||
| } | ||
|
|
||
| type Exclude = { [key: string]: Exclude | true }; | ||
|
|
||
| /** | ||
|
|
@@ -182,11 +161,11 @@ export function lowerCaseFirstCharacter(str: string): string { | |
| return str.length > 0 ? `${str[0].toLowerCase()}${str.slice(1)}` : str; | ||
| } | ||
|
|
||
| export type PropDiffs = Record<string, PropertyDifference<any>>; | ||
| type PropDiffs = Record<string, PropertyDifference<any>>; | ||
|
|
||
| export class ClassifiedChanges { | ||
| public constructor( | ||
| public readonly change: HotswappableChangeCandidate, | ||
| public readonly change: ResourceChange, | ||
| public readonly hotswappableProps: PropDiffs, | ||
| public readonly nonHotswappableProps: PropDiffs, | ||
| ) { | ||
|
|
@@ -212,7 +191,7 @@ export class ClassifiedChanges { | |
| } | ||
| } | ||
|
|
||
| export function classifyChanges(xs: HotswappableChangeCandidate, hotswappablePropNames: string[]): ClassifiedChanges { | ||
| export function classifyChanges(xs: ResourceChange, hotswappablePropNames: string[]): ClassifiedChanges { | ||
| const hotswappableProps: PropDiffs = {}; | ||
| const nonHotswappableProps: PropDiffs = {}; | ||
|
|
||
|
|
@@ -229,7 +208,7 @@ export function classifyChanges(xs: HotswappableChangeCandidate, hotswappablePro | |
|
|
||
| export function reportNonHotswappableChange( | ||
| ret: ChangeHotswapResult, | ||
| change: HotswappableChangeCandidate, | ||
| change: ResourceChange, | ||
| nonHotswappableProps?: PropDiffs, | ||
| reason?: string, | ||
| hotswapOnlyVisible?: boolean, | ||
|
|
@@ -249,7 +228,7 @@ export function reportNonHotswappableChange( | |
| } | ||
|
|
||
| export function reportNonHotswappableResource( | ||
| change: HotswappableChangeCandidate, | ||
| change: ResourceChange, | ||
| reason?: string, | ||
| ): ChangeHotswapResult { | ||
| return [ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly, these were unused.
propsChangedis not made available as raw data viachange.