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