mirror of https://github.com/dexidp/dex.git
Browse Source
Co-authored-by: Márk Sági-Kazár <sagikazarmark@users.noreply.github.com> Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>pull/1893/head
2 changed files with 32 additions and 30 deletions
@ -1,31 +1,32 @@
|
||||
#!/bin/sh -e |
||||
|
||||
### Usage: /docker-entrypoint.sh <command> <args> |
||||
### * If command equals to "serve", config file for serving will be preprocessed using gomplate and saved to tmp dir. |
||||
### Example: docker-entrypoint.sh serve config.yaml = dex serve /tmp/dex-config.yaml-ABCDEFG |
||||
### * If command is not in the list of known dex commands, it will be executed bypassing entrypoint. |
||||
### Example: docker-entrypoint.sh echo "Hello!" = echo "Hello!" |
||||
function main() { |
||||
executable=$1 |
||||
command=$2 |
||||
|
||||
command=$1 |
||||
|
||||
case "$command" in |
||||
serve) |
||||
for file_candidate in $@ ; do |
||||
if test -f "$file_candidate"; then |
||||
tmpfile=$(mktemp /tmp/dex.config.yaml-XXXXXX) |
||||
gomplate -f "$file_candidate" -o "$tmpfile" |
||||
if [[ "$executable" != "dex" ]] && [[ "$executable" != "$(which dex)" ]]; then |
||||
exec $@ |
||||
fi |
||||
|
||||
args="${args} ${tmpfile}" |
||||
else |
||||
args="${args} ${file_candidate}" |
||||
if [[ "$command" != "serve" ]]; then |
||||
exec $@ |
||||
fi |
||||
done |
||||
exec dex $args |
||||
;; |
||||
--help|-h|version) |
||||
exec dex $@ |
||||
|
||||
for tpl_candidate in $@ ; do |
||||
case "$tpl_candidate" in |
||||
*.tpl|*.tmpl|*.yaml) |
||||
tmp_file=$(mktemp /tmp/dex.config.yaml-XXXXXX) |
||||
gomplate -f "$tpl_candidate" -o "$tmp_file" |
||||
|
||||
args="${args} ${tmp_file}" |
||||
;; |
||||
*) |
||||
exec $@ |
||||
args="${args} ${tpl_candidate}" |
||||
;; |
||||
esac |
||||
esac |
||||
done |
||||
exec $args |
||||
} |
||||
|
||||
main $@ |
||||
|
||||
Loading…
Reference in new issue