diff --git a/charts/onechart/templates/deployment.yaml b/charts/onechart/templates/deployment.yaml index 9daa390..5a36090 100644 --- a/charts/onechart/templates/deployment.yaml +++ b/charts/onechart/templates/deployment.yaml @@ -5,6 +5,10 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "helm-chart.labels" . | nindent 4 }} + {{- if .Values.gitSha }} + annotations: + gimlet.io/git-sha: {{ .Values.gitSha }} + {{- end }} spec: replicas: {{ .Values.replicas }} selector: @@ -17,6 +21,12 @@ spec: {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} + {{- if .Values.gitSha }} + gimlet.io/git-sha: {{ .Values.gitSha }} + {{- end }} + {{- if .Values.gitRepository }} + gimlet.io/git-repository: {{ .Values.gitRepository }} + {{- end }} labels: {{- include "helm-chart.selectorLabels" . | nindent 8 }} spec: diff --git a/charts/onechart/templates/ingress.yaml b/charts/onechart/templates/ingress.yaml index b3368a7..140abd7 100644 --- a/charts/onechart/templates/ingress.yaml +++ b/charts/onechart/templates/ingress.yaml @@ -13,9 +13,17 @@ metadata: namespace: {{ .root.Release.Namespace }} labels: {{- include "helm-chart.labels" .root | nindent 4 }} - {{- with .ingress.annotations }} + {{- if or (or .root.Values.gitSha .ingress.annotations) .root.Values.gitRepository }} annotations: - {{- toYaml . | nindent 4 }} + {{- if .ingress.annotations }} + {{- toYaml .ingress.annotations | nindent 4 }} + {{- end }} + {{- if .root.Values.gitSha }} + gimlet.io/git-sha: {{ .root.Values.gitSha }} + {{- end }} + {{- if .root.Values.gitRepository }} + gimlet.io/git-sha: {{ .root.Values.gitRepository }} + {{- end }} {{- end }} spec: {{- if default false .ingress.tlsEnabled }} diff --git a/charts/onechart/templates/service.yaml b/charts/onechart/templates/service.yaml index e319b31..8396561 100644 --- a/charts/onechart/templates/service.yaml +++ b/charts/onechart/templates/service.yaml @@ -5,6 +5,15 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "helm-chart.labels" . | nindent 4 }} + {{- if or .Values.gitRepository .Values.gitSha }} + annotations: + {{- if .Values.gitRepository }} + gimlet.io/git-repository: {{ .Values.gitRepository }} + {{- end }} + {{- if .Values.gitSha }} + gimlet.io/git-sha: {{ .Values.gitSha }} + {{- end }} + {{- end }} spec: type: {{ if .Values.nodePortEnabled }}NodePort{{ else if .Values.loadbalancerEnabled }}LoadBalancer{{ else }}ClusterIP{{ end }} {{- if .Values.stickySessions }} diff --git a/charts/onechart/tests/service_taxonomy_test.yaml b/charts/onechart/tests/service_taxonomy_test.yaml new file mode 100644 index 0000000..498d43f --- /dev/null +++ b/charts/onechart/tests/service_taxonomy_test.yaml @@ -0,0 +1,14 @@ +suite: test service +templates: + - service.yaml +tests: + - it: Should set Gimlet taxonomy + set: + gitRepository: github.com/laszlocph/demo-app + gitSha: xyz + asserts: + - equal: + path: metadata.annotations + value: + gimlet.io/git-repository: github.com/laszlocph/demo-app + gimlet.io/git-sha: xyz diff --git a/values.yaml b/values.yaml index 8270ce0..b59c72f 100644 --- a/values.yaml +++ b/values.yaml @@ -8,4 +8,7 @@ ingresses: kubernetes.io/ingress.class: nginx - host: another.local annotations: - kubernetes.io/ingress.class: nginx \ No newline at end of file + kubernetes.io/ingress.class: nginx + +gitRepository: github.com/laszlocph/demo-app +gitSha: xyz