mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 16:42:51 +00:00
Move trim quotes logic to separate function
This commit is contained in:
@@ -152,11 +152,7 @@ func (o *addMetadataOptions) convertToMap(arg string) (map[string]string, error)
|
||||
}
|
||||
|
||||
// remove quotes if value is quoted
|
||||
if len(result[kv[0]]) > 0 &&
|
||||
result[kv[0]][:1] == "\"" &&
|
||||
result[kv[0]][len(result[kv[0]])-1:] == "\"" {
|
||||
result[kv[0]] = result[kv[0]][1 : len(result[kv[0]])-1]
|
||||
}
|
||||
result[kv[0]] = trimQuotes(result[kv[0]])
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -188,3 +184,12 @@ func (o *addMetadataOptions) writeToMap(m map[string]string, kind kindOfAdd) err
|
||||
func (o *addMetadataOptions) makeError(input string, message string) error {
|
||||
return fmt.Errorf("invalid %s: %s (%s)", o.kind, input, message)
|
||||
}
|
||||
|
||||
func trimQuotes(s string) string {
|
||||
if len(s) >= 2 {
|
||||
if s[0] == '"' && s[len(s)-1] == '"' {
|
||||
return s[1 : len(s)-1]
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user