Skip to content

Commit 5409304

Browse files
authored
kubectl version doesn't support vX.Y.Z (#1373)
* Fix issue when version is passed with v * remove wcho command * update version * update test cases to check for specific versions
1 parent 66c73df commit 5409304

File tree

5 files changed

+90
-3
lines changed

5 files changed

+90
-3
lines changed

src/kubectl-helm-minikube/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "kubectl-helm-minikube",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"name": "Kubectl, Helm, and Minikube",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/kubectl-helm-minikube",
66
"description": "Installs latest version of kubectl, Helm, and optionally minikube. Auto-detects latest versions and installs needed dependencies.",

src/kubectl-helm-minikube/install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ fi
5454
find_version_from_git_tags() {
5555
local variable_name=$1
5656
local requested_version=${!variable_name}
57+
requested_version="${requested_version#v}"
5758
if [ "${requested_version}" = "none" ]; then return; fi
5859
local repository=$2
5960
local prefix=${3:-"tags/v"}
6061
local separator=${4:-"."}
61-
local last_part_optional=${5:-"false"}
62+
local last_part_optional=${5:-"false"}
6263
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
6364
local escaped_separator=${separator//./\\.}
6465
local last_part
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library
5+
source dev-container-features-test-lib
6+
7+
# Define expected versions
8+
KUBECTL_EXPECTED_VERSION="v1.33.0"
9+
HELM_VERSION="v3.17.3"
10+
MINIKUBE_VERSION="v1.31.1"
11+
12+
set +e
13+
kubectl version --client --output json | jq -r '.clientVersion.gitVersion' | grep "${KUBECTL_VERSION}"
14+
exit_code=$?
15+
check "kubectl-version-${KUBECTL_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
16+
echo "kubectl version:"
17+
kubectl version --client
18+
19+
helm version --short | grep "${HELM_VERSION}"
20+
exit_code=$?
21+
check "helm-version-${HELM_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
22+
echo "helm version:"
23+
helm version --short
24+
25+
minikube version --short | grep "${MINIKUBE_VERSION}"
26+
exit_code=$?
27+
check "minikube-version-${MINIKUBE_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
28+
echo "minikube version:"
29+
minikube version --short
30+
set -e
31+
32+
# Report result
33+
reportResults
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library
5+
source dev-container-features-test-lib
6+
7+
# Define expected versions
8+
KUBECTL_EXPECTED_VERSION="1.30"
9+
HELM_VERSION="3.16"
10+
MINIKUBE_VERSION="1.28"
11+
12+
set +e
13+
kubectl version --client --output json | jq -r '.clientVersion.gitVersion' | grep "${KUBECTL_VERSION}"
14+
exit_code=$?
15+
check "kubectl-version-${KUBECTL_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
16+
echo "kubectl version:"
17+
kubectl version --client
18+
19+
helm version --short | grep "${HELM_VERSION}"
20+
exit_code=$?
21+
check "helm-version-${HELM_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
22+
echo "helm version:"
23+
helm version --short
24+
25+
minikube version --short | grep "${MINIKUBE_VERSION}"
26+
exit_code=$?
27+
check "minikube-version-${MINIKUBE_VERSION}-installed" bash -c "echo ${exit_code} | grep 0"
28+
echo "minikube version:"
29+
minikube version --short
30+
set -e
31+
32+
# Report result
33+
reportResults

test/kubectl-helm-minikube/scenarios.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,25 @@
1818
"minikube": "none"
1919
}
2020
}
21+
},
22+
"install_kubectl_without_version": {
23+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
24+
"features": {
25+
"kubectl-helm-minikube": {
26+
"version": "1.30",
27+
"helm": "3.16",
28+
"minikube": "1.28"
29+
}
30+
}
31+
},
32+
"install_kubectl_with_version": {
33+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
34+
"features": {
35+
"kubectl-helm-minikube": {
36+
"version": "v1.33.0",
37+
"helm": "v3.17.3",
38+
"minikube": "v1.31.1"
39+
}
40+
}
2141
}
22-
}
42+
}

0 commit comments

Comments
 (0)