diff --git a/helmfile.d/values/grafana/grafana-user.yaml.gotmpl b/helmfile.d/values/grafana/grafana-user.yaml.gotmpl index e0da6dc90..fe9cba588 100644 --- a/helmfile.d/values/grafana/grafana-user.yaml.gotmpl +++ b/helmfile.d/values/grafana/grafana-user.yaml.gotmpl @@ -60,8 +60,8 @@ datasources: If only one workload cluster, don't bother naming the datasource and set to default. Otherwise set the name of the clusters so users know what they are looking at. */}} - {{- if eq (len .Values.global.clustersMonitoring) 1 }} - - name: "Workload Cluster" + {{- with first .Values.global.clustersMonitoring }} + - name: "Workload Cluster {{ . }}" access: proxy basicAuth: false editable: false @@ -71,11 +71,11 @@ datasources: url: http://grafana-label-enforcer:9090 version: 1 jsonData: - customQueryParameters: "tenant_id={{ first .Values.global.clustersMonitoring }}" + customQueryParameters: "tenant_id={{ . }}" manageAlerts: false - {{- else }} - {{- range .Values.global.clustersMonitoring }} - - name: "{{ . }}" + {{- end }} + {{- range rest .Values.global.clustersMonitoring }} + - name: "Workload Cluster {{ . }}" access: proxy basicAuth: false editable: false @@ -89,7 +89,6 @@ datasources: manageAlerts: false {{- end }} {{- end }} - {{- end }} {{ $trailingDot := "" }} {{- if .Values.grafana.user.trailingDots }} diff --git a/tests/Dockerfile b/tests/Dockerfile index f9d1f4855..a8b0e77a7 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,5 +1,5 @@ # Container to run unit tests -FROM ubuntu:rolling AS unit +FROM ubuntu:24.04 AS unit LABEL org.opencontainers.image.source=https://github.com/elastisys/compliantkubernetes-apps ARG DEBIAN_FRONTEND="noninteractive" diff --git a/tests/end-to-end/grafana/datasources.cy.js b/tests/end-to-end/grafana/datasources.cy.js index d8b84d9b9..44635fa6a 100644 --- a/tests/end-to-end/grafana/datasources.cy.js +++ b/tests/end-to-end/grafana/datasources.cy.js @@ -8,7 +8,7 @@ describe("grafana admin datasources", function() { // Cypress does not like trailing dots cy.yqDig("sc", ".grafana.ops.trailingDots") - .should("not.equal", "true") + .should((value) => assert(value !== "true", ".grafana.ops.trailingDots in sc config must not be 'true'")) }) beforeEach(function() { @@ -74,7 +74,7 @@ describe("grafana dev datasources", function() { // Cypress does not like trailing dots cy.yqDig("sc", ".grafana.user.trailingDots") - .should("not.equal", "true") + .should((value) => assert(value !== "true", ".grafana.ops.trailingDots in sc config must not be 'true'")) }) beforeEach(function() { @@ -109,10 +109,19 @@ describe("grafana dev datasources", function() { }) it("has workload cluster", function() { - cy.contains("Workload Cluster") - .should("exist") - .siblings() - .contains("default") - .should("exist") + cy.yqDigParse("sc", ".global.clustersMonitoring") + .then(([first_cluster, ...rest_clusters]) => { + cy.contains(`Workload Cluster ${first_cluster}`) + .should("exist") + .parent() + .siblings() + .contains("default") + .should("exist") + + for (const cluster of rest_clusters) { + cy.contains(`Workload Cluster ${cluster}`) + .should("exist") + } + }) }) })