Skip to content

Feature Request: use helm --set-literal in valuesFrom with targetPath #1317

@Preisschild

Description

@Preisschild

Currently, you need to escape some characters manually if you want to use valuesFrom + targetPath to insert a string from a configmap into a helm value that contains characters such as ,. This is documented here: https://fluxcd.io/flux/components/helm/helmreleases/#values-references

This was solved in helm by creating the --set-literal flag: helm/helm#9182

But I don't think you can set this behavior in fluxcd's helm controller.

Would it be a good idea to make use of this behavior by default when using valuesFrom?

Related:
#853
fluxcd/flux2#1756

Example test case (https://github.com/fluxcd/pkg/blob/main/chartutil/values_test.go)

{
	name: "with target path and comma",
	resources: []runtime.Object{
		mockConfigMap("values", map[string]string{"single": "value1,value2"}),
	},
	references: []meta.ValuesReference{
		{
			Kind:       kindConfigMap,
			Name:       "values",
			ValuesKey:  "single",
			TargetPath: "merge.at.specific.path",
		},
	},
	want: chartutil.Values{
		"merge": map[string]interface{}{
			"at": map[string]interface{}{
				"specific": map[string]interface{}{
					"path": "value1,value2",
				},
			},
		},
	},
},

A real world example would be wanting to load a kustomize configMapGenerator-created application.properties into a helm value (such as a configmap in the helm chart). See this example from the Kubernetes docs:

https://kubernetes.io/docs/concepts/configuration/configmap/#configmaps-and-pods

  game.properties: |
    enemy.types=aliens,monsters
    player.maximum-lives=5    

Using strvals.ParseLiteralInto here (https://github.com/fluxcd/pkg/blob/version/v0.10.0/chartutil/values.go#L267) would make it possible to pass the test case if the value were wrapped in extra quotes. But configMapGenerator-created configmaps (with an application.properties as its filesource for example) would not have it wrapped into extra quotes, so this still wouldnt fix this use case.

Using it here (https://github.com/fluxcd/pkg/blob/version/v0.10.0/chartutil/values.go#L270) would make the kustomize cm-generator use case possible, but then test cases such as this one: (https://github.com/fluxcd/pkg/blob/version/v0.10.0/chartutil/values_test.go#L328) fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions