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

feat(sre): add default feature flags [INFRA-20920] #288

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 14 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/cdk-context-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export module cdkContextJson {
* @default - do not create stack SampleCode for OIDC role
*/
readonly createOidcRoleStack?: boolean;
/**
* Add default feature flags for CDK
*
* @default - true
*/
readonly addDefaultFeatureFlags?: boolean;
/**
* You must configure this if you want to self-mutation cdk.context.json.
*
Expand All @@ -40,6 +46,12 @@ export module cdkContextJson {
readonly injectionOptions?: InjectionOptions;
}

export function addDefaultFeatureFlags(project: awscdk.AwsCdkTypeScriptApp): void {
project.cdkConfig.json.addOverride('context', {
'@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker': true,
});
}

export function injectAwsAuthIntoBuild(project: awscdk.AwsCdkTypeScriptApp, options: InjectionOptions): void {
const build = project.tryFindObjectFile('.github/workflows/build.yml');
build?.addOverride('jobs.build.permissions', { 'id-token': 'write' });
Expand Down
4 changes: 4 additions & 0 deletions src/clickup-cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ export module clickupCdk {
}
}

if (options.cdkContextJsonOptions?.addDefaultFeatureFlags !== false) {
cdkContextJson.addDefaultFeatureFlags(this);
}

if (options.sendReleaseEvent === false) {
this.datadogEvent = false;
} else {
Expand Down
28 changes: 28 additions & 0 deletions test/__snapshots__/cdk-context-json.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions test/__snapshots__/clickup-cdk.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions test/cdk-context-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ describe('addOidcRoleStack', () => {
expect(synth['src/github-actions-oidc-cdk-context-lookup-role.ts']).toMatchSnapshot();
});
});

describe('addDefaultFeatureFlags', () => {
const project = new awscdk.AwsCdkTypeScriptApp(requiredParams);
cdkContextJson.addDefaultFeatureFlags(project);
const synth = Testing.synth(project);
test('adds feature flags', () => {
expect(synth['cdk.json']).toMatchSnapshot();
});
});
1 change: 1 addition & 0 deletions test/clickup-cdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('ClickUpCdkTypeScriptApp', () => {
'src/widget.ts',
'test/widget.test.ts',
'.github/workflows/release.yml',
'cdk.json',
].forEach((file) => {
test(file, () => {
expect(synth[file]).toMatchSnapshot();
Expand Down
Loading