diff --git a/parse/builder/builder.go b/parse/builder/builder.go index d0a73b675..ec4e25904 100644 --- a/parse/builder/builder.go +++ b/parse/builder/builder.go @@ -330,6 +330,9 @@ func ConvertSimple(fieldType string, value interface{}, op Operation) (interface case "password": return convert.ToString(value), nil case "string": + if op.IsList() { + return convert.ToStringNoTrim(value), nil + } return convert.ToString(value), nil case "dnsLabel": str := convert.ToString(value) diff --git a/types/convert/convert.go b/types/convert/convert.go index 6f5e61ae0..9529ae4c5 100644 --- a/types/convert/convert.go +++ b/types/convert/convert.go @@ -44,7 +44,7 @@ func Singular(value interface{}) interface{} { return value } -func ToString(value interface{}) string { +func ToStringNoTrim(value interface{}) string { if t, ok := value.(time.Time); ok { return t.Format(time.RFC3339) } @@ -52,7 +52,11 @@ func ToString(value interface{}) string { if single == nil { return "" } - return strings.TrimSpace(fmt.Sprint(single)) + return fmt.Sprint(single) +} + +func ToString(value interface{}) string { + return strings.TrimSpace(ToStringNoTrim(value)) } func ToTimestamp(value interface{}) (int64, error) { diff --git a/types/set/reconcile.go b/types/set/reconcile.go index 9912ae326..fbdfce4fc 100644 --- a/types/set/reconcile.go +++ b/types/set/reconcile.go @@ -15,3 +15,8 @@ func Diff(desired, actual map[string]bool) (toCreate []string, toDelete []string } return } + +func Changed(desired, actual map[string]bool) bool { + toCreate, toDelete, _ := Diff(desired, actual) + return len(toCreate) != 0 || len(toDelete) != 0 +}