From dfc9bdaf0371fb5760525f8dc5cd6d42d23e7cde Mon Sep 17 00:00:00 2001 From: Praveen M Date: Fri, 20 Dec 2024 11:14:51 +0530 Subject: [PATCH] ci: address shadowing of predeclared identifier - Comparing integers makes more sense than comparing the strings. Signed-off-by: Praveen M --- e2e/utils.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/e2e/utils.go b/e2e/utils.go index d0319aa2f..608f6e600 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -1580,10 +1580,17 @@ func k8sVersionGreaterEquals(c kubernetes.Interface, major, minor int) bool { // return value. } - maj := strconv.Itoa(major) - min := strconv.Itoa(minor) + vMajor, err := strconv.Atoi(v.Major) + if err != nil { + framework.Failf("failed to convert Kubernetes major version %q to int: %v", v.Major, err) + } - return (v.Major > maj) || (v.Major == maj && v.Minor >= min) + vMinor, err := strconv.Atoi(v.Minor) + if err != nil { + framework.Failf("failed to convert Kubernetes minor version %q to int: %v", v.Minor, err) + } + + return (vMajor > major) || (vMajor == major && vMinor >= minor) } // waitForJobCompletion polls the status of the given job and waits until the