Skip to content

Commit

Permalink
feat: additional templating (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
cberg-aot authored Nov 15, 2023
1 parent de50493 commit 1356e8f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion charts/component/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.17
version: 0.0.18

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
8 changes: 4 additions & 4 deletions charts/component/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ vault.hashicorp.com/agent-inject-token: 'true'
vault.hashicorp.com/agent-pre-populate-only: 'true' # this makes sure the secret vault will only change during pod restart
vault.hashicorp.com/auth-path: auth/k8s-silver # This was tricky. Be sure to use k8s-silver, k8s-gold, or k8s-golddr
vault.hashicorp.com/namespace: platform-services
vault.hashicorp.com/role: {{.Values.vault.role}} # licenseplate-nonprod or licenseplate-prod are your options
vault.hashicorp.com/role: {{tpl .Values.global.license .}}-{{tpl .Values.vault.role .}} # licenseplate-nonprod or licenseplate-prod are your options
{{- if .Values.vault.resources }}
vault.hashicorp.com/agent-requests-cpu: {{.Values.vault.resources.requests.cpu }}
vault.hashicorp.com/agent-limits-cpu: {{.Values.vault.resources.limits.cpu }}
Expand All @@ -92,9 +92,9 @@ vault.hashicorp.com/agent-limits-mem: {{.Values.vault.resources.limits.memory }}
# - The name of the secret is any unique string after vault.hashicorp.com/agent-inject-secret-<name>
# - The value is the path in Vault where the secret is located.
{{- range $k := .Values.vault.secretPaths }}
vault.hashicorp.com/agent-inject-secret-{{$k}}: {{$.Values.vault.role}}/{{$k}}
vault.hashicorp.com/agent-inject-template-{{$k}}: |
{{ printf "%s" "{{" }}- with secret "{{$.Values.vault.role}}/{{$k}}"{{ printf "%s" "}}" }}
vault.hashicorp.com/agent-inject-secret-{{tpl $k $}}: {{tpl $.Values.global.license $}}-{{tpl $.Values.vault.role $}}/{{tpl $k $}}
vault.hashicorp.com/agent-inject-template-{{tpl $k $}}: |
{{ printf "%s" "{{" }}- with secret "{{tpl $.Values.global.license $}}-{{tpl $.Values.vault.role $}}/{{tpl $k $}}"{{ printf "%s" "}}" }}
{{ printf "%s" "{{" }}- range $k,$v := .Data.data{{ printf "%s" "}}" }}
export {{"{{"}}$k{{"}}"}}="{{"{{"}}$v{{"}}"}}"
{{ printf "%s" "{{" }}- end{{ printf "%s" "}}" }}
Expand Down
16 changes: 9 additions & 7 deletions charts/component/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ spec:
labels:
{{- include "component.selectorLabels" . | nindent 8 }}
spec:
{{- if .Values.imagePullSecrets }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.podSecurityContext }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
Expand All @@ -47,16 +49,16 @@ spec:
{{- range .Values.initContainers }}
- name: {{ .name }}
{{- if (contains "sha256:" .tag) }}
image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ trimPrefix "sha256:" .tag }}'
image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ trimPrefix "sha256:" tpl .tag $ }}'
{{- else }}
image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ .tag }}'
image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ tpl .tag $ }}'
{{- end }}

imagePullPolicy: Always
{{- if .command }}
command:
{{- range .command }}
- "{{ . }}"
- "{{tpl . .}}"
{{- end }}
{{- end}}
{{- if .args }}
Expand Down Expand Up @@ -160,7 +162,7 @@ spec:
{{- end }}
{{- end }}
{{- if $.Values.serviceAccount }}
serviceAccountName: {{ $.Values.serviceAccount.name }}
serviceAccountName: {{tpl $.Values.serviceAccount.name .}}
{{- end }}
containers:
{{- range .Values.containers }}
Expand All @@ -172,7 +174,7 @@ spec:
{{- if .command }}
command:
{{- range .command }}
- "{{ . }}"
- "{{tpl . $}}"
{{- end }}
{{- end}}
{{- if .args }}
Expand All @@ -182,9 +184,9 @@ spec:
{{- end }}
{{- end }}
{{- if (contains "sha256:" .tag) }}
image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ trimPrefix "sha256:" .tag }}'
image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ trimPrefix "sha256:" tpl .tag $ }}'
{{- else }}
image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ .tag }}'
image: '{{$.Values.global.openshiftImageRegistry}}/{{$.Release.Namespace}}/{{$releaseName}}-{{ .name }}:{{ tpl .tag $ }}'
{{- end }}
imagePullPolicy: Always
{{- if .envFrom }}
Expand Down
24 changes: 12 additions & 12 deletions charts/component/templates/imagestreams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ spec:
lookupPolicy:
local: false
tags:
{{- if (contains "sha256:" .tag) }}
- name: {{ trimPrefix "sha256:" .tag | quote }}
{{- if (contains "sha256:" (tpl .tag $)) }}
- name: {{ trimPrefix "sha256:" (tpl .tag $) | quote }}
{{- else }}
- name: {{ .tag | quote }}
- name: {{ (tpl .tag $) | quote }}
{{- end }}
from:
kind: DockerImage
{{- if (contains "sha256:" .tag) }}
name: '{{ tpl .registry $ }}/{{ tpl .repository $ }}/{{ .image }}@{{ .tag }}'
{{- if (contains "sha256:" (tpl .tag $)) }}
name: '{{ tpl .registry $ }}/{{ tpl .repository $ }}/{{ .image }}@{{ (tpl .tag $) }}'
{{- else }}
name: '{{ tpl .registry $ }}/{{ tpl .repository $ }}/{{ .image }}:{{ .tag }}'
name: '{{ tpl .registry $ }}/{{ tpl .repository $ }}/{{ .image }}:{{ (tpl .tag $) }}'
{{- end }}
referencePolicy:
type: Local
Expand All @@ -42,17 +42,17 @@ spec:
lookupPolicy:
local: false
tags:
{{- if (contains "sha256:" .tag) }}
- name: {{ trimPrefix "sha256:" .tag | quote }}
{{- if (contains "sha256:" (tpl .tag $)) }}
- name: {{ trimPrefix "sha256:" (tpl .tag $) | quote }}
{{- else }}
- name: {{ .tag | quote }}
- name: {{ (tpl .tag $) | quote }}
{{- end }}
from:
kind: DockerImage
{{- if (contains "sha256:" .tag) }}
name: '{{ tpl .registry $ }}/{{ tpl .repository $ }}/{{ .image }}@{{ .tag }}'
{{- if (contains "sha256:" (tpl .tag $)) }}
name: '{{ tpl .registry $ }}/{{ tpl .repository $ }}/{{ .image }}@{{ (tpl .tag $) }}'
{{- else }}
name: '{{ tpl .registry $ }}/{{ tpl .repository $ }}/{{ .image }}:{{ .tag }}'
name: '{{ tpl .registry $ }}/{{ tpl .repository $ }}/{{ .image }}:{{ (tpl .tag $) }}'
{{- end }}
referencePolicy:
type: Local
Expand Down
2 changes: 1 addition & 1 deletion charts/component/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
- host: {{tpl .host $ | quote }}
http:
paths:
{{- range .paths }}
Expand Down
2 changes: 1 addition & 1 deletion charts/component/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.serviceAccount.name }}
name: {{ tpl .Values.serviceAccount.name .}}
labels:
{{- include "component.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
Expand Down

0 comments on commit 1356e8f

Please sign in to comment.