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

fix: Don't collect runtime information when versionReporting is disabled #1890

Merged
merged 2 commits into from
Feb 28, 2019
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
8 changes: 6 additions & 2 deletions packages/@aws-cdk/cdk/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ export class App extends Root {

const result: cxapi.SynthesizeResponse = {
version: cxapi.PROTO_RESPONSE_VERSION,
stacks: this.synthesizeStacks(Object.keys(this.stacks)),
runtime: this.collectRuntimeInformation()
stacks: this.synthesizeStacks(Object.keys(this.stacks))
};

const disableVersionReporting = this.node.getContext(cxapi.DISABLE_VERSION_REPORTING);
if (!disableVersionReporting) {
result.runtime = this.collectRuntimeInformation();
}

const outfile = path.join(outdir, cxapi.OUTFILE_NAME);
fs.writeFileSync(outfile, JSON.stringify(result, undefined, 2));
}
Expand Down
13 changes: 13 additions & 0 deletions packages/@aws-cdk/cdk/test/test.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@ export = {
test.done();
},

'runtime library versions disabled'(test: Test) {
const context: any = {};
context[cxapi.DISABLE_VERSION_REPORTING] = true;

const response = withApp(context, app => {
const stack = new Stack(app, 'stack1');
new Resource(stack, 'MyResource', { type: 'Resource::Type' });
});

test.equals(response.runtime, undefined);
test.done();
},

'runtime library versions'(test: Test) {
const response = withApp({}, app => {
const stack = new Stack(app, 'stack1');
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/cx-api/lib/cxapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,8 @@ export const PATH_METADATA_KEY = 'aws:cdk:path';
* Enables the embedding of the "aws:cdk:path" in CloudFormation template metadata.
*/
export const PATH_METADATA_ENABLE_CONTEXT = 'aws:cdk:enable-path-metadata';

/**
* Disable the collection and reporting of version information.
*/
export const DISABLE_VERSION_REPORTING = 'aws:cdk:disable-version-reporting';
9 changes: 9 additions & 0 deletions packages/aws-cdk/lib/api/cxapp/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ export async function execProgram(aws: SDK, config: Settings): Promise<cxapi.Syn
context[cxapi.ASSET_RESOURCE_METADATA_ENABLED_CONTEXT] = true;
}

let versionReporting: boolean = config.get(['versionReporting']);
if (versionReporting === undefined) {
versionReporting = true; // defaults to true
}

if (!versionReporting) {
context[cxapi.DISABLE_VERSION_REPORTING] = true;
}

debug('context:', context);

env[cxapi.CONTEXT_ENV] = JSON.stringify(context);
Expand Down