Add IsOpenshift flag

This commit is contained in:
waseem
2019-07-04 10:32:17 +02:00
parent 9b48d320be
commit 9f3c8379a6
3 changed files with 8 additions and 4 deletions

View File

@@ -53,7 +53,7 @@ func TestMain(m *testing.M) {
// Perform rolling upgrade on deploymentConfig and create env var upon updating the configmap
func TestControllerUpdatingConfigmapShouldCreateEnvInDeploymentConfig(t *testing.T) {
// Don't run test on non-openshift environment
if !kube.IsOpenshift() {
if !clients.IsOpenshift {
return
}

View File

@@ -67,7 +67,7 @@ func doRollingUpgrade(config util.Config) {
rollingUpgrade(clients, config, GetDaemonSetRollingUpgradeFuncs())
rollingUpgrade(clients, config, GetStatefulSetRollingUpgradeFuncs())
if clients.OpenshiftAppsClient != nil {
if clients.IsOpenshift {
rollingUpgrade(clients, config, GetDeploymentConfigRollingUpgradeFuncs())
}
}

View File

@@ -15,10 +15,12 @@ import (
type Clients struct {
KubernetesClient kubernetes.Interface
OpenshiftAppsClient appsclient.Interface
IsOpenshift bool
}
func GetClients() Clients {
client, err := GetClient()
isOpenshift := true
if err != nil {
logrus.Fatalf("Unable to create Kubernetes client error = %v", err)
}
@@ -26,14 +28,16 @@ func GetClients() Clients {
appsClient, err := GetOpenshiftAppsClient()
if err != nil {
logrus.Warnf("Unable to create Openshift Apps client error = %v", err)
isOpenshift = false
}
return Clients{
KubernetesClient: client,
OpenshiftAppsClient: appsClient,
IsOpenshift: isOpenshift,
}
}
func IsOpenshift() bool {
func isOpenshift() bool {
client, err := GetClient()
if err != nil {
logrus.Fatalf("Unable to create Kubernetes client error = %v", err)
@@ -46,7 +50,7 @@ func IsOpenshift() bool {
}
func GetOpenshiftAppsClient() (*appsclient.Clientset, error) {
if !IsOpenshift() {
if !isOpenshift() {
return nil, errors.New("Not running on Openshift")
}
config, err := getConfig()