Skip to content
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

chore(cdk): remove expired feature flags from init templates #13085

Merged
merged 2 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion packages/@aws-cdk/cx-api/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const S3_GRANT_WRITE_WITHOUT_ACL = '@aws-cdk/aws-s3:grantWriteWithoutAcl'
*
* Tests must cover the default (disabled) case and the future (enabled) case.
*/
export const FUTURE_FLAGS = {
export const FUTURE_FLAGS: { [key: string]: any } = {
[ENABLE_STACK_NAME_DUPLICATES_CONTEXT]: 'true',
[ENABLE_DIFF_NO_FAIL_CONTEXT]: 'true',
[STACK_RELATIVE_EXPORTS_CONTEXT]: 'true',
Expand Down
7 changes: 6 additions & 1 deletion packages/aws-cdk/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,15 @@ export class InitTemplate {
return;
}

const futureFlags: {[key: string]: any} = {};
Object.entries(cxapi.FUTURE_FLAGS)
.filter(([k, _]) => !cxapi.FUTURE_FLAGS_EXPIRED.includes(k))
.forEach(([k, v]) => futureFlags[k] = v);

const config = await fs.readJson(cdkJson);
config.context = {
...config.context,
...cxapi.FUTURE_FLAGS,
...futureFlags,
};

await fs.writeJson(cdkJson, config, { spaces: 2 });
Expand Down
9 changes: 7 additions & 2 deletions packages/aws-cdk/test/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ describe.each(['1', '2'])('v%s tests', (majorVersion) => {

const config = await fs.readJson(path.join(tmpDir, 'cdk.json'));
const context = config.context || {};
for (const [key, expected] of Object.entries(cxapi.FUTURE_FLAGS)) {
const actual = context[key];
for (const [key, expected] of Object.entries(context)) {
const actual = cxapi.FUTURE_FLAGS[key];
expect(actual).toEqual(expected);
}

// assert that expired future flags are not part of the cdk.json
Object.keys(context).forEach(k => {
expect(cxapi.FUTURE_FLAGS_EXPIRED.includes(k)).toEqual(false);
});
});
}
}
Expand Down