diff --git a/src/main/helm/templates/_helpers.tpl b/src/main/helm/templates/_helpers.tpl index 05eff90dd9ffac4f88dd80512a238227c4f3094f..0ca938a6673b5a1718fc0bf433c78888c61a1377 100644 --- a/src/main/helm/templates/_helpers.tpl +++ b/src/main/helm/templates/_helpers.tpl @@ -24,7 +24,11 @@ {{- define "app.baseDomain" -}} -{{- printf "%s-%s.%s" (.Values.ozgcloud).bezeichner (.Values.ozgcloud).adminDomainSuffix .Values.baseUrl }} +{{- printf "%s-%s.%s" (.Values.ozgcloud).bezeichner (.Values.ozgcloud).adminDomainSuffix ( include "app.getBaseUrl" . ) }} +{{- end -}} + +{{- define "app.getBaseUrl" -}} +{{- required "baseUrl muss angegeben sein" .Values.baseUrl }} {{- end -}} {{/* Namespace */}} @@ -101,3 +105,19 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} {{- define "app.serviceAccountName" -}} {{ printf "%s" ( (.Values.serviceAccount).name | default "administration-service-account" ) }} {{- end -}} + +{{- define "app.getZufiSearchUri" -}} +{{ if ((.Values.ozgcloud).organisationEinheit).zufiSearchUri }} +{{- printf "%s" .Values.ozgcloud.organisationEinheit.zufiSearchUri }} +{{- else -}} +{{- printf "https://%s/api/organisationseinheits?searchBy={searchBy}" ( include "app.generateAlfaUrl" . ) }} +{{- end -}} +{{- end -}} + +{{- define "app.generateAlfaUrl" -}} +{{ if (.Values.ozgcloud).alfaUrl }} +{{- printf "%s" .Values.ozgcloud.alfaUrl }} +{{- else -}} +{{- printf "%s.%s" ( include "app.ozgcloudBezeichner" . ) ( include "app.getBaseUrl" . ) }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml index 7131cc9d9630c7d8d5964a3abcf2512e42b3dc87..454069903ae76d9d272d85779148443bbe427540 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -129,7 +129,7 @@ spec: {{- end }} {{- if eq ((.Values.ozgcloud).feature).organisationsEinheiten "true" }} - name: ozgcloud_organisationeinheit_zufisearchuri - value: {{ required "ozgcloud.organisationEinheit.zufiSearchUri must be set if feature organisationsEinheiten is activated" ((.Values.ozgcloud).organisationEinheit).zufiSearchUri}} + value: {{ include "app.getZufiSearchUri" . }} {{- end }} envFrom: {{- if (.Values.database).useExternal }} diff --git a/src/main/helm/values.yaml b/src/main/helm/values.yaml index 4d2e4848388dcd89febfe8aa79975444a449af1d..86aaec61ba16dbf49d880c88931a5ab2b94fad3a 100644 --- a/src/main/helm/values.yaml +++ b/src/main/helm/values.yaml @@ -23,7 +23,7 @@ # replicaCount: 1 -baseUrl: ozg-sh.de +baseUrl: ozgcloud: bezeichner: helm diff --git a/src/test/helm/deployment_zufi_test.yaml b/src/test/helm/deployment_zufi_test.yaml index e342ff4be91b397f84da64cf8606fc8d99f6e082..b7a2350f69765e8a5d9c75f726d7ffd004884b1e 100644 --- a/src/test/helm/deployment_zufi_test.yaml +++ b/src/test/helm/deployment_zufi_test.yaml @@ -41,8 +41,6 @@ tests: ozgcloud: feature: organisationsEinheiten: "false" - organisationEinheit: - zufiSearchUri: alfa/zufi/search/endpoint?searchBy={searchBy} asserts: - notContains: path: spec.template.spec.containers[0].env @@ -50,34 +48,54 @@ tests: name: ozgcloud_organisationeinheit_zufisearchuri any: true - it: should not contain zufi search uri if organisationseinheit feature toggle is disabled - set: - ozgcloud: - organisationEinheit: - zufiSearchUri: alfa/zufi/search/endpoint?searchBy={searchBy} asserts: - notContains: path: spec.template.spec.containers[0].env content: name: ozgcloud_organisationeinheit_zufisearchuri any: true + - it: should generate zufi search uri + set: + ozgcloud: + feature: + organisationsEinheiten: "true" + baseUrl: ozg-sh.de + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: ozgcloud_organisationeinheit_zufisearchuri + value: https://helm.ozg-sh.de/api/organisationseinheits?searchBy={searchBy} - it: should set zufi search uri set: ozgcloud: feature: organisationsEinheiten: "true" organisationEinheit: - zufiSearchUri: alfa/zufi/search/endpoint?searchBy={searchBy} + zufiSearchUri: "https://company.local/api/organisationseinheits?searchBy={searchBy}" + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: ozgcloud_organisationeinheit_zufisearchuri + value: "https://company.local/api/organisationseinheits?searchBy={searchBy}" + - it: should set alfa url + set: + ozgcloud: + feature: + organisationsEinheiten: "true" + alfaUrl: "alfa.local" asserts: - contains: path: spec.template.spec.containers[0].env content: name: ozgcloud_organisationeinheit_zufisearchuri - value: alfa/zufi/search/endpoint?searchBy={searchBy} - - it: should fail if zufi search uri is not set + value: "https://alfa.local/api/organisationseinheits?searchBy={searchBy}" + - it: should fail without baseUrl and alfaUrl and zufiSearchUrl set: ozgcloud: feature: organisationsEinheiten: "true" asserts: - failedTemplate: - errorMessage: "ozgcloud.organisationEinheit.zufiSearchUri must be set if feature organisationsEinheiten is activated" + errorMessage: "baseUrl muss angegeben sein" \ No newline at end of file diff --git a/src/test/helm/keycloak_client_crd_test.yaml b/src/test/helm/keycloak_client_crd_test.yaml index 2ab407d1845b2870e03dee138e086581bed9b904..eb5c6003aaff9d7a4ab01824ed3f007fdf9e5a1c 100644 --- a/src/test/helm/keycloak_client_crd_test.yaml +++ b/src/test/helm/keycloak_client_crd_test.yaml @@ -33,6 +33,7 @@ set: bundesland: by bezeichner: helm environment: test + baseUrl: ozg-sh.de tests: - it: should contain header data set: