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

refactor(core): misc cleanups to App-related APIs #2731

Merged
merged 20 commits into from
Jun 5, 2019
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/app-delivery/test/integ.cicd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ new cicd.PipelineDeployStackAction(stack, 'DeployStack', {
capabilities: cfn.CloudFormationCapabilities.None,
});

app.run();
app.synth();
6 changes: 3 additions & 3 deletions packages/@aws-cdk/assert/lib/synth-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stack, SynthesisOptions, Synthesizer } from '@aws-cdk/cdk';
import { ConstructNode, Stack, SynthesisOptions } from '@aws-cdk/cdk';
import cxapi = require('@aws-cdk/cx-api');

export class SynthUtils {
Expand All @@ -7,8 +7,8 @@ export class SynthUtils {
*/
public static synthesize(stack: Stack, options: SynthesisOptions = { }): cxapi.CloudFormationStackArtifact {
// always synthesize against the root (be it an App or whatever) so all artifacts will be included
const synth = new Synthesizer();
const assembly = synth.synthesize(stack.node.root, options);
const root = stack.node.root;
const assembly = ConstructNode.synth(root.node, options);
return assembly.getStack(stack.name);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assert/test/test.assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function synthesizedStack(fn: (stack: cdk.Stack) => void): cx.CloudFormationStac
const stack = new cdk.Stack(app, 'TestStack');
fn(stack);

const assembly = app.run();
const assembly = app.synth();
return assembly.getStack(stack.name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ const asset = new assets.DockerImageAsset(stack, 'DockerImage', {
new cdk.CfnOutput(stack, 'ArtifactHash', { value: asset.artifactHash });
new cdk.CfnOutput(stack, 'ImageUri', { value: asset.imageUri });

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets-docker/test/test.image-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export = {
directory: path.join(__dirname, 'demo-image')
});

const session = app.run();
const session = app.synth();

test.ok(fs.existsSync(path.join(session.directory, 'asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/Dockerfile')));
test.ok(fs.existsSync(path.join(session.directory, 'asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/index.py')));
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/assets/lib/staging.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Construct, ISynthesisSession, ISynthesizable } from '@aws-cdk/cdk';
import { Construct, ISynthesisSession } from '@aws-cdk/cdk';
import cxapi = require('@aws-cdk/cx-api');
import fs = require('fs');
import path = require('path');
Expand Down Expand Up @@ -26,7 +26,7 @@ export interface StagingProps extends CopyOptions {
* The file/directory are staged based on their content hash (fingerprint). This
* means that only if content was changed, copy will happen.
*/
export class Staging extends Construct implements ISynthesizable {
export class Staging extends Construct {

/**
* The path to the asset (stringinfied token).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class TestStack extends cdk.Stack {

const app = new cdk.App();
new TestStack(app, 'aws-cdk-asset-test');
app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets/test/integ.assets.file.lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class TestStack extends cdk.Stack {

const app = new cdk.App();
new TestStack(app, 'aws-cdk-asset-file-test');
app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class TestStack extends cdk.Stack {

const app = new cdk.App();
new TestStack(app, 'aws-cdk-asset-refs');
app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets/test/integ.assets.refs.lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class TestStack extends cdk.Stack {

const app = new cdk.App();
new TestStack(app, 'aws-cdk-asset-refs');
app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/assets/test/integ.multi-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class TestStack extends cdk.Stack {

const app = new cdk.App();
new TestStack(app, 'aws-cdk-multi-assets');
app.run();
app.synth();
10 changes: 5 additions & 5 deletions packages/@aws-cdk/assets/test/test.asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export = {
test.ok(entry, 'found metadata entry');

// verify that now the template contains parameters for this asset
const session = app.run();
const session = app.synth();

test.deepEqual(stack.node.resolve(entry!.data), {
path: SAMPLE_ASSET_DIR,
Expand Down Expand Up @@ -57,7 +57,7 @@ export = {
path: dirPath
});

const synth = app.run().getStack(stack.name);
const synth = app.synth().getStack(stack.name);
const meta = synth.manifest.metadata || {};
test.deepEqual(meta['/my-stack/MyAsset'][0].data, {
eladb marked this conversation as resolved.
Show resolved Hide resolved
path: 'asset.6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2',
Expand Down Expand Up @@ -249,7 +249,7 @@ export = {
});

// THEN
app.run();
app.synth();
test.ok(fs.existsSync(tempdir));
test.ok(fs.existsSync(path.join(tempdir, 'asset.a7a79cdf84b802ea8b198059ff899cffc095a1b9606e919f98e05bf80779756b.zip')));
test.done();
Expand All @@ -269,7 +269,7 @@ export = {
});

// THEN
app.run();
app.synth();
test.ok(fs.existsSync(tempdir));
const hash = 'asset.6b84b87243a4a01c592d78e1fd3855c4bfef39328cd0a450cc97e81717fea2a2';
test.ok(fs.existsSync(path.join(tempdir, hash, 'sample-asset-file.txt')));
Expand Down Expand Up @@ -341,7 +341,7 @@ export = {
new ZipDirectoryAsset(stack, 'MyAsset', { path: SAMPLE_ASSET_DIR });

// WHEN
const session = app.run();
const session = app.synth();
const artifact = session.getStack(stack.name);

const md = Object.values(artifact.manifest.metadata || {})[0][0].data;
eladb marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ function helloCode(_event: any, _context: any, callback: any) {
});
}

new BookApp().run();
new BookApp().synth();
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const api = new apigateway.RestApi(stack, 'my-api');
// at least one method is required
api.root.addMethod('GET');

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/integ.restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ const app = new cdk.App();

new Test(app, 'test-apigateway-restapi');

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/test.restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export = {
api.root.addResource('bar').addResource('goo');

// THEN
test.throws(() => app.run(), /The REST API doesn't contain any methods/);
test.throws(() => app.synth(), /The REST API doesn't contain any methods/);
test.done();
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ new autoscaling.AutoScalingGroup(stack, 'Fleet', {
machineImage: new ec2.AmazonLinuxImage({ generation: ec2.AmazonLinuxGeneration.AmazonLinux2 }),
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const lb = new elb.LoadBalancer(stack, 'LB', {
lb.addTarget(asg);
lb.addListener({ externalPort: 80 });

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ asg.scaleOnRequestCount('AModestLoad', {
targetRequestsPerSecond: 1
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ asg.scaleOnCpuUtilization('KeepCPUReasonable', {
targetUtilizationPercent: 50
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ const app = new cdk.App();

new TestStack(app, 'integ-iam-external-role');

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ new autoscaling.AutoScalingGroup(stack, 'Fleet', {
spotPrice: '0.20'
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ new cdk.CfnOutput(stack, 'MessageId', { value: snsPublish.getData('MessageId') }
new cdk.CfnOutput(stack, 'TopicArn', { value: listTopics.getData('Topics.0.TopicArn') });
new cdk.CfnOutput(stack, 'ParameterValue', { value: getParameter.getData('Parameter.Value') });

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ const app = new cdk.App();

new SucceedingStack(app, 'SucceedingStack');

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ new cloudfront.CloudFrontWebDistribution(stack, 'AnAmazingWebsiteProbably2', {
loggingConfig: {}
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ new cloudfront.CloudFrontWebDistribution(stack, 'AnAmazingWebsiteProbably', {
]
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ new cloudfront.CloudFrontWebDistribution(stack, 'AnAmazingWebsiteProbably', {
defaultRootObject: ''
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribution', {
enableIpV6: false
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ new cloudfront.CloudFrontWebDistribution(stack, 'AnAmazingWebsiteProbably', {
}
});

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ new cloudfront.CloudFrontWebDistribution(stack, 'MyDistribution', {
]
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const bucket = new s3.Bucket(stack, 'Bucket', { removalPolicy: cdk.RemovalPolicy
const trail = new cloudtrail.Trail(stack, 'Trail');
trail.addS3EventSelector([bucket.arnForObjects('')]);

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ dashboard.add(new cloudwatch.SingleValueWidget({
metrics: [metric]
}));

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/test/integ.caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ new codebuild.Project(stack, 'MyProject', {
}
});

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/test/integ.defaults.lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ const app = new cdk.App();

new TestStack(app, 'codebuild-default-project');

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ const app = new cdk.App();

new TestStack(app, 'test-codebuild-docker-asset');

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/test/integ.ecr.lit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ const app = new cdk.App();

new TestStack(app, 'test-codebuild-docker-asset');

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/test/integ.github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ const app = new cdk.App();

new TestStack(app, 'test-codebuild-github');

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ new codebuild.Project(stack, 'MyProject', {
}
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ new codebuild.Project(stack, 'MyProject', {
],
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ new Project(stack, 'MyProject', {
buildScriptAsset: new assets.ZipDirectoryAsset(stack, 'Bundle', { path: 'script_bundle' })
});

app.run();
app.synth();
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/test/integ.project-vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ new Project(stack, 'MyProject', {
vpc
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ repo.onReferenceCreated('OnReferenceCreated', {
}
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ new codedeploy.LambdaDeploymentGroup(stack, 'BlueGreenDeployment', {
postHook
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ new codedeploy.ServerDeploymentGroup(stack, 'CodeDeployGroup', {
},
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ new codepipeline.Pipeline(stack, 'Pipeline', {
});
/// !hide

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ lambdaStage.addAction(new cpactions.LambdaInvokeAction({
lambda: lambdaFun,
}));

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ new codepipeline.Pipeline(stack, 'Pipeline', {
],
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ new codepipeline.Pipeline(stack, 'MyPipeline', {
],
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ pipeline.addToRolePolicy(new iam.PolicyStatement()
.addAllResources()
);

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ pipeline.addStage({
],
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ pipeline.addStage({
],
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ new codepipeline.Pipeline(stack, 'Pipeline', {
],
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ new codepipeline.Pipeline(stack, 'Pipeline', {
],
});

app.run();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ deployStage.addAction(new cpactions.CodeDeployServerDeployAction({
input: sourceOutput,
}));

app.run();
app.synth();
Loading