flux2 icon indicating copy to clipboard operation
flux2 copied to clipboard

HelmRelease valuesFrom kind secret with comma separated values (cannot end with ,)

Open tomasfabian opened this issue 2 years ago • 4 comments

Describe the bug

Hi, in case that the secret value contains a comma character we receive the following error message:

 helm-controller  unable to merge value from key 'brokers' in Secret 'default/kafka' into target path 'kafka.Brokers': key "net:9092" has no value (cannot end with ,)    

Steps to reproduce

Secret with a comma separated list of brokers:

Name:         kafka
Namespace:    default
Labels:       managed-by=kafkaConnection-operator
Annotations:  <none> 
Type:  Opaque
Data
====
brokers:  107 bytes

brokers value:

kafka01.net:9092,kafka02.net:9092,kafka03.net:9092

Example HelmRelease yaml:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: my-app
  namespace: default
spec:
  interval: 1m
  chart:
    spec:
      chart: my-chart
      version: "0.1.0-alpha"
      sourceRef:
        kind: HelmRepository
        name: harbor-chart-repo
        namespace: default
  valuesFrom:
    - kind: Secret
      targetPath: kafka.brokers
      name: kafka
      valuesKey: brokers
      optional: false

Expected behavior

The secret value shouldn't be "parsed" with an error outcome.

Screenshots and recordings

No response

OS / Distro

N/A

Flux version

v0.17.1

Flux check

N/A

Git provider

No response

Container Registry provider

No response

Additional context

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

tomasfabian avatar Apr 07 '22 13:04 tomasfabian

You need to escape the comma, as otherwise the parsing logic (which equals --set as helm itself has when targetPath is used) will trip over the value. See also: https://helm.sh/docs/intro/using_helm/#the-format-and-limitations-of---set

The correct value would be: kafka01.net:9092\,kafka02.net:9092\,kafka03.net:9092

hiddeco avatar Apr 07 '22 13:04 hiddeco

Hi thanks for you reply @hiddeco.

The creation of the secret is not under our control. We are using the following kafka-topic-operator.

Thx

tomasfabian avatar Apr 07 '22 13:04 tomasfabian

You need to escape the comma, as otherwise the parsing logic (which equals --set as helm itself has when targetPath is used) will trip over the value. See also: https://helm.sh/docs/intro/using_helm/#the-format-and-limitations-of---set

The correct value would be: kafka01.net:9092\,kafka02.net:9092\,kafka03.net:9092

may be it can be solved when flux2 using --set-file instead of --set.

I occured the issue also, but my content is a json.

wuhuizuo avatar Jul 02 '22 09:07 wuhuizuo

I was also hoping that valuesFrom could allow using a ConfigMap whose content is a regular values.yaml with comments etc.

nourspace avatar Sep 20 '22 23:09 nourspace