fluxcd-community / helm-charts

Community maintained Helm charts for Flux
Apache License 2.0
124 stars 76 forks source link

flux-sync .gitRepository.spec.ignore multiline support #133

Closed odise closed 2 years ago

odise commented 2 years ago

Describe the bug a clear and concise description of what the bug is.

I'm struggling setting a multiline git ignore configuration like:

gitRepository:
  spec:
    url: repository_url
    ref: {"branch": "branch"}
    ignore: |
      # exclude all
      /*
      # include deploy dir
      !/cluster-name/fluxcd-applications

This results in:

Error: YAML parse error on flux2-sync/templates/flux-gitrepository.yaml: error converting YAML to JSON: yaml: line 20: could not find expected ':'

What's your helm version?

3.9.4

What's your kubectl version?

v1.24.3

What's the chart version?

1.0.0

What happened?

No response

What you expected to happen?

No response

How to reproduce it?

No response

Enter the changed values of values.yaml?

gitRepository: spec: ignore: |

exclude all

  /*
  # include deploy dir
  !/cluster-name/fluxcd-applications

Enter the command that you execute and failing/misfunctioning.

helm upgrade -n flux-system -f x fluxcd-apps fluxcd-community/flux2-sync

Anything else we need to know?

No response

odise commented 2 years ago

I guess something like:

ignore: {{ .Values.gitRepository.spec.ignore | toYaml }}

in https://github.com/fluxcd-community/helm-charts/blob/main/charts/flux2-sync/templates/flux-gitrepository.yaml#L32 should fix the problem.

stefanprodan commented 2 years ago

this has nothing to do with ignore, multi-line works file, the ref is wrong.

odise commented 2 years ago

Even when I set it to:

gitRepository:
  spec:
    url: repository_url
    ref: 
      branch:  branch

the error stays the same.

stefanprodan commented 2 years ago

You're right, the bug is here https://github.com/fluxcd-community/helm-charts/blob/main/charts/flux2-sync/templates/flux-gitrepository.yaml#L44

It should be:

  {{- with .Values.gitRepository.spec.include }}
  include: |
    {{ . }}
  {{- end }}
odise commented 2 years ago

@stefanprodan you referring to include (which is a list of maps). I refer to ignore which should support multiline strings.

stefanprodan commented 2 years ago

Yes, sorry I meant:

  {{- with .Values.gitRepository.spec.ignore }}
  ignore: |
    {{ . }}
  {{- end }}
odise commented 2 years ago

Np, any chance to fix it and release in a short term notice?

stefanprodan commented 2 years ago

PR welcome!

odise commented 2 years ago

@stefanprodan here you go.