From 2ddea51f2ef08fb8ce617567a82f698745adcc4b Mon Sep 17 00:00:00 2001 From: Mathiyarasy <157102811+Mathiyarasy@users.noreply.github.com> Date: Mon, 2 Jun 2025 13:35:17 +0000 Subject: [PATCH 1/4] Fix issue when version is passed with v --- src/kubectl-helm-minikube/install.sh | 4 ++- .../install_kubectl_with_version.sh | 28 +++++++++++++++++++ .../install_kubectl_without_version.sh | 28 +++++++++++++++++++ test/kubectl-helm-minikube/scenarios.json | 22 ++++++++++++++- 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 test/kubectl-helm-minikube/install_kubectl_with_version.sh create mode 100644 test/kubectl-helm-minikube/install_kubectl_without_version.sh diff --git a/src/kubectl-helm-minikube/install.sh b/src/kubectl-helm-minikube/install.sh index bf6c8f535..9cb1a272c 100755 --- a/src/kubectl-helm-minikube/install.sh +++ b/src/kubectl-helm-minikube/install.sh @@ -54,11 +54,12 @@ fi find_version_from_git_tags() { local variable_name=$1 local requested_version=${!variable_name} + requested_version="${requested_version#v}" if [ "${requested_version}" = "none" ]; then return; fi local repository=$2 local prefix=${3:-"tags/v"} local separator=${4:-"."} - local last_part_optional=${5:-"false"} + local last_part_optional=${5:-"false"} if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then local escaped_separator=${separator//./\\.} local last_part @@ -68,6 +69,7 @@ find_version_from_git_tags() { last_part="${escaped_separator}[0-9]+" fi local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$" + echo "Regex: ${regex}" local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)" if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)" diff --git a/test/kubectl-helm-minikube/install_kubectl_with_version.sh b/test/kubectl-helm-minikube/install_kubectl_with_version.sh new file mode 100644 index 000000000..115374584 --- /dev/null +++ b/test/kubectl-helm-minikube/install_kubectl_with_version.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +set +e + kubectl + exit_code=$? + check "kubectl-is-installed" bash -c "echo ${exit_code} | grep 0" + echo "kubectl version:" + kubectl version --client + + helm version + exit_code=$? + check "helm-is-installed" bash -c "echo ${exit_code} | grep 0" + echo "helm version:" + helm version + + minikube version + exit_code=$? + check "minikube-is-installed" bash -c "echo ${exit_code} | grep 0" + echo "minikube version:" + minikube version +set -e + +# Report result +reportResults \ No newline at end of file diff --git a/test/kubectl-helm-minikube/install_kubectl_without_version.sh b/test/kubectl-helm-minikube/install_kubectl_without_version.sh new file mode 100644 index 000000000..115374584 --- /dev/null +++ b/test/kubectl-helm-minikube/install_kubectl_without_version.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +set +e + kubectl + exit_code=$? + check "kubectl-is-installed" bash -c "echo ${exit_code} | grep 0" + echo "kubectl version:" + kubectl version --client + + helm version + exit_code=$? + check "helm-is-installed" bash -c "echo ${exit_code} | grep 0" + echo "helm version:" + helm version + + minikube version + exit_code=$? + check "minikube-is-installed" bash -c "echo ${exit_code} | grep 0" + echo "minikube version:" + minikube version +set -e + +# Report result +reportResults \ No newline at end of file diff --git a/test/kubectl-helm-minikube/scenarios.json b/test/kubectl-helm-minikube/scenarios.json index b82a9966e..f18ce0756 100644 --- a/test/kubectl-helm-minikube/scenarios.json +++ b/test/kubectl-helm-minikube/scenarios.json @@ -18,5 +18,25 @@ "minikube": "none" } } + }, + "install_kubectl_without_version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "kubectl-helm-minikube": { + "version": "1.30", + "helm": "3.16", + "minikube": "1.28" + } + } + }, + "install_kubectl_with_version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "kubectl-helm-minikube": { + "version": "v1.33.0", + "helm": "v3.17.3", + "minikube": "v1.31.1" + } + } } -} +} \ No newline at end of file From 22c52def0e34fae8813001138921fc4b96871346 Mon Sep 17 00:00:00 2001 From: Mathiyarasy <157102811+Mathiyarasy@users.noreply.github.com> Date: Mon, 2 Jun 2025 13:47:53 +0000 Subject: [PATCH 2/4] remove wcho command --- src/kubectl-helm-minikube/install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/kubectl-helm-minikube/install.sh b/src/kubectl-helm-minikube/install.sh index 9cb1a272c..f0cf1c946 100755 --- a/src/kubectl-helm-minikube/install.sh +++ b/src/kubectl-helm-minikube/install.sh @@ -59,7 +59,7 @@ find_version_from_git_tags() { local repository=$2 local prefix=${3:-"tags/v"} local separator=${4:-"."} - local last_part_optional=${5:-"false"} + local last_part_optional=${5:-"false"} if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then local escaped_separator=${separator//./\\.} local last_part @@ -69,7 +69,6 @@ find_version_from_git_tags() { last_part="${escaped_separator}[0-9]+" fi local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$" - echo "Regex: ${regex}" local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)" if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)" From b8643fd6f800a76945f87c212773b2d8a26fa875 Mon Sep 17 00:00:00 2001 From: Mathiyarasy <157102811+Mathiyarasy@users.noreply.github.com> Date: Tue, 3 Jun 2025 12:46:48 +0000 Subject: [PATCH 3/4] update version --- src/kubectl-helm-minikube/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kubectl-helm-minikube/devcontainer-feature.json b/src/kubectl-helm-minikube/devcontainer-feature.json index 30c621f28..410a909e4 100644 --- a/src/kubectl-helm-minikube/devcontainer-feature.json +++ b/src/kubectl-helm-minikube/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "kubectl-helm-minikube", - "version": "1.2.1", + "version": "1.2.2", "name": "Kubectl, Helm, and Minikube", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/kubectl-helm-minikube", "description": "Installs latest version of kubectl, Helm, and optionally minikube. Auto-detects latest versions and installs needed dependencies.", From d5d5573740c6e7ee20c09c227da2b3e9e1f2b58c Mon Sep 17 00:00:00 2001 From: Mathiyarasy <157102811+Mathiyarasy@users.noreply.github.com> Date: Wed, 4 Jun 2025 10:22:13 +0000 Subject: [PATCH 4/4] update test cases to check for specific versions --- .../install_kubectl_with_version.sh | 21 ++++++++++++------- .../install_kubectl_without_version.sh | 21 ++++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/test/kubectl-helm-minikube/install_kubectl_with_version.sh b/test/kubectl-helm-minikube/install_kubectl_with_version.sh index 115374584..6e0608f59 100644 --- a/test/kubectl-helm-minikube/install_kubectl_with_version.sh +++ b/test/kubectl-helm-minikube/install_kubectl_with_version.sh @@ -4,24 +4,29 @@ set -e # Optional: Import test library source dev-container-features-test-lib +# Define expected versions +KUBECTL_EXPECTED_VERSION="v1.33.0" +HELM_VERSION="v3.17.3" +MINIKUBE_VERSION="v1.31.1" + set +e - kubectl + kubectl version --client --output json | jq -r '.clientVersion.gitVersion' | grep "${KUBECTL_VERSION}" exit_code=$? - check "kubectl-is-installed" bash -c "echo ${exit_code} | grep 0" + check "kubectl-version-${KUBECTL_VERSION}-installed" bash -c "echo ${exit_code} | grep 0" echo "kubectl version:" kubectl version --client - helm version + helm version --short | grep "${HELM_VERSION}" exit_code=$? - check "helm-is-installed" bash -c "echo ${exit_code} | grep 0" + check "helm-version-${HELM_VERSION}-installed" bash -c "echo ${exit_code} | grep 0" echo "helm version:" - helm version + helm version --short - minikube version + minikube version --short | grep "${MINIKUBE_VERSION}" exit_code=$? - check "minikube-is-installed" bash -c "echo ${exit_code} | grep 0" + check "minikube-version-${MINIKUBE_VERSION}-installed" bash -c "echo ${exit_code} | grep 0" echo "minikube version:" - minikube version + minikube version --short set -e # Report result diff --git a/test/kubectl-helm-minikube/install_kubectl_without_version.sh b/test/kubectl-helm-minikube/install_kubectl_without_version.sh index 115374584..8a73ff599 100644 --- a/test/kubectl-helm-minikube/install_kubectl_without_version.sh +++ b/test/kubectl-helm-minikube/install_kubectl_without_version.sh @@ -4,24 +4,29 @@ set -e # Optional: Import test library source dev-container-features-test-lib +# Define expected versions +KUBECTL_EXPECTED_VERSION="1.30" +HELM_VERSION="3.16" +MINIKUBE_VERSION="1.28" + set +e - kubectl + kubectl version --client --output json | jq -r '.clientVersion.gitVersion' | grep "${KUBECTL_VERSION}" exit_code=$? - check "kubectl-is-installed" bash -c "echo ${exit_code} | grep 0" + check "kubectl-version-${KUBECTL_VERSION}-installed" bash -c "echo ${exit_code} | grep 0" echo "kubectl version:" kubectl version --client - helm version + helm version --short | grep "${HELM_VERSION}" exit_code=$? - check "helm-is-installed" bash -c "echo ${exit_code} | grep 0" + check "helm-version-${HELM_VERSION}-installed" bash -c "echo ${exit_code} | grep 0" echo "helm version:" - helm version + helm version --short - minikube version + minikube version --short | grep "${MINIKUBE_VERSION}" exit_code=$? - check "minikube-is-installed" bash -c "echo ${exit_code} | grep 0" + check "minikube-version-${MINIKUBE_VERSION}-installed" bash -c "echo ${exit_code} | grep 0" echo "minikube version:" - minikube version + minikube version --short set -e # Report result