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: add labels to containers #139

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
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.8.2
version: 2.8.3
description: A Helm chart for Kubernetes
type: application
9 changes: 8 additions & 1 deletion charts/snyk-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand Down Expand Up @@ -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 -}}
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 @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 26 additions & 2 deletions charts/snyk-broker/tests/broker_deployment_labels_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Loading