diff --git a/src/main/helm/templates/ingress.yaml b/src/main/helm/templates/ingress.yaml index 4b8a34978263469c5af9925f504703c8a3a92368..c9e606ed0bf39698127f86381d65b0ad8edee09d 100644 --- a/src/main/helm/templates/ingress.yaml +++ b/src/main/helm/templates/ingress.yaml @@ -25,10 +25,16 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - {{- with .Values.ingress.configuration_snippet}} - annotations: {{- toYaml . | nindent 4 }} + annotations: + {{- if .Values.ingress.configuration_snippet }} + {{- with .Values.ingress.configuration_snippet }} + {{- toYaml . | nindent 4 }} {{- end }} more_set_headers "Access-Control-Allow-Origin: {{ (include "app.alfaAddress" .) }}"; + {{- end }} + {{- with .Values.ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- if (.Values.ingress).certManagerAnnotations -}} {{- range (.Values.ingress).certManagerAnnotations }} {{ . | indent 4 }} diff --git a/src/test/helm/ingress_nginx_cors_test.yaml b/src/test/helm/ingress_nginx_cors_test.yaml index f415a7e2018f5b73ce10322e963a237386a36c1c..831fe9f0aa4cefbdbd5809c614753a41640047bf 100644 --- a/src/test/helm/ingress_nginx_cors_test.yaml +++ b/src/test/helm/ingress_nginx_cors_test.yaml @@ -44,3 +44,23 @@ tests: more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-XSRF-TOKEN"; more_set_headers "Access-Control-Expose-Headers: Content-Length,Content-Range"; more_set_headers "Access-Control-Allow-Origin: https://helm.test.sh.ozg-cloud.de"; + - it: Should disable nginx configuration snippet + set: + ingress: + configuration_snippet: null + asserts: + - notExists: + path: metadata.annotations["nginx.ingress.kubernetes.io/configuration-snippet"] + - it: Should contain annotations + set: + ingress: + annotations: + foo: bar + hello: world + asserts: + - equal: + path: metadata.annotations.foo + value: bar + - equal: + path: metadata.annotations.hello + value: world \ No newline at end of file