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(cli): stop processing on metadata errors #3168

Merged
merged 5 commits into from
Jul 3, 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
2 changes: 2 additions & 0 deletions packages/aws-cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ async function initCommandLine() {
defaultBehavior: DefaultSelection.AllStacks
});

appStacks.processMetadata(stacks);

// if we have a single stack, print it to STDOUT
if (stacks.length === 1) {
return stacks[0].template;
Expand Down
5 changes: 1 addition & 4 deletions packages/aws-cdk/lib/api/cxapp/stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ export class AppStacks {
// Filter original array because it is in the right order
const selectedList = stacks.filter(s => selectedStacks.has(s.name));

// Only check selected stacks for errors
this.processMessages(selectedList);

return selectedList;
}

Expand Down Expand Up @@ -269,7 +266,7 @@ export class AppStacks {
/**
* Extracts 'aws:cdk:warning|info|error' metadata entries from the stack synthesis
*/
private processMessages(stacks: cxapi.CloudFormationStackArtifact[]) {
public processMetadata(stacks: cxapi.CloudFormationStackArtifact[]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call this processMessages, isn't it more accurate?

let warnings = false;
let errors = false;

Expand Down
2 changes: 2 additions & 0 deletions packages/aws-cdk/lib/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export class CdkToolkit {
defaultBehavior: DefaultSelection.OnlySingle
});

this.appStacks.processMetadata(stacks);

for (const stack of stacks) {
if (stacks.length !== 1) { highlight(stack.name); }
if (!stack.environment) {
Expand Down
4 changes: 3 additions & 1 deletion packages/aws-cdk/test/api/test.stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export = testCase({
const selected = await stacks.selectStacks(['withouterrors'], {
defaultBehavior: DefaultSelection.AllStacks
});
stacks.processMetadata(selected);

// THEN
test.equal(selected[0].template.resource, 'noerrorresource');
Expand All @@ -27,9 +28,10 @@ export = testCase({

// WHEN
try {
await stacks.selectStacks(['witherrors'], {
const selected = await stacks.selectStacks(['witherrors'], {
defaultBehavior: DefaultSelection.AllStacks
});
stacks.processMetadata(selected);

test.ok(false, 'Did not get exception');
} catch (e) {
Expand Down