Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't strip strings on output #184

Merged
merged 2 commits into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions parse/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions types/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,19 @@ 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)
}
single := Singular(value)
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) {
Expand Down
5 changes: 5 additions & 0 deletions types/set/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}