Skip to content

Commit

Permalink
feat(sre): add default feature flags [INFRA-20920]
Browse files Browse the repository at this point in the history
  • Loading branch information
KLoganCU committed Aug 30, 2024
1 parent aba860f commit 8cd014c
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 4 deletions.
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

0 comments on commit 8cd014c

Please sign in to comment.