Skip to content

Commit a7ec25a

Browse files
bin: update prompt
1 parent 2d6adff commit a7ec25a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

bin/common.bash

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ log_error() {
7979
log_error_no_newline "${*}\n"
8080
}
8181

82+
log_fatal() {
83+
log_error "${*}"
84+
exit 1
85+
}
86+
87+
log_continue() {
88+
if [[ "${CK8S_AUTO_APPROVE:-false}" != "true" ]]; then
89+
log_warning_no_newline "${1} [y/N]: "
90+
91+
read -r reply
92+
if ! [[ "${reply}" =~ ^(y|Y|yes|Yes|YES)$ ]]; then
93+
log_fatal "aborted"
94+
fi
95+
fi
96+
}
97+
8298
# Checks that all dependencies are available and critical ones for matching minor version.
8399
check_tools() {
84100
local req
@@ -294,11 +310,7 @@ check_openstack_credentials() {
294310
log_warning "If you are not running on openstack, then you can safely ignore this."
295311
fi
296312

297-
log_info_no_newline "Proceed with the current credentials [y/N]: "
298-
read -r reply
299-
if [[ "${reply}" != "y" ]]; then
300-
exit 1
301-
fi
313+
log_continue "Continue with the current credentials?"
302314
}
303315

304316
# Compares the expected and actual git state of the kubespray submodule.
@@ -317,13 +329,7 @@ kubespray_version_check() {
317329

318330
log_info "The status of the kubespray git submodule differs from the expected status, either it is on another commit or there are file changes. This can cause unexpected versions to be installed or cause other errors. We recommend that you stop and check what has changed."
319331
log_info "Expected" "${expected_commit}", "got" "${current_commit}".
320-
log_info_no_newline "Do you want to abort? (Y/n): "
321-
322-
read -r reply
323-
324-
if [[ "${reply}" != "n" ]]; then
325-
exit 1
326-
fi
332+
log_continue "Do you want to continue?"
327333
fi
328334
}
329335

0 commit comments

Comments
 (0)