Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mariadb): Add support for reading password from file #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions runmariadb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

set -eu

if [[ -z "${MARIADB_PASSWORD:-}" ]]; then
echo "FATAL: Missing database password, set the MARIADB_PASSWORD variable"
exit 1
PASSWORD_FILE="/run/secrets/mariadb-password" # Specify the password file location
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update README with the new feature?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious if the file should be just password, so that standard Kubernetes secrets could be mounted to /run/secrets.


if [ -f "$PASSWORD_FILE" ]; then
# Password file exists, read from it
MARIADB_PASSWORD=$(cat "$PASSWORD_FILE")
echo "Using password from file"
elif [ -n "$MARIADB_PASSWORD" ]; then
# Password file doesn't exist, but environment variable is set, use it
echo "Using MARIADB_PASSWORD from environment variable"
else
# Neither file nor environment variable exists, handle the error
echo "FATAL: MARIADB_PASSWORD not found in file or environment variable"
exit 1
fi

set -x
Expand Down