@@ -23,12 +23,41 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
2323{ {- end -} }
2424{ {- end -} }
2525
26+ { {- define " docker-registry.secretName" -} }
27+ { {- if .Values.secrets.existingSecret } }
28+ { {- .Values.secrets.existingSecret } }
29+ { {- else } }
30+ { {- template " docker-registry.fullname" . } }-secret
31+ { {- end } }
32+ { {- end } }
33+
34+ { {- define " docker-registry.azureSecretName" -} }
35+ { {- if .Values.secrets.azure.existingSecret } }
36+ { {- .Values.secrets.azure.secretRef } }
37+ { {- else } }
38+ { {- template " docker-registry.fullname" . } }-secret
39+ { {- end } }
40+ { {- end } }
41+
42+ { {- define " docker-registry.swiftSecretName" -} }
43+ { {- if .Values.secrets.swift.existingSecret } }
44+ { {- .Values.secrets.swift.secretRef } }
45+ { {- else } }
46+ { {- template " docker-registry.fullname" . } }-secret
47+ { {- end } }
48+ { {- end } }
49+
2650{ {- define " docker-registry.envs" -} }
2751- name: REGISTRY_HTTP_SECRET
2852 valueFrom:
2953 secretKeyRef:
30- name: { { template " docker-registry.fullname" . } }-secret
54+ name: { { template " docker-registry.secretName" . } }
55+ { {- if and .Values.secrets.haSharedSecretKey .Values.secrets.existingSecret } }
56+ key: { {- .Values.secrets.haSharedSecretKey } }
57+ { {- else } }
3158 key: haSharedSecret
59+ { {- end } }
60+ { {- end } }
3261
3362{ {- if .Values.secrets.htpasswd } }
3463- name: REGISTRY_AUTH
@@ -53,18 +82,30 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
5382- name: REGISTRY_STORAGE_AZURE_ACCOUNTNAME
5483 valueFrom:
5584 secretKeyRef:
56- name: { { template " docker-registry.fullname" . } }-secret
85+ name: { { template " docker-registry.azureSecretName" . } }
86+ { {- if and .Values.secrets.azure.azureAccountNameKey .Values.secrets.azure.existingSecret } }
87+ key: { {- .Values.secrets.azure.accountNameKey } }
88+ { {- else } }
5789 key: azureAccountName
90+ { {- end } }
5891- name: REGISTRY_STORAGE_AZURE_ACCOUNTKEY
5992 valueFrom:
6093 secretKeyRef:
61- name: { { template " docker-registry.fullname" . } }-secret
94+ name: { { template " docker-registry.azureSecretName" . } }
95+ { {- if and .Values.secrets.azure.azureAccountNameKey .Values.secrets.azure.existingSecret } }
96+ key: { {- .Values.secrets.azure.accountKeyKey } }
97+ { {- else } }
6298 key: azureAccountKey
99+ { {- end } }
63100- name: REGISTRY_STORAGE_AZURE_CONTAINER
64101 valueFrom:
65102 secretKeyRef:
66- name: { { template " docker-registry.fullname" . } }-secret
103+ name: { { template " docker-registry.azureSecretName" . } }
104+ { {- if and .Values.secrets.azure.containerKey .Values.secrets.azure.existingSecret } }
105+ key: { {- .Values.secrets.azure.containerKey } }
106+ { {- else } }
67107 key: azureContainer
108+ { {- end } }
68109{ {- else if eq .Values.storage " s3" } }
69110- name: REGISTRY_STORAGE_S3_REGION
70111 value: { { required " .Values.s3.region is required" .Values.s3.region } }
@@ -74,12 +115,12 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
74115- name: REGISTRY_STORAGE_S3_ACCESSKEY
75116 valueFrom:
76117 secretKeyRef:
77- name: { { if .Values.secrets.s3.secretRef } }{ { .Values.secrets.s3.secretRef } }{ { else } }{ { template " docker-registry.fullname " . } }-secret { { end } }
118+ name: { { if .Values.secrets.s3.secretRef } }{ { .Values.secrets.s3.secretRef } }{ { else } }{ { template " docker-registry.secretName " . } }{ { end } }
78119 key: s3AccessKey
79120- name: REGISTRY_STORAGE_S3_SECRETKEY
80121 valueFrom:
81122 secretKeyRef:
82- name: { { if .Values.secrets.s3.secretRef } }{ { .Values.secrets.s3.secretRef } }{ { else } }{ { template " docker-registry.fullname " . } }-secret { { end } }
123+ name: { { if .Values.secrets.s3.secretRef } }{ { .Values.secrets.s3.secretRef } }{ { else } }{ { template " docker-registry.secretName " . } }{ { end } }
83124 key: s3SecretKey
84125{ {- end -} }
85126
@@ -119,13 +160,21 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
119160- name: REGISTRY_STORAGE_SWIFT_USERNAME
120161 valueFrom:
121162 secretKeyRef:
122- name: { { template " docker-registry.fullname" . } }-secret
163+ name: { { template " docker-registry.swiftSecretName" . } }
164+ { {- if and .Values.secrets.swift.usernameKey .Values.secrets.swift.secretRef -} }
165+ key: { {- .Values.secrets.swift.usernameKey -} }
166+ { {- else -} }
123167 key: swiftUsername
168+ { {- end -} }
124169- name: REGISTRY_STORAGE_SWIFT_PASSWORD
125170 valueFrom:
126171 secretKeyRef:
127- name: { { template " docker-registry.fullname" . } }-secret
172+ name: { { template " docker-registry.swiftSecretName" . } }
173+ { {- if and .Values.secrets.swift.passwordKey .Values.secrets.swift.secretRef -} }
174+ key: { {- .Values.secrets.swift.passwordKey -} }
175+ { {- else -} }
128176 key: swiftPassword
177+ { {- end -} }
129178- name: REGISTRY_STORAGE_SWIFT_CONTAINER
130179 value: { { required " .Values.swift.container is required" .Values.swift.container } }
131180{ {- end -} }
@@ -136,13 +185,21 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
136185- name: REGISTRY_PROXY_USERNAME
137186 valueFrom:
138187 secretKeyRef:
139- name: { { if .Values.proxy.secretRef } }{ { .Values.proxy.secretRef } }{ { else } }{ { template " docker-registry.fullname" . } }-secret{ { end } }
188+ name: { { if .Values.proxy.secretRef } }{ { .Values.proxy.secretRef } }{ { else } }{ { template " docker-registry.secretName" . } }{ { end } }
189+ { {- if and .Values.proxy.proxyUsernameKey .Values.proxy.secretRef -} }
190+ key: { {- .Values.proxy.proxyUsernameKey -} }
191+ { {- else -} }
140192 key: proxyUsername
193+ { {- end -} }
141194- name: REGISTRY_PROXY_PASSWORD
142195 valueFrom:
143196 secretKeyRef:
144- name: { { if .Values.proxy.secretRef } }{ { .Values.proxy.secretRef } }{ { else } }{ { template " docker-registry.fullname" . } }-secret{ { end } }
197+ name: { { if .Values.proxy.secretRef } }{ { .Values.proxy.secretRef } }{ { else } }{ { template " docker-registry.secretName" . } }{ { end } }
198+ { {- if and .Values.proxy.proxyPasswordKey .Values.proxy.secretRef -} }
199+ key: { {- .Values.proxy.proxyPasswordKey -} }
200+ { {- else -} }
145201 key: proxyPassword
202+ { {- end -} }
146203{ {- end -} }
147204
148205{ {- if .Values.persistence.deleteEnabled } }
@@ -154,8 +211,6 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
154211{ { toYaml . } }
155212{ {- end -} }
156213
157- { {- end -} }
158-
159214{ {- define " docker-registry.volumeMounts" -} }
160215- name: "{ { template " docker-registry.fullname" . } }-config"
161216 mountPath: { { .Values.configPath } }
@@ -191,10 +246,15 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
191246{ {- if .Values.secrets.htpasswd } }
192247- name: auth
193248 secret:
194- secretName: { { template " docker-registry.fullname " . } }-secret
249+ secretName: { { template " docker-registry.secretName " . } }
195250 items:
251+ { {- if and .Values.secrets.htpasswdKey .Values.secrets.existingSecret } }
252+ - key: { {- .Values.secrets.htpasswdKey } }
253+ path: htpasswd
254+ { {- else } }
196255 - key: htpasswd
197256 path: htpasswd
257+ { {- end } }
198258{ {- end } }
199259
200260{ {- if eq .Values.storage " filesystem" } }
0 commit comments