Skip to content

Commit 00b53d8

Browse files
committed
add proper logs, remove deadcode, fix test
assisted-by: Cursor for code-review Signed-off-by: Anand Kumar Singh <anandrkskd@gmail.com>
1 parent 495b3fb commit 00b53d8

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

cmd/main.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,9 @@ func main() {
224224

225225
// Setup Scheme for OpenShift Config if available
226226
// Disables default Argo CD instance if the cluster doesn't contain OpenShift config API
227-
var disableDefault bool
228-
disableDefault = strings.ToLower(os.Getenv(common.DisableDefaultInstallEnvVar)) == "true"
227+
229228
if util.IsConfigAPIFound() {
230229
registerComponentOrExit(mgr, configv1.AddToScheme)
231-
} else {
232-
setupLog.Info("Non-OpenShift cluster detected, disabling default Argo CD instance")
233-
disableDefault = true
234230
}
235231

236232
registerComponentOrExit(mgr, rolloutManagerApi.AddToScheme)
@@ -264,13 +260,14 @@ func main() {
264260
if err = (&controllers.ReconcileGitopsService{
265261
Client: client,
266262
Scheme: mgr.GetScheme(),
267-
DisableDefaultInstall: disableDefault,
263+
DisableDefaultInstall: strings.ToLower(os.Getenv(common.DisableDefaultInstallEnvVar)) == "true",
268264
}).SetupWithManager(mgr); err != nil {
269265
setupLog.Error(err, "unable to create controller", "controller", "GitopsService")
270266
os.Exit(1)
271267
}
272268
} else {
273-
setupLog.Info("Non-OpenShift cluster detected, skipping GitopsService controller setup")
269+
setupLog.Info("skipping GitopsService controller setup", "reason", "OpenShift Config API not available")
270+
274271
}
275272

276273
if util.IsRouteAPIFound() {

controllers/argocd/argocd_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func TestDexConfiguration(t *testing.T) {
233233

234234
func TestSSOSkippedOnNonOpenShift(t *testing.T) {
235235
util.SetConfigAPIFound(false)
236+
defer util.SetConfigAPIFound(true)
236237

237238
scheme := runtime.NewScheme()
238239
_ = argoapp.AddToScheme(scheme)

controllers/util/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ func InspectCluster() error {
116116
return stderrors.Join(errs...)
117117
}
118118

119-
// used as a shortcut to check if the cluster is an OpenShift cluster
119+
// used as a shortcut to check if the Config.Openshift.io API is found
120120
func IsConfigAPIFound() bool {
121121
return configAPIFound
122122
}
123123

124124
// used as a shortcut to check if the cluster is an OpenShift cluster
125125
func IsOpenShiftCluster() bool {
126-
return configAPIFound
126+
return IsConfigAPIFound()
127127
}
128128

129129
// verify if the Config.Openshift.io API is found

0 commit comments

Comments
 (0)