Skip to content

Commit

Permalink
test/helpers: fix ensure kubectl version to work for RCs
Browse files Browse the repository at this point in the history
Fixes: 6181255 ("test: ensure kubectl version is available for test run")
Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm committed Nov 26, 2021
1 parent 9791902 commit 244cd8b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/helpers/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func CreateKubectl(vmName string, log *logrus.Entry) (k *Kubectl) {
}
k.setBasePath()
if err := k.ensureKubectlVersion(); err != nil {
ginkgoext.Failf("failed to ensure kubectl version")
ginkgoext.Failf("failed to ensure kubectl version: %s", err)
}
}

Expand Down Expand Up @@ -4449,8 +4449,9 @@ func (kub *Kubectl) ensureKubectlVersion() error {
//check current kubectl version
type Version struct {
ClientVersion struct {
Major string `json:"major"`
Minor string `json:"minor"`
Major string `json:"major"`
Minor string `json:"minor"`
GitVersion string `json:"gitVersion"`
} `json:"clientVersion"`
}
res := kub.ExecShort(fmt.Sprintf("%s version --client -o json", KubectlCmd))
Expand All @@ -4477,8 +4478,8 @@ func (kub *Kubectl) ensureKubectlVersion() error {
}
path := path.Join(GetKubectlPath(), "kubectl")
res = kub.Exec(
fmt.Sprintf("curl --output %s https://storage.googleapis.com/kubernetes-release/release/v%s.0/bin/linux/amd64/kubectl && chmod +x %s",
path, GetCurrentK8SEnv(), path))
fmt.Sprintf("curl --output %s https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/amd64/kubectl && chmod +x %s",
path, v.ClientVersion.GitVersion, path))
if !res.WasSuccessful() {
return fmt.Errorf("failed to download kubectl")
}
Expand Down

0 comments on commit 244cd8b

Please sign in to comment.