Skip to content

Commit

Permalink
fix: reorder prompts so that cluster exists before checking secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeMac committed Nov 21, 2024
1 parent 9380b6e commit dea28a2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@

set -eo pipefail

read -p "Enter your target gitops repo URL [default: https://github.com/get-glu/gitops-example]: " repository
repository="${repository:-https://github.com/get-glu/gitops-example}"
repository="${repository%.git}"

if kubectl -n glu get secret pipeline 2>&1 >/dev/null; then
token="$(kubectl -n glu get secret pipeline -o jsonpath='{.data.github_password}' | base64 -d)"
else
read -s -p "Enter your GitHub personal access token [default: <empty> (read-only pipeline)]: " token
echo ""
echo "Creating cluster..."
fi

kind create cluster \
--wait 120s \
--config - <<EOF || echo "Cluster already exists"
--config - <<EOF 2>/dev/null || echo "Cluster already exists"
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: glu-gitops-example
Expand All @@ -40,6 +28,20 @@ if ! command -v timoni 2>&1 >/dev/null; then
go install github.com/stefanprodan/timoni/cmd/timoni@latest
fi

echo ""

read -p "Enter your target gitops repo URL [default: https://github.com/get-glu/gitops-example]: " repository
repository="${repository:-https://github.com/get-glu/gitops-example}"
repository="${repository%.git}"

if kubectl -n glu get secret pipeline 2>&1 >/dev/null; then
token="$(kubectl -n glu get secret pipeline -o jsonpath='{.data.github_password}' | base64 -d)"
else
read -s -p "Enter your GitHub personal access token [default: <empty> (read-only pipeline)]: " token
echo ""
echo "Creating cluster..."
fi

CONFIGURATION_REPOSITORY_URL="${repository}" \
CONFIGURATION_REPOSITORY_PASSWORD="${token}" \
timoni bundle apply --kube-context kind-glu-gitops-example -f timoni/flux-aio.cue --runtime-from-env
Expand Down

0 comments on commit dea28a2

Please sign in to comment.