configs/configupgrade: Use break to cancel default function rendering

We're using break elsewhere in here so it was weird to have a small set
of situations that return instead, which could then cause confusion for
future maintenance if a reader doesn't notice that control doesn't always
leave the outer switch statement.
This commit is contained in:
Martin Atkins 2018-11-30 18:38:19 -08:00
parent 48f1245e6b
commit 39c3e7112f
1 changed files with 5 additions and 4 deletions

View File

@ -26,6 +26,7 @@ func upgradeExpr(val interface{}, filename string, interp bool, an *analysis) ([
// of these correspond to expressions in HCL2. Therefore we need to
// comprehensively handle every possible HCL1 *and* HIL AST node type
// and, at minimum, print it out as-is in HCL2 syntax.
Value:
switch tv := val.(type) {
case *hcl1ast.LiteralType:
@ -214,14 +215,14 @@ func upgradeExpr(val interface{}, filename string, interp bool, an *analysis) ([
}
}
buf.WriteByte(']')
return buf.Bytes(), diags
break Value
case "map":
// Should now use object constructor syntax, but we can only
// achieve that if the call is valid, which requires an even
// number of arguments.
if len(argExprs) == 0 {
buf.WriteString("{}")
return buf.Bytes(), diags
break Value
} else if len(argExprs)%2 == 0 {
buf.WriteString("{\n")
for i := 0; i < len(argExprs); i += 2 {
@ -234,7 +235,7 @@ func upgradeExpr(val interface{}, filename string, interp bool, an *analysis) ([
buf.WriteByte('\n')
}
buf.WriteByte('}')
return buf.Bytes(), diags
break Value
}
case "lookup":
// A lookup call with only two arguments is equivalent to native
@ -247,7 +248,7 @@ func upgradeExpr(val interface{}, filename string, interp bool, an *analysis) ([
buf.WriteByte('[')
buf.Write(argExprs[1])
buf.WriteByte(']')
return buf.Bytes(), diags
break Value
}
}