From 06bb0d2f08cb9b30db9cb6ffb08360b2c2351949 Mon Sep 17 00:00:00 2001 From: Yuan Gao Date: Mon, 10 Aug 2026 10:30:23 -0700 Subject: [PATCH] hack: add --help to create-kind-cluster.sh and fix a bashism The script is configured entirely through the environment, which was only discoverable by reading it. Add a usage block that names the variables and exits before touching Docker. Also switch the registry's running check from `==` to `=`; the latter is the POSIX test operator and the rest of the script already uses it. --- hack/create-kind-cluster.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hack/create-kind-cluster.sh b/hack/create-kind-cluster.sh index 26548f2b4..96772894a 100755 --- a/hack/create-kind-cluster.sh +++ b/hack/create-kind-cluster.sh @@ -21,11 +21,24 @@ KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}" reg_name="kind-registry" reg_port="5001" +if [ "$#" -gt 0 ]; then + case "$1" in + -h|--help) + echo "Usage: $0" + echo "Creates the kind cluster '${KIND_CLUSTER_NAME}' and a local registry container on port ${reg_port}." + echo + echo "Configured through the environment:" + echo " KIND_CLUSTER_NAME Name of the cluster to create (default: kind)." + exit 0 + ;; + esac +fi + mkdir -p "${ROOT}/bin" # 1. Create registry container unless it already exists echo "Setting up local docker registry '${reg_name}' on port ${reg_port}..." -if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" == "true" ]; then +if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" = "true" ]; then if ! docker port "${reg_name}" | grep -q "${reg_port}"; then echo "Registry exists but is not mapped to port ${reg_port}. Recreating..." docker rm -f "${reg_name}"