-
Notifications
You must be signed in to change notification settings - Fork 60
refactor(cli): stack/security diff no longer prints directly to a stream #264
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
Conversation
| diffs = numberFromBool(printSecurityDiff(template, stacks.firstStack, RequireApproval.Broadening, quiet)); | ||
| } else { | ||
| const { stackDiffCount, printableStackDiff } = printStackDiff(template, stacks.firstStack, strict, contextLines, quiet, undefined, undefined, false); |
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.
I'd strongly advise you rename these functions since they don't print anything anymore.
mrgrain
left a comment
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 doesn't touch printSecurityDiff yet, right?
| import type { Deployments } from './deployments'; | ||
| import { ToolkitError } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api'; | ||
| import { IO, type IoHelper } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private'; | ||
| import { info } from '../../cli/messages'; |
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.
Nope!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #264 +/- ##
==========================================
+ Coverage 85.18% 85.24% +0.05%
==========================================
Files 221 221
Lines 36512 36606 +94
Branches 4445 4450 +5
==========================================
+ Hits 31104 31205 +101
+ Misses 5307 5306 -1
+ Partials 101 95 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes #302 In #264, we capture the output of the Formatter into a stream, and that is then converted to a string. This diff only gets printed if the diff isn't empty, but by some quirk `formatStackDiff` used to print the stack name _outside_ of the stream, thus creating the (correct) behavior. #264 made sure that `format` doesn't print, so we need to make sure that the consumer of `formatStackDiff` prints the relevant info. This PR makes sure that the stack name is returned as the formatted diff even if the actual diff is empty. We will print the right information when we print the formatted diff now. I also made similar modifications to `formatSecurityDiff`, as we should move away from `format` methods printing anything at all. BEFORE (cdk 2.1006.0): <img width="326" alt="Screenshot 2025-04-02 at 9 04 04 AM" src="https://github.com/user-attachments/assets/03b92517-e475-4c27-a4c1-52217be824c8" /> AFTER (my local cdk): <img width="322" alt="Screenshot 2025-04-02 at 9 03 11 AM" src="https://github.com/user-attachments/assets/53a7d3e0-2e62-45ca-898b-93c923028346" /> --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Signed-off-by: github-actions <github-actions@github.com> Co-authored-by: github-actions <github-actions@github.com>
part of https://github.com/orgs/aws/projects/257
this refactor removes direct prints to
stderrorstdoutfor the diff cli command. the diff result will instead be printed through the globalCliIoHost.the diff format is determined by the
Formatterclass, which takes in astreamthat previously wasstdout(orstderr). now, we are sending our own stream intoFormatter, capturing what was previously immediately printed and instead returning it as a string. we then print the resulting string throughCliIoHost. it should have no functional change to how the diff cli works today.this effort will help support diff in the toolkit lib because it allows the
IoHostgovernance of the diff print.as this is a pure refactor, successful existing tests is enough to ensure that this works.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license