Skip to content

Commit

Permalink
Merge pull request artemiscloud#142 from gtully/dont_rely_on_detect_o…
Browse files Browse the repository at this point in the history
…penshift_before_auto_detect_start

fix use of detect openshift before auto_detect start
  • Loading branch information
gaohoward committed Feb 9, 2022
2 parents b597dc9 + 7332e2a commit fa30b76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
13 changes: 0 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import (

"github.com/artemiscloud/activemq-artemis-operator/pkg/sdkk8sutil"

"github.com/artemiscloud/activemq-artemis-operator/pkg/resources/environments"
routev1 "github.com/openshift/api/route/v1"

brokerv1alpha1 "github.com/artemiscloud/activemq-artemis-operator/api/v1alpha1"
Expand Down Expand Up @@ -122,18 +121,6 @@ func main() {
os.Exit(1)
}

isOpenshift, err1 := environments.DetectOpenshift()
if err1 != nil {
log.Error(err1, "Failed to get env")
os.Exit(1)
}

if isOpenshift {
log.Info("environment is openshift")
} else {
log.Info("environment is not openshift")
}

printVersion()
oprNameSpace, err := sdkk8sutil.GetOperatorNamespace()
if err != nil {
Expand Down
10 changes: 8 additions & 2 deletions pkg/resources/environments/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,16 @@ func DetectOpenshift() (bool, error) {

// Find out if we're on OpenShift or Kubernetes
stateManager := common.GetStateManager()
openshift, keyExists := stateManager.GetState(common.OpenShiftAPIServerKind).(bool)
isOpenshift, keyExists := stateManager.GetState(common.OpenShiftAPIServerKind).(bool)

if keyExists {
return openshift, nil
if isOpenshift {
log.Info("environment is openshift")
} else {
log.Info("environment is not openshift")
}

return isOpenshift, nil
}
return false, errors.New("environment not yet determined")
}
Expand Down

0 comments on commit fa30b76

Please sign in to comment.