diff --git a/questions.yml b/questions.yml index e30707ff86e1b44fb3cbbf5578eef08570731100..9bb197d1e5fa075ed4f68cd2b2c11e03ecff939e 100644 --- a/questions.yml +++ b/questions.yml @@ -42,10 +42,9 @@ questions: group: "Ingress" show_subquestion_if: true subquestions: - - variable: ingress.host + - variable: ingress.overrideHost type: string - label: URL des deposit Webservice - default: afm.ozg-sh.de + label: Override generated deposit Webservice URL group: "Ingress" - variable: routing.fallbackStrategy diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 7d3c778a7e1063fa402908776f728c1d3ab2ea62..fc26695d7ae134da2977dc63c8072070c4faf7b1 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -63,6 +63,11 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{- end -}} +{{- define "app.kopBezeichner" -}} +{{- required "Bezeichner muss angegeben sein" (.Values.kop).bezeichner -}} +{{- end -}} + + {{- define "app.resources" }} {{- if eq (include "app.kopEnvironment" . ) "prod" }} limits: @@ -81,20 +86,32 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{- end }} {{- end -}} -{{- define "app.ssoName" -}} -{{ coalesce (.Values.sso).name ((split "-" (include "app.namespace" .) )._1) }} -{{- end -}} {{- define "app.ingress.host" }} -{{- if .Values.ingress.host }} -{{- printf "%s" .Values.ingress.host }} +{{- if .Values.ingress.overrideHost }} +{{- printf "%s" .Values.ingress.overrideHost }} +{{- else }} + +{{- if eq (include "app.kopEnvironment" . ) "prod" }} +{{- if eq (.Values.image).name "formsolutions-adapter" }} +{{- printf "https://%s-fs.ozg-sh.de" (include "app.kopBezeichner" .) }} {{- else }} -{{- if eq (include "app.ssoLevel" . ) "prod" }} -{{- printf "https://%s.afm.ozg-sh.de" (include "app.ssoName" .) }} -{{- else if eq (include "app.ssoLevel" . ) "stage" }} -{{- printf "https://%s.%s.afm.ozg-sh.de" (include "app.ssoName" .) (include "app.ssoLevel" . ) }} +{{- printf "https://%s.afm.ozg-sh.de" (include "app.kopBezeichner" .) }} +{{- end }} + +{{- else if eq (include "app.kopEnvironment" . ) "stage" }} +{{- if eq (.Values.image).name "formsolutions-adapter" }} +{{- printf "https://%s-fs.stage.ozg-sh.de" (include "app.kopBezeichner" .) }} {{- else }} -{{- printf "https://%s-afm.%s.ozg-sh.de" (include "app.ssoName" .) (include "app.ssoLevel" . ) }} +{{- printf "https://%s.stage.afm.ozg-sh.de" (include "app.kopBezeichner" .) }} +{{- end }} + +{{- else }} +{{- if eq (.Values.image).name "formsolutions-adapter" }} +{{- printf "https://%s-fs.%s.ozg-sh.de" (include "app.kopBezeichner" .) (include "app.kopEnvironment" . ) }} +{{- else }} +{{- printf "https://%s-afm.%s.ozg-sh.de" (include "app.kopBezeichner" .) (include "app.kopEnvironment" . ) }} +{{- end }} {{- end }} {{- end }} {{- end }} diff --git a/test-values.yaml b/test-values.yaml index 7eed0a446958c8d223e0736f38de3b52b146355e..37031e34541a0396a43470ed42eb7b8d63af15b1 100644 --- a/test-values.yaml +++ b/test-values.yaml @@ -1,2 +1,3 @@ kop: - environment: test \ No newline at end of file + environment: test + bezeichner: helm \ No newline at end of file diff --git a/unit-tests/ingress-create-or-not.yaml b/unit-tests/ingress-create-or-not.yaml index 1bc7b34151cdcb471624056cf5b4fd263c9418db..5cf4b5fb85035c9993802633d6ada7fce693144d 100644 --- a/unit-tests/ingress-create-or-not.yaml +++ b/unit-tests/ingress-create-or-not.yaml @@ -5,6 +5,8 @@ tests: - it: create ingress by config set: ingress.enabled: true + kop.environment: dev + kop.bezeichner: unit asserts: - isKind: of: Ingress @@ -15,6 +17,9 @@ tests: - hasDocuments: count: 0 - it: ingress should be created by default + set: + kop.environment: dev + kop.bezeichner: unit asserts: - isKind: of: Ingress diff --git a/unit-tests/ingress.yaml b/unit-tests/ingress.yaml deleted file mode 100644 index 596ce0b34d2856b6fc8bc43a9d093671e86230ec..0000000000000000000000000000000000000000 --- a/unit-tests/ingress.yaml +++ /dev/null @@ -1,91 +0,0 @@ -suite: test ingress creation -release: - name: intelliform-adapter - namespace: helm-test -templates: - - templates/ingress.yaml -set: - image.name: intelliform-adapter -tests: - - it: should match basic data - asserts: - - containsDocument: - kind: Ingress - apiVersion: networking.k8s.io/v1 - - equal: - path: metadata.name - value: intelliform-adapter - - equal: - path: metadata.namespace - value: helm-test - - it: should match service port number - asserts: - - equal: - path: spec.rules[0].http.paths[0].backend.service.port.number - value: 8080 - - it: should match service name - asserts: - - equal: - path: spec.rules[0].http.paths[0].backend.service.name - value: intelliform-adapter - - it: should match service path - asserts: - - isEmpty: - path: spec.rules[0].http.paths[0].path - - it: should match service pathType - asserts: - - equal: - path: spec.rules[0].http.paths[0].pathType - value: ImplementationSpecific - - it: should create dev host - release: - namespace: sh-unit-dev - asserts: - - equal: - path: spec.rules[0].host - value: https://unit-afm.dev.ozg-sh.de - - equal: - path: spec.tls[0].hosts[0] - value: https://unit-afm.dev.ozg-sh.de - - it: should create test host - release: - namespace: sh-unit-test - asserts: - - equal: - path: spec.rules[0].host - value: https://unit-afm.test.ozg-sh.de - - equal: - path: spec.tls[0].hosts[0] - value: https://unit-afm.test.ozg-sh.de - - it: should create prod host - release: - namespace: sh-unit-prod - asserts: - - equal: - path: spec.rules[0].host - value: https://unit.afm.ozg-sh.de - - equal: - path: spec.tls[0].hosts[0] - value: https://unit.afm.ozg-sh.de - - it: should create stage host - release: - namespace: sh-unit-stage - asserts: - - equal: - path: spec.rules[0].host - value: https://unit.stage.afm.ozg-sh.de - - equal: - path: spec.tls[0].hosts[0] - value: https://unit.stage.afm.ozg-sh.de - - it: should set host - release: - namespace: sh-unit-stage - set: - ingress.host: https://host.dev.ozg-sh.de - asserts: - - equal: - path: spec.rules[0].host - value: https://host.dev.ozg-sh.de - - equal: - path: spec.tls[0].hosts[0] - value: https://host.dev.ozg-sh.de \ No newline at end of file diff --git a/unit-tests/ingress_test.yaml b/unit-tests/ingress_test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..44611be7e93f702576e455808785ab546144ece0 --- /dev/null +++ b/unit-tests/ingress_test.yaml @@ -0,0 +1,159 @@ +suite: test ingress creation +release: + name: intelliform-adapter + namespace: sh-helm-test +templates: + - templates/ingress.yaml +tests: + - it: should match basic data + set: + kop.environment: dev + kop.bezeichner: unit + asserts: + - containsDocument: + kind: Ingress + apiVersion: networking.k8s.io/v1 + - equal: + path: metadata.name + value: intelliform-adapter + - equal: + path: metadata.namespace + value: sh-helm-test + - it: should match service port number + set: + kop.environment: dev + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].http.paths[0].backend.service.port.number + value: 8080 + - it: should match service name + set: + kop.environment: dev + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].http.paths[0].backend.service.name + value: intelliform-adapter + - it: should match service path + set: + kop.environment: dev + kop.bezeichner: unit + asserts: + - isEmpty: + path: spec.rules[0].http.paths[0].path + - it: should match service pathType + set: + kop.environment: dev + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].http.paths[0].pathType + value: ImplementationSpecific + - it: should create afm dev host + set: + kop.environment: dev + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://unit-afm.dev.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://unit-afm.dev.ozg-sh.de + - it: should create afm test host + set: + kop.environment: test + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://unit-afm.test.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://unit-afm.test.ozg-sh.de + - it: should create afm prod host + set: + kop.environment: prod + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://unit.afm.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://unit.afm.ozg-sh.de + - it: should create afm stage host + set: + kop.environment: stage + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://unit.stage.afm.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://unit.stage.afm.ozg-sh.de + - it: should set host + release: + namespace: sh-unit-stage + set: + ingress.overrideHost: https://host.dev.ozg-sh.de + kop.environment: dev + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://host.dev.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://host.dev.ozg-sh.de + + - it: should create fs dev host + set: + image.name: formsolutions-adapter + kop.environment: dev + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://unit-fs.dev.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://unit-fs.dev.ozg-sh.de + - it: should create fs test host + set: + image.name: formsolutions-adapter + kop.environment: test + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://unit-fs.test.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://unit-fs.test.ozg-sh.de + - it: should create fs prod host + set: + image.name: formsolutions-adapter + kop.environment: prod + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://unit-fs.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://unit-fs.ozg-sh.de + - it: should create fs stage host + set: + image.name: formsolutions-adapter + kop.environment: stage + kop.bezeichner: unit + asserts: + - equal: + path: spec.rules[0].host + value: https://unit-fs.stage.ozg-sh.de + - equal: + path: spec.tls[0].hosts[0] + value: https://unit-fs.stage.ozg-sh.de \ No newline at end of file diff --git a/values.yaml b/values.yaml index d63291fcb939f76ed0ba42d8c07a4204f724406f..332ff99bc0f5f5b3f7214d136ccc4b41de1c347f 100644 --- a/values.yaml +++ b/values.yaml @@ -25,10 +25,12 @@ imageCredentials: ingress: enabled: true + # overrideHost: afm.ozg-sh.de #routing: # fallbackStrategy: DENY # routingStrategy: SINGLE # kop: -# environment: dev \ No newline at end of file +# environment: dev +# bezeichner: helm \ No newline at end of file