-
-
Notifications
You must be signed in to change notification settings - Fork 995
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 error output in plan-all.. #789
Changes from all commits
9f64720
45d0c5c
ed05a3e
35fba5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,12 @@ func RunShellCommandWithOutput(terragruntOptions *options.TerragruntOptions, wor | |
// command requested by the user. The output of these other commands should not end up on stdout as this | ||
// breaks scripts relying on terraform's output. | ||
if !reflect.DeepEqual(terragruntOptions.TerraformCliArgs, args) { | ||
outWriter = terragruntOptions.ErrWriter | ||
errWriter = os.Stderr | ||
outWriter = os.Stdout | ||
} | ||
|
||
if terragruntOptions.ErrWriter != os.Stderr { | ||
errWriter = io.MultiWriter(terragruntOptions.ErrWriter, os.Stderr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain the thinking behind these changes a bit more? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is basically taking care of giving a summary of all errors at the end of a plan-all run and printing the errors while running... the check is needed to not print logs twice while running if used in a normal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed.. ;) i can try to fix it in another way.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as far as i have seen ErrWriter is not used in a consequent manner and fixing it in a nicer way would require a lot of refactoring as there are already a lot of exceptions throughout the code.. |
||
} | ||
|
||
if workingDir == "" { | ||
|
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.
Does
Clone
not do this automatically?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 clone function sets up a new logger logging to the current ErrWriter.. which is not where the current logger is logging to..
I know this might not be the cleanest solution to just set it this way, but since it fixed it for me, i went for it.
maybe an actual go developer can come up with a cleaner implementation ;)
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.
btw it seems that ErrWriter and Logger are not really connected in a logical consequent way. since setting ErrWriter does not change the Logger in any way and also not sets up a new Logger.
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.
Hm, it seems like the right fix would be to make the
Clone
method do the right thing. This small workaround means (a) thatClone
may still be doing the wrong thing in other places and (b) if we make updates toClone
in the future, that may break in this one-off fix here.