Skip to content

Commit

Permalink
Merge pull request #9 from camptocamp/add-basic-auth
Browse files Browse the repository at this point in the history
Add basic auth support, fix name
  • Loading branch information
sbrunner authored Jan 25, 2022
2 parents 49069b5 + e316c11 commit 61e53ec
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
appVersion: '1.0'
description: A chart to manage the application secrets
name: custom-pod
name: secrets
version: 0.1.0
dependencies:
- name: common
Expand Down
8 changes: 7 additions & 1 deletion templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ metadata:
type: generic
data:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | b64enc }}
{{- if eq ( default "value" $value.type ) "value" }}
{{ $key }}: {{ $value.value | b64enc }}
{{- else }}
{{- if eq $value.type "basicAuth" }}
{{ $key }}: {{ ( printf "Basic %s" ( printf "%s:%s" $value.user $value.password ) | b64enc ) | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
17 changes: 9 additions & 8 deletions tests/expected.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
---
# Source: custom-pod/templates/dockerhub-secret.yaml
# Source: secrets/templates/dockerhub-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: custom-custom-pod-dockerregistry
name: custom-secrets-dockerregistry
labels:
helm.sh/chart: custom-pod-0.1.0
helm.sh/chart: secrets-0.1.0
app.kubernetes.io/version: "1.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: custom-pod
app.kubernetes.io/name: secrets
app.kubernetes.io/instance: custom
app.kubernetes.io/component: main
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: ewogICJhdXRocyI6IHsKICAgICJkb2NrZXIuaW8iOiB7CiAgICAgICJhdXRoIjogIll6SmpaMmx6WW05ME9qRXlNelE9IiwKICAgICAgInVzZXJuYW1lIjogImMyY2dpc2JvdCIsCiAgICAgICJwYXNzd29yZCI6ICIxMjM0IiwKICAgICAgImVtYWlsIjogImRvY2tlci1odWJAY2FtcHRvY2FtcC5jb20iCiAgICB9LAogICAgImdoY3IuaW8iOiB7CiAgICAgICJhdXRoIjogIll6SmpMV0p2ZEMxbmFYTXRZMms2TVRJek5BPT0iLAogICAgICAidXNlcm5hbWUiOiAiYzJjLWJvdC1naXMtY2kiLAogICAgICAicGFzc3dvcmQiOiAiMTIzNCIsCiAgICAgICJlbWFpbCI6ICJnZW9zcGF0aWFsLWJvdEBjYW1wdG9jYW1wLmNvbSIKICAgIH0sCiAgICAiaHR0cHM6Ly9pbmRleC5kb2NrZXIuaW8vdjEvIjogewogICAgICAiYXV0aCI6ICJZekpqWjJselltOTBPakV5TXpRPSIsCiAgICAgICJ1c2VybmFtZSI6ICJjMmNnaXNib3QiLAogICAgICAicGFzc3dvcmQiOiAiMTIzNCIsCiAgICAgICJlbWFpbCI6ICJkb2NrZXItaHViQGNhbXB0b2NhbXAuY29tIgogICAgfSwKICAgICJleGFtcGxlLmNvbSI6IHsiYXV0aCI6ICJibTl3WlRwdWIzQmwifQogIH0KfQ==
---
# Source: custom-pod/templates/secret.yaml
# Source: secrets/templates/secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: custom-custom-pod
name: custom-secrets
labels:
helm.sh/chart: custom-pod-0.1.0
helm.sh/chart: secrets-0.1.0
app.kubernetes.io/version: "1.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: custom-pod
app.kubernetes.io/name: secrets
app.kubernetes.io/instance: custom
app.kubernetes.io/component: main
type: generic
data:
test: dG90bw==
test2: dG90bzI=
test3: "UW1GemFXTWdKU0Z6S0R4dWFXdytLVHAwYjNSdg=="
10 changes: 8 additions & 2 deletions tests/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ dockerregistry:
password: '1234'

secrets:
test: toto
test2: toto2
test:
value: toto
test2:
value: toto2
test3:
type: basicAuth
username: toto
password: toto
13 changes: 9 additions & 4 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
nameOverride: ''
fullnameOverride: ''
#
#dockerregistry:

dockerregistry: {}
# registry-url:
# email: docker-hub@camptocamp.com
# username: dockerhubc2c
# password: xxx

#secrets:
# key: value
secrets: {}
# key1:
# value: value
# key2:
# type: basicAuth
# username: value
# password: value

0 comments on commit 61e53ec

Please sign in to comment.