numeric variables aren't always interpreted as str
If we have a number value in our config variables, format it as a string, and send it with the HCL=true flag just in case. Also use %g for for float encoding, as the output is a generally a little friendlier.
This commit is contained in:
parent
98d8440711
commit
bf83b435e1
|
@ -107,7 +107,7 @@ func (e *encodeState) encodeInt(i interface{}) error {
|
|||
}
|
||||
|
||||
func (e *encodeState) encodeFloat(f interface{}) error {
|
||||
_, err := fmt.Fprintf(e, "%f", f)
|
||||
_, err := fmt.Fprintf(e, "%g", f)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -327,25 +327,15 @@ RANGE:
|
|||
case string:
|
||||
tfv.Value = v
|
||||
|
||||
case []interface{}:
|
||||
hcl, err = encodeHCL(v)
|
||||
if err != nil {
|
||||
break RANGE
|
||||
}
|
||||
|
||||
tfv.Value = string(hcl)
|
||||
tfv.IsHCL = true
|
||||
|
||||
case map[string]interface{}:
|
||||
hcl, err = encodeHCL(v)
|
||||
if err != nil {
|
||||
break RANGE
|
||||
}
|
||||
|
||||
tfv.Value = string(hcl)
|
||||
tfv.IsHCL = true
|
||||
default:
|
||||
err = fmt.Errorf("unknown type %T for variable %s", v, k)
|
||||
// everything that's not a string is now HCL encoded
|
||||
hcl, err = encodeHCL(v)
|
||||
if err != nil {
|
||||
break RANGE
|
||||
}
|
||||
|
||||
tfv.Value = string(hcl)
|
||||
tfv.IsHCL = true
|
||||
}
|
||||
|
||||
tfVars = append(tfVars, tfv)
|
||||
|
|
Loading…
Reference in New Issue