From fe402a1727dfa7000ff0a87eb4426ab93cec596c Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Tue, 24 Sep 2024 08:12:41 +0100 Subject: [PATCH 1/2] fix: add labels to containers --- charts/snyk-broker/templates/_helpers.tpl | 9 +++++- .../templates/broker_deployment.yaml | 2 +- ..._deployment_disablesuffixes_test.yaml.snap | 2 ++ .../broker_cra_deployment_test.yaml.snap | 2 ++ .../broker_deployment_apprisk_test.yaml.snap | 2 ++ ...oker_deployment_artifactory_test.yaml.snap | 2 ++ ...ustomaccept_disablesuffixes_test.yaml.snap | 2 ++ ...ker_deployment_customaccept_test.yaml.snap | 2 ++ ..._deployment_disablesuffixes_test.yaml.snap | 8 ++++++ ...ent_ingress_disablesuffixes_test.yaml.snap | 2 ++ .../broker_deployment_ingress_test.yaml.snap | 2 ++ ...r_deployment_scm_token_pool_test.yaml.snap | 6 ++++ .../broker_deployment_test.yaml.snap | 10 +++++++ ...cra_deployment_digitalocean_test.yaml.snap | 2 ++ ..._deployment_disablesuffixes_test.yaml.snap | 2 ++ .../cra_deployment_harbor_test.yaml.snap | 2 ++ .../cra_deployment_test.yaml.snap | 2 ++ .../tests/broker_deployment_labels_test.yaml | 28 +++++++++++++++++-- 18 files changed, 83 insertions(+), 4 deletions(-) diff --git a/charts/snyk-broker/templates/_helpers.tpl b/charts/snyk-broker/templates/_helpers.tpl index e023ce6..b41bf36 100644 --- a/charts/snyk-broker/templates/_helpers.tpl +++ b/charts/snyk-broker/templates/_helpers.tpl @@ -54,6 +54,13 @@ app.kubernetes.io/name: {{ include "snyk-broker.name" . }}{{if not .Values.disab app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} +{{/* +Pod labels (merge normal labels and selectors) +*/}} +{{- define "snyk-broker.podLabels" -}} +{{- merge (include "snyk-broker.labels" . | fromYaml ) (include "snyk-broker.selectorLabels" . | fromYaml) | toYaml -}} +{{- end }} + {{/* Create the name of the service account to use */}} @@ -113,7 +120,7 @@ Create the name of the broker service to use {{- $serviceLength := len $service -}} {{- $releaseNameLength := len .Release.Name -}} {{- $truncatedLength := int (sub 63 (add $serviceLength $releaseNameLength)) -}} -{{- .Values.scmType | trunc $truncatedLength }}{{ $service }}{{ .Release.Name }} +{{- .Values.scmType | trunc $truncatedLength }}{{ $service }}{{ .Release.Name }} {{- else }} {{- .Values.scmType | trunc 47 }}-broker-service {{- end -}} diff --git a/charts/snyk-broker/templates/broker_deployment.yaml b/charts/snyk-broker/templates/broker_deployment.yaml index 3e4e7ae..2f07a20 100644 --- a/charts/snyk-broker/templates/broker_deployment.yaml +++ b/charts/snyk-broker/templates/broker_deployment.yaml @@ -22,7 +22,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "snyk-broker.selectorLabels" . | nindent 8 }} + {{- include "snyk-broker.podLabels" . | nindent 8 }} spec: {{- if .Values.extraPodSpecs }} {{- toYaml .Values.extraPodSpecs | nindent 6 }} diff --git a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_disablesuffixes_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_disablesuffixes_test.yaml.snap index 30b3ae3..06e1c61 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_disablesuffixes_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_disablesuffixes_test.yaml.snap @@ -20,7 +20,9 @@ with CRA: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_test.yaml.snap index 30b3ae3..06e1c61 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_test.yaml.snap @@ -20,7 +20,9 @@ with CRA: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_apprisk_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_apprisk_test.yaml.snap index 253a846..8b6c95b 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_apprisk_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_apprisk_test.yaml.snap @@ -20,7 +20,9 @@ apprisk enabled: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_artifactory_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_artifactory_test.yaml.snap index 088f2d8..1197ba8 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_artifactory_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_artifactory_test.yaml.snap @@ -20,7 +20,9 @@ should render artifactoryUrl and brokerClientValidationUrl as secrets: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_customaccept_disablesuffixes_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_customaccept_disablesuffixes_test.yaml.snap index 37b18af..3b6e25b 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_customaccept_disablesuffixes_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_customaccept_disablesuffixes_test.yaml.snap @@ -33,7 +33,9 @@ customaccept values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_customaccept_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_customaccept_test.yaml.snap index af515d2..73adeee 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_customaccept_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_customaccept_test.yaml.snap @@ -33,7 +33,9 @@ customaccept values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_disablesuffixes_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_disablesuffixes_test.yaml.snap index d07b1cd..3bc0e09 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_disablesuffixes_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_disablesuffixes_test.yaml.snap @@ -20,7 +20,9 @@ HA mode on: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -167,7 +169,9 @@ HA mode on with 4 replicas: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -314,7 +318,9 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -459,7 +465,9 @@ preflight checks off: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_ingress_disablesuffixes_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_ingress_disablesuffixes_test.yaml.snap index 7ba21ce..0283307 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_ingress_disablesuffixes_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_ingress_disablesuffixes_test.yaml.snap @@ -20,7 +20,9 @@ ingress: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_ingress_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_ingress_test.yaml.snap index a71a172..df7d27f 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_ingress_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_ingress_test.yaml.snap @@ -20,7 +20,9 @@ ingress: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_scm_token_pool_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_scm_token_pool_test.yaml.snap index 23079b5..cbf50db 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_scm_token_pool_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_scm_token_pool_test.yaml.snap @@ -20,7 +20,9 @@ github token pool configured: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -178,7 +180,9 @@ github token pool configured with enabled useExternalSecretScmTokenPool: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -328,7 +332,9 @@ gitlab token pool configured: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/broker_deployment_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_deployment_test.yaml.snap index c36da32..6ed929e 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_deployment_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_deployment_test.yaml.snap @@ -20,7 +20,9 @@ HA mode on: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -167,7 +169,9 @@ HA mode on with 4 replicas: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -314,7 +318,9 @@ HTTPS enabled: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -478,7 +484,9 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: @@ -623,7 +631,9 @@ preflight checks off: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/cra_deployment_digitalocean_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/cra_deployment_digitalocean_test.yaml.snap index 7abee19..36cd62a 100644 --- a/charts/snyk-broker/tests/__snapshot__/cra_deployment_digitalocean_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/cra_deployment_digitalocean_test.yaml.snap @@ -20,7 +20,9 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/cra_deployment_disablesuffixes_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/cra_deployment_disablesuffixes_test.yaml.snap index fc8f6c9..82a54e7 100644 --- a/charts/snyk-broker/tests/__snapshot__/cra_deployment_disablesuffixes_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/cra_deployment_disablesuffixes_test.yaml.snap @@ -20,7 +20,9 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/cra_deployment_harbor_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/cra_deployment_harbor_test.yaml.snap index 6fb3b05..a96b761 100644 --- a/charts/snyk-broker/tests/__snapshot__/cra_deployment_harbor_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/cra_deployment_harbor_test.yaml.snap @@ -20,7 +20,9 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/__snapshot__/cra_deployment_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/cra_deployment_test.yaml.snap index ef50b51..0c8ff2e 100644 --- a/charts/snyk-broker/tests/__snapshot__/cra_deployment_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/cra_deployment_test.yaml.snap @@ -20,7 +20,9 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker-RELEASE-NAME + helm.sh/chart: snyk-broker-0.0.0 spec: containers: - env: diff --git a/charts/snyk-broker/tests/broker_deployment_labels_test.yaml b/charts/snyk-broker/tests/broker_deployment_labels_test.yaml index d81b61a..e0235e9 100644 --- a/charts/snyk-broker/tests/broker_deployment_labels_test.yaml +++ b/charts/snyk-broker/tests/broker_deployment_labels_test.yaml @@ -10,8 +10,6 @@ values: tests: - it: handles duplicative labels and adds new labels - values: - - ./fixtures/default_values.yaml set: labels: app.kubernetes.io/name: "my duplicated label" @@ -25,3 +23,29 @@ tests: app.kubernetes.io/name: snyk-broker-RELEASE-NAME helm.sh/chart: snyk-broker-0.0.0 test: node1 + - it: sets a label + set: + labels: + costCenter: prodsec + asserts: + - equal: + path: metadata.labels.costCenter + value: prodsec + - it: sets a label on the broker pod + set: + labels: + costCenter: prodsec + asserts: + - equal: + path: spec.template.metadata.labels.costCenter + value: prodsec + template: broker_deployment.yaml + - it: does not override a default label on the broker pod + set: + labels: + app.kubernetes.io/name: fake + asserts: + - equal: + path: spec.template.metadata.labels["app.kubernetes.io/name"] + value: snyk-broker-RELEASE-NAME + template: broker_deployment.yaml From 12a9b0258c173b91e2f59bf8e47dfaf53c70d70e Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Fri, 27 Sep 2024 15:16:46 +0100 Subject: [PATCH 2/2] chore: bump version --- charts/snyk-broker/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/snyk-broker/Chart.yaml b/charts/snyk-broker/Chart.yaml index ca721c6..a8cc1c0 100644 --- a/charts/snyk-broker/Chart.yaml +++ b/charts/snyk-broker/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 name: snyk-broker -version: 2.8.2 +version: 2.8.3 description: A Helm chart for Kubernetes type: application