Skip to content

Commit 0c6b89c

Browse files
Copilotabdurriq
andcommitted
Improve error messages and diagnostics for kubectl version fetching
Co-authored-by: abdurriq <[email protected]>
1 parent 6b69e33 commit 0c6b89c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/kubectl-helm-minikube/install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ if [ ${KUBECTL_VERSION} != "none" ]; then
154154
# Install the kubectl, verify checksum
155155
echo "Downloading kubectl..."
156156
if [ "${KUBECTL_VERSION}" = "latest" ] || [ "${KUBECTL_VERSION}" = "lts" ] || [ "${KUBECTL_VERSION}" = "current" ] || [ "${KUBECTL_VERSION}" = "stable" ]; then
157-
KUBECTL_VERSION="$(curl -fsSL --connect-timeout 10 --max-time 30 https://dl.k8s.io/release/stable.txt 2>/dev/null || echo "")"
157+
KUBECTL_VERSION="$(curl -fsSL --connect-timeout 10 --max-time 30 https://dl.k8s.io/release/stable.txt 2>&1 | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' || echo "")"
158158
if [ -z "${KUBECTL_VERSION}" ]; then
159-
echo "(!) Failed to fetch kubectl stable version, falling back to version discovery via git tags"
159+
echo "(!) Failed to fetch kubectl stable version from dl.k8s.io, falling back to version discovery via git tags"
160160
find_version_from_git_tags KUBECTL_VERSION https://github.com/kubernetes/kubernetes
161161
fi
162162
else
163163
find_version_from_git_tags KUBECTL_VERSION https://github.com/kubernetes/kubernetes
164164
fi
165165
if [ -z "${KUBECTL_VERSION}" ] || [ "${KUBECTL_VERSION}" = "none" ]; then
166-
echo "(!) Failed to determine kubectl version"
166+
echo "(!) Failed to determine kubectl version. Check network connectivity or specify an explicit version."
167167
exit 1
168168
fi
169169
if [ "${KUBECTL_VERSION::1}" != 'v' ]; then

0 commit comments

Comments
 (0)