Skip to content

Commit

Permalink
Add missing template files
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Jul 7, 2022
1 parent 0ec3643 commit c9b1876
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ repos:
hooks:
- id: sops-encryption
# Add files here if they contain the word 'secret' but should not be encrypted
exclude: secrets\.md|helm-charts/support/templates/prometheus-ingres-auth/secret\.yaml
exclude: secrets\.md|helm-charts/support/templates/prometheus-ingres-auth/secret\.yaml|helm-charts/basehub/templates/dex/secret\.yaml
9 changes: 9 additions & 0 deletions helm-charts/basehub/templates/dex/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Until https://github.com/Masterminds/sprig/issues/282 is fixed
{{- define "randHex" -}}
{{- $result := "" }}
{{- range $i := until . }}
{{- $rand_hex_char := mod (randNumeric 4 | atoi) 16 | printf "%x" }}
{{- $result = print $result $rand_hex_char }}
{{- end }}
{{- $result }}
{{- end }}
12 changes: 12 additions & 0 deletions helm-charts/basehub/templates/dex/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{ if .Values.dex.enabled -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dex
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
{{- end }}
21 changes: 21 additions & 0 deletions helm-charts/basehub/templates/dex/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.dex.enabled -}}
apiVersion: v1
kind: Secret
metadata:
name: dex
type: Opaque
stringData:
{{- $k8sState := lookup "v1" "Secret" .Release.Namespace "dex" | default (dict "data" (dict)) }}

{{- if hasKey $k8sState.data "oauth2Proxy.clientSecret" }}
oauth2Proxy.clientSecret: {{ index $k8sState.data "oauth2Proxy.clientSecret" | b64dec }}
{{- else }}
oauth2Proxy.clientSecret: {{ include "randHex" 64 }}
{{- end }}

{{- if hasKey $k8sState.data "oauth2Proxy.cookieSecret" }}
oauth2Proxy.cookieSecret: {{ index $k8sState.data "oauth2Proxy.cookieSecret" | b64dec }}
{{- else }}
oauth2Proxy.cookieSecret: {{ include "randHex" 16 }}
{{- end }}
{{- end }}

0 comments on commit c9b1876

Please sign in to comment.