Skip to content
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

configs/configupgrade: fix panic on nil hilNode #22181

Merged
merged 1 commit into from
Jul 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions configs/configupgrade/upgrade_expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,21 @@ Value:
Subject: hcl1PosRange(filename, tv.Pos).Ptr(),
})
}
if _, ok := hilNode.(*hilast.Output); !ok {
// hil.Parse usually produces an output, but it can sometimes
// produce an isolated expression if the input is entirely
// a single interpolation.
hilNode = &hilast.Output{
Exprs: []hilast.Node{hilNode},
Posx: hilNode.Pos(),
if hilNode != nil {
if _, ok := hilNode.(*hilast.Output); !ok {
// hil.Parse usually produces an output, but it can sometimes
// produce an isolated expression if the input is entirely
// a single interpolation.
if hilNode != nil {
hilNode = &hilast.Output{
Exprs: []hilast.Node{hilNode},
Posx: hilNode.Pos(),
}
}
}
interpDiags := upgradeHeredocBody(&buf, hilNode.(*hilast.Output), filename, an)
diags = diags.Append(interpDiags)
}
interpDiags := upgradeHeredocBody(&buf, hilNode.(*hilast.Output), filename, an)
diags = diags.Append(interpDiags)
}
if !strings.HasSuffix(body, "\n") {
// The versions of HCL1 vendored into Terraform <=0.11
Expand Down