Skip to content

Commit

Permalink
Merge pull request #120 from snyk/fix/adds-labels-to-deployment
Browse files Browse the repository at this point in the history
fix: adds labels to broker deployment [HYB-560]
  • Loading branch information
saumilmac authored Jun 27, 2024
2 parents f2a5084 + cb2b73d commit 06105f3
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/snyk-broker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 8 additions & 4 deletions charts/snyk-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

{{/*
Expand Down
2 changes: 1 addition & 1 deletion charts/snyk-broker/templates/broker_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/snyk-broker/templates/broker_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion charts/snyk-broker/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
25 changes: 25 additions & 0 deletions charts/snyk-broker/tests/broker_deployment_labels_test.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion charts/snyk-broker/tests/fixtures/default_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ preflightChecks:
highAvailabilityMode:
enabled: false
brokerDispatcherUrl: "https://api.test.snyk.io"

3 changes: 3 additions & 0 deletions charts/snyk-broker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 06105f3

Please sign in to comment.