-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(cdk): cdk diff --quiet
to print stack name when there is diffs
#28576
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
@@ -187,15 +187,37 @@ describe('non-nested stacks', () => { | |||
|
|||
// WHEN | |||
const exitCode = await toolkit.diff({ | |||
stackNames: ['A', 'A'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was broken, so fixed this.
This test assumed that the diff does not exist, but the stackNames: ['A', 'A']
specification indicates that the diff does exist and the not.toContain
assertion succeeded because of the presence or absence of ANSI escape sequences.
Therefore, I changed it to specify stackNames: ['D'],
where no diff exists, and removed the ANSI escape sequence in the string used for the assertion.
stackName: 'D', |
if (stackArtifact.stackName === 'D') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch here!
@@ -23,9 +23,10 @@ export function printStackDiff( | |||
context: number, | |||
quiet: boolean, | |||
changeSet?: CloudFormation.DescribeChangeSetOutput, | |||
stream?: cfnDiff.FormatStream): number { | |||
stream?: cfnDiff.FormatStream, | |||
stackDiff?: cfnDiff.TemplateDiff): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cfnDiff.fullDiff
function must be called in the CdkToolkit.diff
method, since we need to get the presence or absence of diffs when determining whether to print the stack name.
I changed it so that the diff can be passed in optionally so that the relatively heavy processing of cfnDiff.fullDiff
does not need to be executed multiple times.
cdk diff --quiet
to print stack name when there is no diffcdk diff --quiet
to print stack name when there is no diff
cdk diff --quiet
to print stack name when there is no diffcdk diff --quiet
to print stack name when there is diffs
Exemption Request: I think the unit tests cover the test for this change. |
Exemption Request: This pull request will not cause any change in the produced code, so it should be exempt from having to contain a change to the integration test file and the resulting snapshot. Also. as it's a CLI code change, I request someone to review it please. It's a very minor change, so it will hopefully be quick to review. |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
…fix-diff-quiet-stack-name
…i-ryo/aws-cdk into fix-diff-quiet-stack-name
Can someone please approve the test-pipeline? Thanks! |
…fix-diff-quiet-stack-name
Looks like this branch needs re-basing again and then needs an approval for that test pipeline. |
Is there any way to push this forward? |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
➡️ PR build request submitted to A maintainer must now check the pipeline and add the |
Hi @sakurai-ryo, @nomike. I'm very sorry for not getting around to this. It looks like I added the In the meantime there are a couple of merge conflicts to be addressed, I'd like to run the cli integ tests again after those have been resolved to be safe. I will keep a close eye on this PR until then. Thank you both for you patience. |
? (numberFromBool(printSecurityDiff(currentTemplate, stack, RequireApproval.Broadening, changeSet)) > 0 ? 1 : 0) | ||
: (printStackDiff(currentTemplate, stack, strict, contextLines, quiet, changeSet, stream) > 0 ? 1 : 0); | ||
? (numberFromBool(printSecurityDiff(currentTemplate, stack, RequireApproval.Broadening, changeSet, diff)) > 0 ? 1 : 0) | ||
: (printStackDiff(currentTemplate, stack, strict, contextLines, quiet, changeSet, stream, diff) > 0 ? 1 : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not pass the diff
in the same function that takes the inputs to create the diff (the old template and new template). Instead let's move the
stream.write(format('Stack %s\n', chalk.bold(stack.displayName)));
to printStackDiff
(you can access the stackName
from the stack
object passed as the second argument to printStackDiff
).
@@ -187,15 +187,37 @@ describe('non-nested stacks', () => { | |||
|
|||
// WHEN | |||
const exitCode = await toolkit.diff({ | |||
stackNames: ['A', 'A'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
1 similar comment
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
The pull request linter fails with the following errors:
PRs must pass status checks before we can provide a meaningful review. If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing ✅ A exemption request has been requested. Please wait for a maintainer's review. |
This PR has been in the MERGE CONFLICTS state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error. |
The pull request linter fails with the following errors:
PRs must pass status checks before we can provide a meaningful review. If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing ✅ A exemption request has been requested. Please wait for a maintainer's review. |
This is still broken and should be fixed. The --quiet flag is broken without it. |
The
--quiet
flag on thecdk diff
command will prevent the stack name and default message from being printed when there is no diff.If diffs exist, the stack name and diffs are expected to be printed, but currently the stack name is not displayed and it is difficult to determine which stack the diff is for.
This PR fixed to print the stack name when the
--quiet
flag is specified and diffs exist.Closes #27128
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license