-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check kubernetes server version from within the test
Thus we simplify e2e tests setup Co-authored-by: Danail Branekov <[email protected]> Co-authored-by: Georgi Sabev <[email protected]>
- Loading branch information
1 parent
a426011
commit 85e5026
Showing
4 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package helpers | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
. "github.com/onsi/ginkgo/v2" //lint:ignore ST1001 this is a test file | ||
. "github.com/onsi/gomega" //lint:ignore ST1001 this is a test file | ||
"k8s.io/client-go/kubernetes" | ||
controllerruntime "sigs.k8s.io/controller-runtime" | ||
) | ||
|
||
func getClientSet() *kubernetes.Clientset { | ||
GinkgoHelper() | ||
|
||
config, err := controllerruntime.GetConfig() | ||
Expect(err).NotTo(HaveOccurred()) | ||
clientSet, err := kubernetes.NewForConfig(config) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
return clientSet | ||
} | ||
|
||
func GetClusterVersion() (int, int) { | ||
GinkgoHelper() | ||
|
||
serverVersion, err := getClientSet().ServerVersion() | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
majorVersion, err := strconv.Atoi(serverVersion.Major) | ||
if err != nil { | ||
Skip(fmt.Sprintf("cannot determine kubernetes server major version: %v", err)) | ||
} | ||
|
||
minorVersion, err := strconv.Atoi(serverVersion.Minor) | ||
if err != nil { | ||
Skip(fmt.Sprintf("cannot determine kubernetes server minor version: %v", err)) | ||
} | ||
|
||
return majorVersion, minorVersion | ||
} |