Skip to content

Commit f30fe1e

Browse files
committed
[coconut] Correctly parse string values in JSON-formatted --extra-vars
1 parent 2389560 commit f30fe1e

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

coconut/control/control.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ func CreateEnvironment(cxt context.Context, rpc *coconut.RpcClient, cmd *cobra.C
216216
return
217217
}
218218
for k, v := range extraVarsMapI {
219+
if strVal, ok := v.(string); ok {
220+
extraVarsMap[k] = strVal
221+
continue
222+
}
219223
marshaledValue, marshalErr := json.Marshal(v)
220224
if marshalErr != nil {
221225
continue
@@ -263,6 +267,21 @@ func CreateEnvironment(cxt context.Context, rpc *coconut.RpcClient, cmd *cobra.C
263267
_, _ = fmt.Fprintf(o, "state: %s\n", colorState(env.GetState()))
264268
_, _ = fmt.Fprintf(o, "root role: %s\n", env.GetRootRole())
265269

270+
var (
271+
defaultsStr = stringMapToString(env.Defaults, "\t")
272+
varsStr = stringMapToString(env.Vars, "\t")
273+
userVarsStr = stringMapToString(env.UserVars, "\t")
274+
)
275+
if len(defaultsStr) != 0 {
276+
_, _ = fmt.Fprintf(o, "global defaults:\n%s\n", defaultsStr)
277+
}
278+
if len(varsStr) != 0 {
279+
_, _ = fmt.Fprintf(o, "global variables:\n%s\n", varsStr)
280+
}
281+
if len(userVarsStr) != 0 {
282+
_, _ = fmt.Fprintf(o, "user-provided variables:\n%s\n", userVarsStr)
283+
}
284+
266285
return
267286
}
268287

0 commit comments

Comments
 (0)