Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ function parseFeatureFlagInfo(flagName: string, info: FlagInfo, root: IConstruct
export function generateFeatureFlagReport(builder: CloudAssemblyBuilder, root: IConstruct): void {
const featureFlags: Record<string, FeatureFlag> = {};
for (const [flagName, flagInfo] of Object.entries(feats.FLAGS)) {
// Skip flags that don't apply to the current version line
if (feats.CURRENT_VERSION_EXPIRED_FLAGS.includes(flagName)) {
continue;
}

featureFlags[flagName] = parseFeatureFlagInfo(flagName, flagInfo, root);
}

Expand Down
20 changes: 18 additions & 2 deletions packages/aws-cdk-lib/core/test/feature-flag-report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('generate feature flag report', () => {
const app = new App({
context: {
'@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault': true,
'@aws-cdk/core:aspectStabilization': false,
'@aws-cdk/core:newStyleStackSynthesis': false,
},
});
const assembly = app.synth();
Expand All @@ -25,9 +25,14 @@ describe('generate feature flag report', () => {
flags: expect.objectContaining({
'@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault': expect.objectContaining({
userValue: true,
recommendedValue: true,
}),
'@aws-cdk/core:aspectStabilization': expect.objectContaining({
'@aws-cdk/core:newStyleStackSynthesis': expect.objectContaining({
userValue: false,
recommendedValue: true,
unconfiguredBehavesLike: {
v2: true,
},
}),
}),
}),
Expand All @@ -47,4 +52,15 @@ describe('generate feature flag report', () => {
}),
}));
});
test('expired flags are not included in report', () => {
const app = new App();
const builder = new cxapi.CloudAssemblyBuilder('/tmp/test');
const spy = jest.spyOn(builder, 'addArtifact');

generateFeatureFlagReport(builder, app);

const flags = (spy.mock.calls[0][1].properties as FeatureFlagReportProperties).flags;
// For example
expect(Object.keys(flags)).not.toContain('aws-cdk:enableDiffNoFail');
});
});
14 changes: 6 additions & 8 deletions packages/aws-cdk-lib/cx-api/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1696,18 +1696,16 @@ export const CURRENT_VERSION_EXPIRED_FLAGS: string[] = Object.entries(FLAGS)
/**
* Flag values that should apply for new projects
*
* Add a flag in here (typically with the value `true`), to enable
* backwards-breaking behavior changes only for new projects. New projects
* generated through `cdk init` will include these flags in their generated
* project config.
* This contains flags that satisfy both criteria of:
*
* Tests must cover the default (disabled) case and the future (enabled) case.
*
* Going forward, this should *NOT* be consumed directly anymore.
* - They are configurable for the current major version line.
* - The recommended value is different from the unconfigured value (i.e.,
* configuring a flag is useful)
*/
export const CURRENTLY_RECOMMENDED_FLAGS = Object.fromEntries(
Object.entries(FLAGS)
.filter(([_, flag]) => flag.recommendedValue !== flag.unconfiguredBehavesLike?.[CURRENT_MV] && flag.introducedIn[CURRENT_MV])
.filter(([_, flag]) => flag.introducedIn[CURRENT_MV] !== undefined)
.filter(([_, flag]) => flag.recommendedValue !== flag.unconfiguredBehavesLike?.[CURRENT_MV])
.map(([name, flag]) => [name, flag.recommendedValue]),
);

Expand Down
Loading