Skip to content

Commit ce013b7

Browse files
author
Moritz Clasmeier
committed
wip
1 parent 999f626 commit ce013b7

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

cmd/deploy.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"os"
8+
"reflect"
89
"strings"
910
"time"
1011

@@ -216,6 +217,13 @@ Examples:
216217
if err := yaml.Unmarshal([]byte(yamlValue), &val); err != nil {
217218
return fmt.Errorf("failed to unmarshal value '%s' for key '%s': %w", yamlValue, key, err)
218219
}
220+
// SetNestedField requires JSON-compatible types: float64 for numbers, not int.
221+
switch v := val.(type) {
222+
case int:
223+
val = float64(v)
224+
case int64:
225+
val = float64(v)
226+
}
219227
pathElements := strings.Split(key, ".")
220228
u, err := helpers.StructToMap(settings)
221229
if err != nil {
@@ -224,7 +232,17 @@ Examples:
224232
if err := unstructured.SetNestedField(u, val, pathElements...); err != nil {
225233
return err
226234
}
227-
return helpers.MapToStruct(u, settings)
235+
var updatedSettings deployer.Config
236+
if err := helpers.MapToStruct(u, &updatedSettings); err != nil {
237+
return err
238+
}
239+
if reflect.DeepEqual(settings, &updatedSettings) {
240+
return fmt.Errorf("Set expression %q had no effect -- typo?", expr)
241+
}
242+
*settings = updatedSettings
243+
244+
return nil
245+
228246
},
229247
), "set", "Set expressions, e.g. securedCluster.spec.clusterName=sensor")
230248

internal/deployer/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,6 @@ func DefaultSecuredClusterConfig() SecuredClusterConfig {
215215
return SecuredClusterConfig{
216216
DeployTimeout: DefaultSecuredClusterWaitTimeout,
217217
Namespace: "acs-sensor",
218+
Spec: make(map[string]interface{}),
218219
}
219220
}

0 commit comments

Comments
 (0)