-
Notifications
You must be signed in to change notification settings - Fork 1k
Clean up auto-setup.sh #2516
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
Clean up auto-setup.sh #2516
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I know you asked me to review all these more thoroughly a while ago, so I'm doing it now :)
A few suggestions and one bug.
docker/auto-setup.sh
Outdated
|
||
# === Main database functions === | ||
|
||
validate_db_env() { | ||
if [ "${DB}" == "mysql" ]; then | ||
if [ -z "${MYSQL_SEEDS}" ]; then | ||
if [[ ${DB} == mysql ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: I'd replace an if/elif chain with case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, there are case
in bash.
@@ -2,7 +2,8 @@ | |||
|
|||
set -eu -o pipefail | |||
|
|||
export BIND_ON_IP="${BIND_ON_IP:-$(hostname -i)}" | |||
: "${BIND_ON_IP:=$(hostname -i)}" | |||
export BIND_ON_IP | |||
|
|||
if [[ "${BIND_ON_IP}" =~ ":" ]]; then | |||
# ipv6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
several lines below (github won't let me comment on the right line):
replace for arg in "$@";
with for arg;
I might also convert that into a single for loop containing a case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sequence is important there. I want them to be processed in this sequence no matter on how they are passed in args.
1823775
to
b77d627
Compare
docker/entrypoint.sh
Outdated
@@ -16,12 +16,12 @@ fi | |||
dockerize -template /etc/temporal/config/config_template.yaml:/etc/temporal/config/docker.yaml | |||
|
|||
# Automatically setup Temporal Server (databases, Elasticsearch, default namespace) if "autosetup" is passed as an argument. | |||
for arg in "$@" ; do [[ ${arg} == "autosetup" ]] && /etc/temporal/auto-setup.sh && break ; done | |||
for arg in "$@" ; do [[ ${arg} == autosetup ]] && /etc/temporal/auto-setup.sh && break ; done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could do for arg; do ...
here and next one too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 how I didn't notice it at the first place?
What changed?
Clean up
auto-setup.sh
and other scripts.Why?
For better readability as was suggested by @dnr in #2495.
How did you test it?
Build and run auto-setup docker image locally.
Potential risks
No risks.
Is hotfix candidate?
No.