Skip to content
Snippets Groups Projects
Commit e24e580d authored by OZGCloud's avatar OZGCloud
Browse files

generate spring profiles

parent 90331b9d
No related branches found
No related tags found
No related merge requests found
...@@ -49,17 +49,22 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} ...@@ -49,17 +49,22 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
{{- end }} {{- end }}
{{/*- define "app.environment" -*/}} {{- define "app.envSpringProfiles" }}
{{/*- $namespaceMap := (split "-" (include "app.namespace" .) ) -*/}} {{- if (.Values.env).overrideSpringProfiles -}}
{{/*- coalesce (.Values.kop).environment ( index $namespaceMap (printf "_%d" (sub (len $namespaceMap) 1))) "prod" */}} {{ printf "%s" (.Values.env).overrideSpringProfiles }}
{{/*- end -*/}} {{- else -}}
{{ printf "oc,%s" (include "app.kopEnvironment" . ) }}
{{- end -}}
{{- end -}}
{{- define "app.environment" -}}
{{- define "app.kopEnvironment" -}}
{{- required "Environment muss angegeben sein" (.Values.kop).environment -}} {{- required "Environment muss angegeben sein" (.Values.kop).environment -}}
{{- end -}} {{- end -}}
{{- define "app.resources" }} {{- define "app.resources" }}
{{- if eq (include "app.environment" . ) "prod" }} {{- if eq (include "app.kopEnvironment" . ) "prod" }}
limits: limits:
cpu: "1" cpu: "1"
memory: "1000Mi" memory: "1000Mi"
......
...@@ -37,7 +37,7 @@ spec: ...@@ -37,7 +37,7 @@ spec:
value: {{ .value }} value: {{ .value }}
{{- end }} {{- end }}
- name: spring_profiles_active - name: spring_profiles_active
value: {{ (.Values.env).springProfiles | default "oc, prod" }} value: {{ include "app.envSpringProfiles" . }}
- name: kop_adapter_fallbackStrategy - name: kop_adapter_fallbackStrategy
value: {{ (.Values.routing).fallbackStrategy | default "DENY"}} value: {{ (.Values.routing).fallbackStrategy | default "DENY"}}
{{- if (.Values.routing).fundstellePlutoName}} {{- if (.Values.routing).fundstellePlutoName}}
......
suite: test spring profiles
release:
name: if-adapter
templates:
- templates/deployment.yaml
tests:
- it: should override spring profiles
set:
kop.environment: test
env.overrideSpringProfiles: oc,stage,ea
asserts:
- isKind:
of: Deployment
- contains:
path: spec.template.spec.containers[0].env
content:
name: spring_profiles_active
value: oc,stage,ea
- it: should generate spring profiles
set:
kop.environment: test
asserts:
- isKind:
of: Deployment
- contains:
path: spec.template.spec.containers[0].env
content:
name: spring_profiles_active
value: oc,test
\ No newline at end of file
...@@ -5,7 +5,7 @@ image: ...@@ -5,7 +5,7 @@ image:
# tag: latest # [default: latest] # tag: latest # [default: latest]
# env: # env:
#springProfiles: oc, prod # [default: oc, prod] # overrideSpringProfiles: "oc,prod"
# customList: # add name value pair for additional environments # customList: # add name value pair for additional environments
# - name: Dinge # - name: Dinge
# value: true # value: true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment