mirror of
https://github.com/stakater/Reloader.git
synced 2026-05-05 16:26:41 +00:00
Add IsOpenshift flag
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user