Skip to content

Commit ca590ec

Browse files
committed
Treat quoted values as string when targetPath is set
1 parent 9618562 commit ca590ec

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

controllers/helmrelease_controller.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,19 @@ func (r *HelmReleaseReconciler) composeValues(ctx context.Context, hr v2.HelmRel
611611
// TODO(hidde): this is a bit of hack, as it mimics the way the option string is passed
612612
// to Helm from a CLI perspective. Given the parser is however not publicly accessible
613613
// while it contains all logic around parsing the target path, it is a fair trade-off.
614-
singleValue := v.TargetPath + "=" + string(valuesData)
615-
if err := strvals.ParseInto(singleValue, result); err != nil {
614+
stringValuesData := string(valuesData)
615+
const singleQuote = "'"
616+
const doubleQuote = "\""
617+
var err error
618+
if (strings.HasPrefix(stringValuesData, singleQuote) && strings.HasSuffix(stringValuesData, singleQuote)) || (strings.HasPrefix(stringValuesData, doubleQuote) && strings.HasSuffix(stringValuesData, doubleQuote)) {
619+
stringValuesData = strings.Trim(stringValuesData, singleQuote+doubleQuote)
620+
singleValue := v.TargetPath + "=" + stringValuesData
621+
err = strvals.ParseIntoString(singleValue, result)
622+
} else {
623+
singleValue := v.TargetPath + "=" + stringValuesData
624+
err = strvals.ParseInto(singleValue, result)
625+
}
626+
if err != nil {
616627
return nil, fmt.Errorf("unable to merge value from key '%s' in %s '%s' into target path '%s': %w", v.GetValuesKey(), v.Kind, namespacedName, v.TargetPath, err)
617628
}
618629
}

0 commit comments

Comments
 (0)