8000 Clean up auto-setup.sh by alexshtin · Pull Request #2516 · temporalio/temporal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 4 commits into from
Feb 18, 2022

Conversation

alexshtin
Copy link
Contributor
@alexshtin alexshtin commented Feb 17, 2022

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.

@alexshtin alexshtin requested a review from a team as a code owner February 17, 2022 06:19
@alexshtin alexshtin requested a review from dnr February 17, 2022 06:21
Copy link
Member
@dnr dnr left a 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.


# === Main database functions ===

validate_db_env() {
if [ "${DB}" == "mysql" ]; then
if [ -z "${MYSQL_SEEDS}" ]; then
if [[ ${DB} == mysql ]]; then
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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

Copy link
Contributor Author

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.

@alexshtin alexshtin force-pushed the feature/improve-auto-setup branch from 1823775 to b77d627 Compare February 18, 2022 05:43
@alexshtin
Copy link
Contributor Author

image

@@ -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
Copy link
Member

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

Copy link
Contributor Author

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?

@alexshtin alexshtin enabled auto-merge (squash) February 18, 2022 18:58
@alexshtin alexshtin merged commit faa1dc1 into temporalio:master Feb 18, 2022
@alexshtin alexshtin deleted the feature/improve-auto-setup branch March 29, 2022 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
0