Skip to content

Commit 287b5e0

Browse files
committed
enhancing KIND support with timer
1 parent df90329 commit 287b5e0

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

install-scripts/kind.sh

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ ensure_helm_repo() {
9797

9898
# Function to check prerequisites
9999
check_prerequisites() {
100-
# List of required commands
101-
REQUIRED_COMMANDS="kind kubectl helm yq"
100+
# List of required commands (removed 'yq')
101+
REQUIRED_COMMANDS="kind kubectl helm"
102102

103103
echo_info "Checking for required tools..."
104104

@@ -139,7 +139,7 @@ select_kind_cluster() {
139139
if [ "$cluster_count" -eq 0 ]; then
140140
# No existing clusters, create a new one
141141
echo_info "No existing Kind clusters found. Creating a new Kind cluster named '$NAMESPACE'."
142-
create_kind_cluster "$NAMESPACE"
142+
run_with_timer create_kind_cluster "$NAMESPACE"
143143
else
144144
# Existing clusters found, prompt user
145145
echo_prompt "Existing Kind clusters detected:"
@@ -165,7 +165,7 @@ select_kind_cluster() {
165165
* )
166166
# Create a new cluster
167167
echo_info "Creating a new Kind cluster named '$NAMESPACE'."
168-
create_kind_cluster "$NAMESPACE"
168+
run_with_timer create_kind_cluster "$NAMESPACE"
169169
;;
170170
esac
171171
fi
@@ -208,6 +208,26 @@ check_pods_and_jobs() {
208208
exit 1
209209
}
210210

211+
# -----------------------------
212+
# Timer Function
213+
# -----------------------------
214+
215+
run_with_timer() {
216+
start_time=$(date +%s) # Start time in seconds
217+
218+
# Execute the command passed as arguments
219+
"$@"
220+
221+
end_time=$(date +%s) # End time in seconds
222+
elapsed_time=$((end_time - start_time)) # Calculate elapsed time in seconds
223+
224+
# Convert elapsed time to minutes and seconds
225+
mins=$((elapsed_time / 60))
226+
secs=$((elapsed_time % 60))
227+
228+
echo "Completed in ${mins} mins ${secs} secs"
229+
}
230+
211231
# -----------------------------
212232
# Port-Forwarding Function
213233
# -----------------------------
@@ -262,9 +282,9 @@ check_prerequisites
262282
# Handle Kind clusters
263283
select_kind_cluster
264284

265-
# Step 1: Install the 'opengovernance' chart into the specified namespace
285+
# Step 1: Install the 'opengovernance' chart into the specified namespace with timing
266286
echo_primary "Installing 'opengovernance' Helm chart into namespace '$NAMESPACE'."
267-
helm_install_with_timeout -n "$NAMESPACE" opengovernance opengovernance/opengovernance --create-namespace || { echo_error "Helm installation failed."; exit 1; }
287+
run_with_timer helm_install_with_timeout -n "$NAMESPACE" opengovernance opengovernance/opengovernance --create-namespace || { echo_error "Helm installation failed."; exit 1; }
268288

269289
# Step 2: Check if the application is ready
270290
check_pods_and_jobs

0 commit comments

Comments
 (0)