Skip to content

Conversation

@shhgs
Copy link

@shhgs shhgs commented Sep 12, 2025

What this PR does / why we need it

This PR fix the issue that helm would crash when you define some labels for the Service.

Which issue this PR fixes

  1. Add some labels to the Service
diff --git a/values.yaml b/values.yaml                                                                                                                                                                             
index 66ceac8..11047b8 100644
--- a/values.yaml
+++ b/values.yaml
@@ -12,7 +12,9 @@ service:
   type: ClusterIP
   externalPort: 9419
   internalPort: 9419
-  labels: {}
+  labels: 
+    foo: bar
+    blah: darh
                                                                                                                                                                                                                 
 resources: {}                                                                                                                                                                                                     
   # We usually recommend not to specify default resources and to leave this as a conscious
  1. Then run
$ helm template rabbitmq-exporter . --debug  --version 2.1.1 -f ./values.yaml 
  ...
Error: YAML parse error on prometheus-rabbitmq-exporter/templates/service.yaml: error converting YAML to JSON: yaml: line 10: mapping values are not allowed in this context
helm.go:84: [debug] error converting YAML to JSON: yaml: line 10: mapping values are not allowed in this context
YAML parse error on prometheus-rabbitmq-exporter/templates/service.yaml
  • fixes #
# git diff 
diff --git a/templates/service.yaml b/templates/service.yaml                                                                                                                                                       
index 394c9cb..447ccf5 100644
--- a/templates/service.yaml
+++ b/templates/service.yaml
@@ -7,9 +7,9 @@ metadata:
     chart: {{ template "prometheus-rabbitmq-exporter.chart" . }}
     release: {{ .Release.Name }}
     heritage: {{ .Release.Service }}
-  {{- with .Values.service.labels }}
-    {{ toYaml . | indent 4 }}
-  {{- end }}
+    {{- with .Values.service.labels -}}
+      {{ toYaml . | nindent 4 }}
+    {{- end }}
 spec:

Special notes for your reviewer

Checklist

  • DCO signed
  • Chart Version bumped
  • Title of the PR starts with chart name (e.g. [prometheus-couchdb-exporter])

@shhgs shhgs force-pushed the prometheus-rabbitmq-exporter_fix-svc-labels branch from be3e20f to 13268ec Compare September 12, 2025 13:05
@shhgs shhgs force-pushed the prometheus-rabbitmq-exporter_fix-svc-labels branch from 13268ec to a7430c3 Compare September 12, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant