diff --git a/charts/snyk-broker/Chart.yaml b/charts/snyk-broker/Chart.yaml index 63a3d0a..4a38962 100644 --- a/charts/snyk-broker/Chart.yaml +++ b/charts/snyk-broker/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 name: snyk-broker -version: 2.6.8 +version: 2.6.9 description: A Helm chart for Kubernetes type: application diff --git a/charts/snyk-broker/templates/_helpers.tpl b/charts/snyk-broker/templates/_helpers.tpl index 37dd28a..c9f7e39 100644 --- a/charts/snyk-broker/templates/_helpers.tpl +++ b/charts/snyk-broker/templates/_helpers.tpl @@ -34,12 +34,16 @@ Create chart name and version as used by the chart label. Common labels */}} {{- define "snyk-broker.labels" -}} -helm.sh/chart: {{ include "snyk-broker.chart" . }} -{{ include "snyk-broker.selectorLabels" . }} +{{- $commonLabels := dict "helm.sh/chart" (include "snyk-broker.chart" .) }} +{{- $commonLabels = merge $commonLabels (include "snyk-broker.selectorLabels" . | fromYaml) }} {{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- $commonLabels = merge $commonLabels (dict "app.kubernetes.io/version" (quote .Chart.AppVersion)) }} {{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- $commonLabels = merge $commonLabels (dict "app.kubernetes.io/managed-by" .Release.Service) }} +{{- with .Values.labels }} +{{- $commonLabels = merge $commonLabels . }} +{{- end }} +{{- toYaml $commonLabels | nindent 4 }} {{- end }} {{/* diff --git a/charts/snyk-broker/templates/broker_deployment.yaml b/charts/snyk-broker/templates/broker_deployment.yaml index cabbf48..b58d3f2 100644 --- a/charts/snyk-broker/templates/broker_deployment.yaml +++ b/charts/snyk-broker/templates/broker_deployment.yaml @@ -4,7 +4,7 @@ metadata: name: "{{ .Values.scmType}}-broker{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}" namespace: {{ .Release.Namespace }} labels: - {{- include "snyk-broker.labels" . | nindent 4 }} + {{- include "snyk-broker.labels" . }} spec: {{- if and (not .Values.autoscaling.enabled) (.Values.highAvailabilityMode.enabled) }} replicas: {{ .Values.replicaCount }} diff --git a/charts/snyk-broker/templates/broker_service.yaml b/charts/snyk-broker/templates/broker_service.yaml index d5bc1c1..0e46d2b 100644 --- a/charts/snyk-broker/templates/broker_service.yaml +++ b/charts/snyk-broker/templates/broker_service.yaml @@ -4,7 +4,7 @@ metadata: name: {{ include "snyk-broker.brokerServiceName" . | nindent 4 }} namespace: {{ .Release.Namespace }} labels: - {{- include "snyk-broker.labels" . | nindent 4 }} + {{- include "snyk-broker.labels" . }} spec: type: {{ .Values.service.brokerType }} ports: diff --git a/charts/snyk-broker/templates/serviceaccount.yaml b/charts/snyk-broker/templates/serviceaccount.yaml index c7a6216..f4ecd91 100644 --- a/charts/snyk-broker/templates/serviceaccount.yaml +++ b/charts/snyk-broker/templates/serviceaccount.yaml @@ -5,7 +5,7 @@ metadata: name: {{ include "snyk-broker.serviceAccountName" . }}{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }} namespace: {{ .Release.Namespace }} labels: - {{- include "snyk-broker.labels" . | nindent 4 }} + {{- include "snyk-broker.labels" . }} {{- with .Values.serviceAccount.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/snyk-broker/tests/broker_deployment_labels_test.yaml b/charts/snyk-broker/tests/broker_deployment_labels_test.yaml new file mode 100644 index 0000000..f4b9177 --- /dev/null +++ b/charts/snyk-broker/tests/broker_deployment_labels_test.yaml @@ -0,0 +1,25 @@ +suite: test broker deployment +chart: + version: 0.0.0 +templates: + - broker_deployment.yaml + - broker_service.yaml + - serviceaccount.yaml + +tests: + - it: handles duplicative labels and adds new labels + values: + - ./fixtures/default_values.yaml + set: + labels: + app.kubernetes.io/name: "my duplicated label" + test: node1 + asserts: + - equal: + path: metadata.labels + value: + 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 + test: node1 diff --git a/charts/snyk-broker/tests/fixtures/default_values.yaml b/charts/snyk-broker/tests/fixtures/default_values.yaml index 2b7ec52..aaaa567 100644 --- a/charts/snyk-broker/tests/fixtures/default_values.yaml +++ b/charts/snyk-broker/tests/fixtures/default_values.yaml @@ -20,4 +20,3 @@ preflightChecks: highAvailabilityMode: enabled: false brokerDispatcherUrl: "https://api.test.snyk.io" - diff --git a/charts/snyk-broker/values.yaml b/charts/snyk-broker/values.yaml index 9cbb2a8..ab6f831 100644 --- a/charts/snyk-broker/values.yaml +++ b/charts/snyk-broker/values.yaml @@ -24,6 +24,9 @@ brokerDispatcherUrl: "https://api.snyk.io" # This number if only used if enableHighAvailabilityMode is true replicaCount: 2 +# Adds additional labels to broker deployment +labels: {} + ##### SCM Generic ##### # scmType is used to define the Source Control that you are connecting to.