From 61015846bc1be20a264fb7bc96084954d833e42a Mon Sep 17 00:00:00 2001 From: Joshua Gibeon Mulyana Date: Thu, 20 Jun 2024 10:43:08 +0700 Subject: [PATCH] add service annotations --- charts/onechart/templates/service.yaml | 7 ++++++- charts/onechart/tests/service_annotation_test.yaml | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 charts/onechart/tests/service_annotation_test.yaml diff --git a/charts/onechart/templates/service.yaml b/charts/onechart/templates/service.yaml index b2d9ff1..8116da0 100644 --- a/charts/onechart/templates/service.yaml +++ b/charts/onechart/templates/service.yaml @@ -5,7 +5,7 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "helm-chart.labels" . | nindent 4 }} - {{- if or (or (or (or (or .Values.gitRepository .Values.gitSha) .Values.serviceName) .Values.serviceDescription) .Values.ownerName) .Values.ownerIm }} + {{- if or (or (or (or (or (or .Values.gitRepository .Values.gitSha) .Values.serviceName) .Values.serviceDescription) .Values.ownerName) .Values.ownerIm) .Values.serviceAnnotations }} annotations: {{- if .Values.gitRepository }} gimlet.io/git-repository: {{ .Values.gitRepository }} @@ -44,6 +44,11 @@ metadata: {{- if .Values.traces }} v1alpha1.opensca.dev/traces: {{ .Values.traces | quote }} {{- end }} + {{- if .Values.serviceAnnotations }} + {{- with .Values.serviceAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} {{- end }} spec: type: {{ if .Values.nodePortEnabled }}NodePort{{ else if .Values.loadbalancerEnabled }}LoadBalancer{{ else }}ClusterIP{{ end }} diff --git a/charts/onechart/tests/service_annotation_test.yaml b/charts/onechart/tests/service_annotation_test.yaml new file mode 100644 index 0000000..3f09e48 --- /dev/null +++ b/charts/onechart/tests/service_annotation_test.yaml @@ -0,0 +1,13 @@ +suite: test deployment +templates: + - service.yaml +tests: + - it: Should set annotations if it is defined + set: + serviceAnnotations: + gimlet.io/test: example + asserts: + - equal: + path: metadata.annotations + value: + gimlet.io/test: example \ No newline at end of file