generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 48
feat: add message about unconfigured feature flags when user runs cdk synth
#765
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
7 commits
Select commit
Hold shift + click to select a range
8bace73
add flags message for cdk synth
vivian12300 0d3c052
spacing change
vivian12300 3e61267
Merge branch 'flag-message' of https://github.com/vivian12300/aws-cdk…
vivian12300 90459e3
address PR comments
vivian12300 1dcc418
address PR comments
vivian12300 0a323fe
update file
vivian12300 ea90145
minor fix
vivian12300 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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const OBSOLETE_FLAGS = [ | ||
'@aws-cdk/core:enableStackNameDuplicates', | ||
'@aws-cdk/aws-s3:grantWriteWithoutAcl', | ||
'@aws-cdk/aws-kms:defaultKeyPolicies', | ||
]; |
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,83 @@ | ||
import { Toolkit } from '@aws-cdk/toolkit-lib'; | ||
import { asIoHelper } from '../../lib/api-private'; | ||
import { displayFlagsMessage } from '../../lib/cli/cdk-toolkit'; | ||
import { TestIoHost } from '../_helpers/io-host'; | ||
|
||
describe('displayFlagsMessage', () => { | ||
let ioHost: TestIoHost; | ||
let ioHelper: any; | ||
let mockToolkit: jest.Mocked<Toolkit>; | ||
let mockCloudExecutable: any; | ||
|
||
beforeEach(() => { | ||
ioHost = new TestIoHost(); | ||
ioHelper = asIoHelper(ioHost, 'synth'); | ||
mockCloudExecutable = {}; | ||
|
||
mockToolkit = { | ||
flags: jest.fn(), | ||
} as any; | ||
|
||
jest.spyOn(Toolkit.prototype, 'flags').mockImplementation(mockToolkit.flags); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
test('displays message with correct count of unconfigured flags, filtering out obsolete flags', async () => { | ||
const mockFlagsData = [ | ||
{ | ||
name: '@aws-cdk/core:testFlag', | ||
userValue: undefined, | ||
recommendedValue: 'true', | ||
explanation: 'Test flag', | ||
module: 'aws-cdk-lib', | ||
}, | ||
{ | ||
name: '@aws-cdk/s3:anotherFlag', | ||
userValue: 'false', | ||
recommendedValue: 'false', | ||
explanation: 'Another test flag', | ||
module: 'aws-cdk-lib', | ||
}, | ||
{ | ||
name: '@aws-cdk/core:enableStackNameDuplicates', | ||
userValue: undefined, | ||
recommendedValue: 'true', | ||
explanation: 'Obsolete flag', | ||
module: 'aws-cdk-lib', | ||
}, | ||
]; | ||
|
||
mockToolkit.flags.mockResolvedValue(mockFlagsData); | ||
|
||
await displayFlagsMessage(mockToolkit as any, mockCloudExecutable, ioHelper); | ||
|
||
expect(mockToolkit.flags).toHaveBeenCalledWith(mockCloudExecutable); | ||
expect(ioHost.notifySpy).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
message: 'You currently have 1 unconfigured feature flags that may require attention to keep your application up-to-date. Run \'cdk flags\' to learn more.', | ||
level: 'info', | ||
}), | ||
); | ||
}); | ||
test('does not display a message when user has no unconfigured flags', async () => { | ||
const mockFlagsData = [ | ||
{ | ||
name: '@aws-cdk/s3:anotherFlag', | ||
userValue: 'false', | ||
recommendedValue: 'false', | ||
explanation: 'Another test flag', | ||
module: 'aws-cdk-lib', | ||
}, | ||
]; | ||
mockToolkit.flags.mockResolvedValue(mockFlagsData); | ||
|
||
await displayFlagsMessage(mockToolkit as any, mockCloudExecutable, ioHelper); | ||
|
||
expect(mockToolkit.flags).toHaveBeenCalledWith(mockCloudExecutable); | ||
expect(ioHost.notifySpy).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.