Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adds labels to broker deployment [HYB-560] #120

Merged
merged 10 commits into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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 . }}
saumilmac marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
{{- toYaml $commonLabels | nindent 4 }}
{{- end }}

{{/*
2 changes: 1 addition & 1 deletion charts/snyk-broker/templates/broker_deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion charts/snyk-broker/templates/broker_service.yaml
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion charts/snyk-broker/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
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
@@ -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
@@ -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
saumilmac marked this conversation as resolved.
Show resolved Hide resolved
labels: {}

##### SCM Generic #####

# scmType is used to define the Source Control that you are connecting to.