Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit f1daae5

Browse files
author
Michael Sauter
committed
Move secret templates into script
1 parent 01235ee commit f1daae5

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

deploy/basic-auth-secret.yaml.tmpl

Lines changed: 0 additions & 10 deletions
This file was deleted.

deploy/install.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ bitbucket_auth=""
1717
bitbucket_webhook_secret=""
1818
nexus_auth=""
1919
private_cert=""
20+
# Templates
21+
basicAuthSecretTemplate="apiVersion: v1
22+
kind: Secret
23+
metadata:
24+
name: '{{name}}'
25+
labels:
26+
app.kubernetes.io/name: ods-pipeline
27+
stringData:
28+
password: '{{password}}'
29+
username: '{{username}}'
30+
type: kubernetes.io/basic-auth"
31+
opaqueSecretTemplate="apiVersion: v1
32+
kind: Secret
33+
metadata:
34+
name: '{{name}}'
35+
labels:
36+
app.kubernetes.io/name: ods-pipeline
37+
stringData:
38+
secret: '{{password}}'
39+
type: Opaque"
2040

2141
# Check prerequisites.
2242
kubectl_bin=""
@@ -120,7 +140,7 @@ kubectlApplySecret () {
120140
# To avoid forward slashes messing up sed, escape forward slashes first.
121141
# See https://tldp.org/LDP/abs/html/string-manipulation.html.
122142
# shellcheck disable=SC2002
123-
cat "${secretTemplate}" | sed "s/{{name}}/${secretName}/" | sed "s/{{username}}/${username//\//\\/}/" | sed "s/{{password}}/${password//\//\\/}/" | "${kubectl_bin}" -n "${namespace}" apply -f -
143+
echo "${secretTemplate}" | sed "s/{{name}}/${secretName}/" | sed "s/{{username}}/${username//\//\\/}/" | sed "s/{{password}}/${password//\//\\/}/" | "${kubectl_bin}" -n "${namespace}" apply -f -
124144
}
125145

126146
installSecret () {
@@ -216,20 +236,20 @@ if [ "${dry_run}" == "true" ]; then
216236
else
217237
# Bitbucket username is not required as PAT alone is enough.
218238
installSecret "ods-bitbucket-auth" \
219-
"basic-auth-secret.yaml.tmpl" \
239+
"${basicAuthSecretTemplate}" \
220240
"${bitbucket_auth}" \
221241
"Please enter the username of Bitbucket user with write permission." \
222242
"Please enter a personal access token of this Bitbucket user (input will be hidden):"
223243

224244
# Webhook secret is a special case, as we do not want the user to set it.
225245
# No prompts -> password will be auto-generated if not given.
226246
installSecret "ods-bitbucket-webhook" \
227-
"opaque-secret.yaml.tmpl" \
247+
"${opaqueSecretTemplate}" \
228248
"${bitbucket_webhook_secret}" \
229249
"" ""
230250

231251
installSecret "ods-nexus-auth" \
232-
"basic-auth-secret.yaml.tmpl" \
252+
"${basicAuthSecretTemplate}" \
233253
"${nexus_auth}" \
234254
"Please enter the username of a Nexus user with write permission:" \
235255
"Please enter the password of this Nexus user (input will be hidden):"

deploy/opaque-secret.yaml.tmpl

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)