-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add ShowPlanFileRaw #83
Conversation
The SDK used a non-JSON version of ShowPlanFile to return the human-friendly, opaque-to-machines plan output during testing. With the switch to tfexec, this is no longer possible, as all `terraform show` commands have the `-json` flag applied, meaning all output will be JSON output. This adds a new function, `ShowRawPlanFile`, which returns a string of the output of `terraform show` _without_ the `-json` flag, showing the raw contents of the plan file. A new function was chosen to avoid overloading the existing ShowPlanFile, and because the existing ShowPlanFile returns a `tfjson.Plan` type, which we can't shoehorn a non-JSON return type into easily. Rather than complicate the return type, it felt like a new function was a better solution.
@paultyng suggested `ShowPlanFileRaw`, so we'll run with that, instead, because I'm ambivalent.
Updated to |
showCmd := tf.showCmd(ctx, false, mergeEnv, planPath) | ||
|
||
var ret bytes.Buffer | ||
showCmd.Stdout = &ret |
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 needs to use mergewriters just in case
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.
mergeWriters
is already called by tf.runTerraformCmd
, though? In fact, that's the only command that calls it.
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.
LGTM. Note name of function ShowPlanFileRaw
(looks like it was changed at some point) if you rebase and merge, as it uses the PR title.
The SDK used a non-JSON version of ShowPlanFile to return the
human-friendly, opaque-to-machines plan output during testing. With the
switch to tfexec, this is no longer possible, as all
terraform show
commands have the
-json
flag applied, meaning all output will be JSONoutput.
This adds a new function,
ShowRawPlanFile
, which returns a string ofthe output of
terraform show
without the-json
flag, showing theraw contents of the plan file. A new function was chosen to avoid
overloading the existing ShowPlanFile, and because the existing
ShowPlanFile returns a
tfjson.Plan
type, which we can't shoehorn anon-JSON return type into easily. Rather than complicate the return
type, it felt like a new function was a better solution.