Skip to content

Commit 495b3fb

Browse files
committed
use IsOpenshitCluster to gate openshift specific capabilities
Signed-off-by: Anand Kumar Singh <anandrkskd@gmail.com>
1 parent 2b77b2b commit 495b3fb

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

cmd/main.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ func main() {
223223
registerComponentOrExit(mgr, argov1beta1api.AddToScheme)
224224

225225
// Setup Scheme for OpenShift Config if available
226+
// Disables default Argo CD instance if the cluster doesn't contain OpenShift config API
226227
var disableDefault bool
227228
disableDefault = strings.ToLower(os.Getenv(common.DisableDefaultInstallEnvVar)) == "true"
228229
if util.IsConfigAPIFound() {
@@ -259,13 +260,17 @@ func main() {
259260
}
260261
}
261262

262-
if err = (&controllers.ReconcileGitopsService{
263-
Client: client,
264-
Scheme: mgr.GetScheme(),
265-
DisableDefaultInstall: disableDefault,
266-
}).SetupWithManager(mgr); err != nil {
267-
setupLog.Error(err, "unable to create controller", "controller", "GitopsService")
268-
os.Exit(1)
263+
if util.IsOpenShiftCluster() {
264+
if err = (&controllers.ReconcileGitopsService{
265+
Client: client,
266+
Scheme: mgr.GetScheme(),
267+
DisableDefaultInstall: disableDefault,
268+
}).SetupWithManager(mgr); err != nil {
269+
setupLog.Error(err, "unable to create controller", "controller", "GitopsService")
270+
os.Exit(1)
271+
}
272+
} else {
273+
setupLog.Info("Non-OpenShift cluster detected, skipping GitopsService controller setup")
269274
}
270275

271276
if util.IsRouteAPIFound() {

controllers/argocd/argocd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func getArgoDexSpec() *argoapp.ArgoCDDexSpec {
9494
}
9595

9696
func getArgoSSOSpec(client client.Client) *argoapp.ArgoCDSSOSpec {
97-
if !util.IsConfigAPIFound() {
97+
if !util.IsOpenShiftCluster() {
9898
log.Info("non-OpenShift cluster detected, skipping SSO/Dex configuration")
9999
return nil
100100
}

controllers/util/util.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ func IsConfigAPIFound() bool {
121121
return configAPIFound
122122
}
123123

124+
// used as a shortcut to check if the cluster is an OpenShift cluster
125+
func IsOpenShiftCluster() bool {
126+
return configAPIFound
127+
}
128+
124129
// verify if the Config.Openshift.io API is found
125130
func verifyConfigAPI() error {
126131
found, err := argoutil.VerifyAPI(configv1.GroupName, configv1.GroupVersion.Version)

0 commit comments

Comments
 (0)