Skip to content

Commit

Permalink
fix: honored when set in envFromSecrets
Browse files Browse the repository at this point in the history
  • Loading branch information
ialejandro committed Aug 28, 2024
1 parent 9740448 commit 8b8121e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
10 changes: 5 additions & 5 deletions charts/openbas/templates/caldera/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ spec:
{{- $_ := set $envList $key true }}
{{- end }}
{{- end }}
# Special handling for OPENBAS_ADMIN_TOKEN which is constructed from other values
{{- if and (not (hasKey $envList "OPENBAS_ADMIN_TOKEN")) (.Values.env.APP__ADMIN__TOKEN) }}
- name: OPENBAS_ADMIN_TOKEN
value: "{{ .Values.env.APP__ADMIN__TOKEN }}"
{{- end }}
# Add variables in plain text from .Values.caldera.env if they were not already added from secrets
{{- if .Values.caldera.env }}
{{- range $key, $value := .Values.caldera.env }}
Expand All @@ -86,6 +81,11 @@ spec:
{{- end }}
{{- end }}
{{- end }}
# Special handling for OPENBAS_ADMIN_TOKEN which is constructed from other values
{{- if and (not (hasKey $envList "OPENBAS_ADMIN_TOKEN")) (.Values.env.APP__ADMIN__TOKEN) }}
- name: OPENBAS_ADMIN_TOKEN
value: "{{ .Values.env.APP__ADMIN__TOKEN }}"
{{- end }}
resources:
{{- toYaml .Values.caldera.resources | nindent 12 }}
volumeMounts:
Expand Down
25 changes: 15 additions & 10 deletions charts/openbas/templates/collector/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ spec:
{{- $_ := set $envList $key true }}
{{- end }}
{{- end }}
# Special handling for OPENBAS_URL which is constructed from other values
{{- if not (hasKey .env "OPENBAS_URL") }}
- name: OPENBAS_URL
value: "http://{{ include "openbas.fullname" $ }}-server:{{ $.Values.service.port }}"
{{- end }}
# Special handling for OPENBAS_TOKEN which is constructed from other values
{{- if and (not (hasKey .env "OPENBAS_TOKEN")) ($.Values.env.OPENBAS_ADMIN_TOKEN) }}
- name: OPENBAS_TOKEN
value: "{{ $.Values.env.OPENBAS_ADMIN_TOKEN }}"
{{- end }}
# Add variables in plain text if they were not already added from secrets
{{- if .env }}
{{- range $key, $value := .env }}
Expand All @@ -83,6 +73,21 @@ spec:
{{- end }}
{{- end }}
{{- end }}
# Special handling for OPENBAS_URL which is constructed from other values
{{- if not (hasKey $envList "OPENBAS_URL") }}
{{- if eq $.Values.env.APP__BASE_PATH "/" }}
- name: OPENBAS_URL
value: "http://{{ include "openbas.fullname" $ }}-server:{{ $.Values.service.port }}"
{{- else }}
- name: OPENBAS_URL
value: "http://{{ include "openbas.fullname" $ }}-server:{{ $.Values.service.port }}{{ $.Values.env.APP__BASE_PATH }}"
{{- end }}
{{- end }}
# Special handling for OPENBAS_TOKEN which is constructed from other values
{{- if and (not (hasKey $envList "OPENBAS_TOKEN")) ($.Values.env.OPENBAS_ADMIN_TOKEN) }}
- name: OPENBAS_TOKEN
value: "{{ $.Values.env.OPENBAS_ADMIN_TOKEN }}"
{{- end }}
resources:
{{- toYaml .resources | nindent 12 }}
{{- with .nodeSelector }}
Expand Down
26 changes: 15 additions & 11 deletions charts/openbas/templates/injector/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ spec:
env:
# Variables from secrets have precedence
{{- $envList := dict -}}

{{- if .envFromSecrets }}
{{- range $key, $value := .envFromSecrets }}
- name: {{ $key | upper }}
Expand All @@ -64,16 +63,6 @@ spec:
{{- $_ := set $envList $key true }}
{{- end }}
{{- end }}
# Special handling for OPENBAS_URL which is constructed from other values
{{- if not (hasKey .env "OPENBAS_URL") }}
- name: OPENBAS_URL
value: "http://{{ include "openbas.fullname" $ }}-server:{{ $.Values.service.port }}"
{{- end }}
# Special handling for OPENBAS_TOKEN which is constructed from other values
{{- if and (not (hasKey .env "OPENBAS_TOKEN")) ($.Values.env.OPENBAS_ADMIN_TOKEN) }}
- name: OPENBAS_TOKEN
value: "{{ $.Values.env.OPENBAS_ADMIN_TOKEN }}"
{{- end }}
# Add variables in plain text if they were not already added from secrets
{{- if .env }}
{{- range $key, $value := .env }}
Expand All @@ -84,6 +73,21 @@ spec:
{{- end }}
{{- end }}
{{- end }}
# Special handling for OPENBAS_URL which is constructed from other values
{{- if not (hasKey $envList "OPENBAS_URL") }}
{{- if eq $.Values.env.APP__BASE_PATH "/" }}
- name: OPENBAS_URL
value: "http://{{ include "openbas.fullname" $ }}-server:{{ $.Values.service.port }}"
{{- else }}
- name: OPENBAS_URL
value: "http://{{ include "openbas.fullname" $ }}-server:{{ $.Values.service.port }}{{ $.Values.env.APP__BASE_PATH }}"
{{- end }}
{{- end }}
# Special handling for OPENBAS_TOKEN which is constructed from other values
{{- if and (not (hasKey $envList "OPENBAS_TOKEN")) ($.Values.env.OPENBAS_ADMIN_TOKEN) }}
- name: OPENBAS_TOKEN
value: "{{ $.Values.env.OPENBAS_ADMIN_TOKEN }}"
{{- end }}
resources:
{{- toYaml .resources | nindent 12 }}
{{- with .nodeSelector }}
Expand Down

0 comments on commit 8b8121e

Please sign in to comment.