Skip to content

Commit cb69387

Browse files
committed
refactor: readability improvements on generated data file
1 parent c190589 commit cb69387

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

app/letsencrypt_service_data.tmpl

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
#!/bin/bash
2+
# shellcheck disable=SC2034
13
LETSENCRYPT_CONTAINERS=(
2-
{{ $orderedContainers := sortObjectsByKeysDesc $ "Created" }}
3-
{{ range $_, $container := whereExist $orderedContainers "Env.LETSENCRYPT_HOST" }}
4-
{{ if trim $container.Env.LETSENCRYPT_HOST }}
5-
{{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
6-
{{/* Explicit per-domain splitting of the certificate */}}
7-
{{ range $host := split $container.Env.LETSENCRYPT_HOST "," }}
8-
{{ $host := trim $host }}
9-
'{{ printf "%.12s" $container.ID }}_{{ sha1 $host }}'
10-
{{ end }}
11-
{{ else }}
12-
{{/* Default: multi-domain (SAN) certificate */}}
13-
{{- "\t"}}'{{ printf "%.12s" $container.ID }}'
4+
{{ $orderedContainers := sortObjectsByKeysDesc $ "Created" }}
5+
{{ range $_, $container := whereExist $orderedContainers "Env.LETSENCRYPT_HOST" }}
6+
{{ if trim $container.Env.LETSENCRYPT_HOST }}
7+
{{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
8+
{{/* Explicit per-domain splitting of the certificate */}}
9+
{{ range $host := split $container.Env.LETSENCRYPT_HOST "," }}
10+
{{ $host := trim $host }}
11+
{{- "\n " }}'{{ printf "%.12s" $container.ID }}_{{ sha1 $host }}' # {{ $container.Name }}, created at {{ $container.Created }}
1412
{{ end }}
13+
{{ else }}
14+
{{/* Default: multi-domain (SAN) certificate */}}
15+
{{- "\n " }}'{{ printf "%.12s" $container.ID }}' # {{ $container.Name }}, created at {{ $container.Created }}
1516
{{ end }}
1617
{{ end }}
18+
{{ end }}
1719
)
1820

1921
{{ range $hosts, $containers := groupBy $ "Env.LETSENCRYPT_HOST" }}
@@ -33,6 +35,7 @@ LETSENCRYPT_CONTAINERS=(
3335
{{ $PRE_HOOK := trim (coalesce $container.Env.ACME_PRE_HOOK "") }}
3436
{{ $POST_HOOK := trim (coalesce $container.Env.ACME_POST_HOOK "") }}
3537
{{ $cid := printf "%.12s" $container.ID }}
38+
{{- "\n" }}# Container {{ $cid }} ({{ $container.Name }})
3639
{{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
3740
{{/* Explicit per-domain splitting of the certificate */}}
3841
{{ range $host := split $hosts "," }}

0 commit comments

Comments
 (0)