-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sh entrypoint to allow MEMOS_DSN_FILE to load variable from…
… secret (#4236) Add sh entrypoint to allow MEMOS_DSN_FILE to load variable from secret
- Loading branch information
1 parent
7817ad0
commit 82b5c8a
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env sh | ||
|
||
file_env() { | ||
var="$1" | ||
fileVar="${var}_FILE" | ||
|
||
val_var="$(printenv "$var")" | ||
val_fileVar="$(printenv "$fileVar")" | ||
|
||
if [ -n "$val_var" ] && [ -n "$val_fileVar" ]; then | ||
echo "error: both $var and $fileVar are set (but are exclusive)" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ -n "$val_var" ]; then | ||
val="$val_var" | ||
elif [ -n "$val_fileVar" ]; then | ||
val="$(cat "$val_fileVar")" | ||
fi | ||
|
||
export "$var"="$val" | ||
unset "$fileVar" | ||
} | ||
|
||
file_env "MEMOS_DSN" | ||
|
||
exec "$@" |