diff --git a/helm/tools/grafana-mcp/templates/_helpers.tpl b/helm/tools/grafana-mcp/templates/_helpers.tpl index 5a8d2bb30f..bd074a815c 100644 --- a/helm/tools/grafana-mcp/templates/_helpers.tpl +++ b/helm/tools/grafana-mcp/templates/_helpers.tpl @@ -67,3 +67,12 @@ Create the grafana server URL {{- define "grafana-mcp.serverUrl" -}} {{- printf "http://%s.%s:%d/mcp" (include "grafana-mcp.fullname" .) .Release.Namespace (.Values.service.port | int) }} {{- end }} + +{{/* +Join registry/repository for grafana-mcp image, skipping empty segments, then append tag +*/}} +{{- define "grafana-mcp.image" -}} +{{- $img := .Values.image -}} +{{- $parts := compact (list $img.registry $img.repository) -}} +{{- printf "%s:%s" (join "/" $parts) $img.tag -}} +{{- end -}} \ No newline at end of file diff --git a/helm/tools/grafana-mcp/templates/deployment.yaml b/helm/tools/grafana-mcp/templates/deployment.yaml index e2a99b0460..bf3be83f36 100644 --- a/helm/tools/grafana-mcp/templates/deployment.yaml +++ b/helm/tools/grafana-mcp/templates/deployment.yaml @@ -35,7 +35,7 @@ spec: - name: grafana-mcp securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" + image: {{ include "grafana-mcp.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }} args: - --transport diff --git a/helm/tools/grafana-mcp/tests/deployment_test.yaml b/helm/tools/grafana-mcp/tests/deployment_test.yaml index b01bdd4ea2..d1ed1c4add 100644 --- a/helm/tools/grafana-mcp/tests/deployment_test.yaml +++ b/helm/tools/grafana-mcp/tests/deployment_test.yaml @@ -100,3 +100,23 @@ tests: - equal: path: spec.template.spec.containers[0].securityContext.runAsUser value: 1000 + + - it: should render the default container image + template: deployment.yaml + asserts: + - equal: + path: spec.template.spec.containers[0].image + value: mcp/grafana:latest + + - it: should omit empty registry segment in image + template: deployment.yaml + set: + image: + registry: "" + asserts: + - equal: + path: spec.template.spec.containers[0].image + value: grafana:latest + - notMatchRegex: + path: spec.template.spec.containers[0].image + pattern: "^/" # no leading slash \ No newline at end of file