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

fix shellcheck in cluster/local #73261

Merged
merged 2 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion cluster/local/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ function prepare-e2e() {
echo "Local doesn't need special preparations for e2e tests" 1>&2
}

# Detect the IP for the master
#
# Vars set:
# KUBE_MASTER
# KUBE_MASTER_IP
# Vars exported:
# KUBE_MASTER_URL
function detect-master {
KUBE_MASTER=localhost
KUBE_MASTER_IP=127.0.0.1
KUBE_MASTER_URL="http://${KUBE_MASTER_IP}:8080"
export KUBE_MASTER_URL="http://${KUBE_MASTER_IP}:8080"
Copy link
Member

Choose a reason for hiding this comment

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

hmm why do we need to export?

Copy link
Member

Choose a reason for hiding this comment

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

IIRC this is sourced and then this env is read by other scripts because :cluster/:. not 100% though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if KUBE_MASTER_URL is needed by other scripts, shellcheck suggest we export it. Otherwise we can remove this env if it's safe.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, hack/ginkgo-e2e.sh should read this env from cluster/loca/util.sh for local provider case like
KUBE_MASTER_URL="${KUBE_MASTER_URL:-https://${KUBE_MASTER_IP:-}}" but it cannot do that at this time and hack/ginkgo-e2e.sh uses a hard-coded default value.
It seems nice to add export for this case.

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment to the above function explaining what it requires, sets and exports? eg:

# Detect the IP for the master
#
# Vars set:
#   KUBE_MASTER
#   KUBE_MASTER_IP
# Vars exported:
#   KUBE_MASTER_URL
function detect-master {

It may seem redundant but it helps us know this is on purpose, and it's the same style used in cluster/gce

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@spiffxp sure, PR updated, PTAL

echo "Using master: $KUBE_MASTER (external IP: $KUBE_MASTER_IP)"
}
1 change: 0 additions & 1 deletion hack/.shellcheck_failures
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
./cluster/kubemark/gce/config-default.sh
./cluster/kubemark/iks/config-default.sh
./cluster/kubemark/util.sh
./cluster/local/util.sh
./cluster/log-dump/log-dump.sh
./cluster/pre-existing/util.sh
./cluster/restore-from-backup.sh
Expand Down