-
-
Notifications
You must be signed in to change notification settings - Fork 46
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: parse error when only outputs is changed #896
fix: parse error when only outputs is changed #896
Conversation
pkg/terraform/parser.go
Outdated
if startChangeOutput != -1 && endChangeOutput == -1 && strings.HasPrefix(line, "Plan: ") { // https://github.com/hashicorp/terraform/blob/dfc12a6a9e1cff323829026d51873c1b80200757/internal/command/views/plan.go#L306 | ||
endChangeOutput = i + 1 | ||
if startChangeOutput != -1 && endChangeOutput == -1 && strings.HasPrefix(line, "-----") { // https://github.com/hashicorp/terraform/blob/1ac7a37d00f3c796f816070847bf02109cb9cab2/internal/command/views/operation.go#L142 |
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.
To include changes to outputs coming after Plan:
, we have to wait for a horizontal rule which comes after Changes to Outputs:
.
// if we get here before finding a horizontal rule, output all remaining. | ||
if endChangeOutput == -1 { | ||
endChangeOutput = len(lines) - 1 | ||
} |
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.
If TF_IN_AUTOMATION
environment variable is set, no horizontal rules appear after Terraform will perform the following actions:
. 😢
name: "plan output changes only pattern 0.12", | ||
body: planOnlyOutputChangesSuccessResult0_12, | ||
result: ParseResult{ | ||
Result: "Plan: 0 to add, 0 to change, 0 to destroy.", |
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 is not ideal, but it's very old version... 🙈
Thank you for your contribution! |
Thanks for testing. 😃 |
OK, I tested. failed, resource changing, outputs changingBoth v4.5.0 and this PR version have the same result. failed, resource changing, outputs no changesSame as failed, resource no changes, outputs changingv4.5.0this PR versionno error, resource changing, outputs changingv4.5.0this PR versionno error, resource changing, outputs no changesBoth v4.5.0 and this PR version have the same result. no error, resource no changes, outputs changingv4.5.0this PR version |
Fixed the problem I noticed in images in the comment above. 🎉 Problem: beforeafterProblem: I copied the test cases from mercari/tfnotify#109, but it may be that Terraform's output specification changed at some point. beforeafter |
That's what I thought too, but pretended not to see. 🙈 Since it is plan, how about changing it to |
Oh, I see. Indeed, Terraform uses e.g.
Could you change to
|
Other than that it looks good. |
fixed: 6fa879f I'm not too sure about this fix. 😅 |
Thank you for your great work! |
The prerelease version v4.5.1-1 is out. We'll verify this, and if there is no problem, we'll release v4.5.1. |
v4.5.1 is out 🎉 Thank you for your contribution! |
Close #117
Related PR: mercari/tfnotify#109