Skip to content

Commit

Permalink
fix(deploy): move '$leading_path' variable definition in eck-operator…
Browse files Browse the repository at this point in the history
… helm chart (#8075)

This fixes an error that is thrown by Helm when templating the `eck-operator` chart. In this case, consider the following variables file:

```bash
config:
  metrics:
    port: "6000"
    secureMode:
      enabled: true
      tls:
        certificateSecret: "my-metrics-cert-secret"
        caSecret: "my-metrics-cert-secret"
        insecureSkipVerify: false
```

Running `helm template` with the above values generates the following error:

```bash
Error: template: eck-operator/templates/serviceMonitor.yaml:25:49: executing "eck-operator/templates/serviceMonitor.yaml" at <.Values.config.metrics.secureMode.tls.caMountDirectory>: can't evaluate field Values in type string

Use --debug flag to render out invalid YAML
```

This error occurs because when modifying the scope using `with`, the reference for `.Values`, for example, is lost ([helm docs](https://helm.sh/docs/chart_template_guide/control_structures/#modifying-scope-using-with)).
  • Loading branch information
devzizu authored Oct 2, 2024
1 parent 0b45a54 commit 306d680
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deploy/eck-operator/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ spec:
tlsConfig:
insecureSkipVerify: {{ .Values.config.metrics.secureMode.tls.insecureSkipVerify | default false }}
{{- if (not .Values.config.metrics.secureMode.tls.insecureSkipVerify) }}
{{- with .Values.config.metrics.secureMode.tls.caSecret }}
{{- $leading_path := trimSuffix "/" .Values.config.metrics.secureMode.tls.caMountDirectory }}
{{- with .Values.config.metrics.secureMode.tls.caSecret }}
caFile: "{{ $leading_path }}/{{ . }}/ca.crt"
{{- end }}
serverName: "{{ include "eck-operator.fullname" . }}-metrics.{{ .Release.Namespace }}.svc"
Expand Down

0 comments on commit 306d680

Please sign in to comment.