@@ -8,102 +8,102 @@ set -euo pipefail
88CLUSTER_NAME=" ${KIND_CLUSTER_NAME:- logstream-integration-test} "
99
1010usage () {
11- echo " Usage: $0 [create|delete|status]"
12- echo " "
13- echo " Commands:"
14- echo " create - Create a KinD cluster for integration tests"
15- echo " delete - Delete the KinD cluster"
16- echo " status - Check if the cluster exists and is running"
17- echo " "
18- echo " Environment variables:"
19- echo " KIND_CLUSTER_NAME - Name of the cluster (default: logstream-integration-test)"
20- exit 1
11+ echo " Usage: $0 [create|delete|status]"
12+ echo " "
13+ echo " Commands:"
14+ echo " create - Create a KinD cluster for integration tests"
15+ echo " delete - Delete the KinD cluster"
16+ echo " status - Check if the cluster exists and is running"
17+ echo " "
18+ echo " Environment variables:"
19+ echo " KIND_CLUSTER_NAME - Name of the cluster (default: logstream-integration-test)"
20+ exit 1
2121}
2222
2323check_kind () {
24- if ! command -v kind & > /dev/null; then
25- echo " Error: 'kind' is not installed."
26- echo " Install it from: https://kind.sigs.k8s.io/docs/user/quick-start/#installation"
27- exit 1
28- fi
24+ if ! command -v kind & > /dev/null; then
25+ echo " Error: 'kind' is not installed."
26+ echo " Install it from: https://kind.sigs.k8s.io/docs/user/quick-start/#installation"
27+ exit 1
28+ fi
2929}
3030
3131check_kubectl () {
32- if ! command -v kubectl & > /dev/null; then
33- echo " Error: 'kubectl' is not installed."
34- echo " Install it from: https://kubernetes.io/docs/tasks/tools/"
35- exit 1
36- fi
32+ if ! command -v kubectl & > /dev/null; then
33+ echo " Error: 'kubectl' is not installed."
34+ echo " Install it from: https://kubernetes.io/docs/tasks/tools/"
35+ exit 1
36+ fi
3737}
3838
3939cluster_exists () {
40- kind get clusters 2> /dev/null | grep -q " ^${CLUSTER_NAME} $"
40+ kind get clusters 2> /dev/null | grep -q " ^${CLUSTER_NAME} $"
4141}
4242
4343create_cluster () {
44- check_kind
45- check_kubectl
46-
47- if cluster_exists; then
48- echo " Cluster '${CLUSTER_NAME} ' already exists."
49- echo " Use '$0 delete' to remove it first, or '$0 status' to check its status."
50- exit 0
51- fi
52-
53- echo " Creating KinD cluster '${CLUSTER_NAME} '..."
54- kind create cluster --name " ${CLUSTER_NAME} " --wait 60s
55-
56- echo " "
57- echo " Cluster created successfully!"
58- echo " "
59- echo " To run integration tests:"
60- echo " go test -tags=integration -v ./..."
61- echo " "
62- echo " To delete the cluster when done:"
63- echo " $0 delete"
44+ check_kind
45+ check_kubectl
46+
47+ if cluster_exists; then
48+ echo " Cluster '${CLUSTER_NAME} ' already exists."
49+ echo " Use '$0 delete' to remove it first, or '$0 status' to check its status."
50+ exit 0
51+ fi
52+
53+ echo " Creating KinD cluster '${CLUSTER_NAME} '..."
54+ kind create cluster --name " ${CLUSTER_NAME} " --wait 60s
55+
56+ echo " "
57+ echo " Cluster created successfully!"
58+ echo " "
59+ echo " To run integration tests:"
60+ echo " go test -tags=integration -v ./..."
61+ echo " "
62+ echo " To delete the cluster when done:"
63+ echo " $0 delete"
6464}
6565
6666delete_cluster () {
67- check_kind
67+ check_kind
6868
69- if ! cluster_exists; then
70- echo " Cluster '${CLUSTER_NAME} ' does not exist."
71- exit 0
72- fi
69+ if ! cluster_exists; then
70+ echo " Cluster '${CLUSTER_NAME} ' does not exist."
71+ exit 0
72+ fi
7373
74- echo " Deleting KinD cluster '${CLUSTER_NAME} '..."
75- kind delete cluster --name " ${CLUSTER_NAME} "
76- echo " Cluster deleted successfully!"
74+ echo " Deleting KinD cluster '${CLUSTER_NAME} '..."
75+ kind delete cluster --name " ${CLUSTER_NAME} "
76+ echo " Cluster deleted successfully!"
7777}
7878
7979status_cluster () {
80- check_kind
81-
82- if cluster_exists; then
83- echo " Cluster '${CLUSTER_NAME} ' exists."
84- echo " "
85- echo " Cluster info:"
86- kubectl cluster-info --context " kind-${CLUSTER_NAME} " 2> /dev/null || echo " (unable to get cluster info)"
87- echo " "
88- echo " Nodes:"
89- kubectl get nodes --context " kind-${CLUSTER_NAME} " 2> /dev/null || echo " (unable to get nodes)"
90- else
91- echo " Cluster '${CLUSTER_NAME} ' does not exist."
92- echo " Use '$0 create' to create it."
93- fi
80+ check_kind
81+
82+ if cluster_exists; then
83+ echo " Cluster '${CLUSTER_NAME} ' exists."
84+ echo " "
85+ echo " Cluster info:"
86+ kubectl cluster-info --context " kind-${CLUSTER_NAME} " 2> /dev/null || echo " (unable to get cluster info)"
87+ echo " "
88+ echo " Nodes:"
89+ kubectl get nodes --context " kind-${CLUSTER_NAME} " 2> /dev/null || echo " (unable to get nodes)"
90+ else
91+ echo " Cluster '${CLUSTER_NAME} ' does not exist."
92+ echo " Use '$0 create' to create it."
93+ fi
9494}
9595
9696case " ${1:- } " in
97- create)
98- create_cluster
99- ;;
100- delete)
101- delete_cluster
102- ;;
103- status)
104- status_cluster
105- ;;
106- * )
107- usage
108- ;;
97+ create)
98+ create_cluster
99+ ;;
100+ delete)
101+ delete_cluster
102+ ;;
103+ status)
104+ status_cluster
105+ ;;
106+ * )
107+ usage
108+ ;;
109109esac
0 commit comments