Skip to content

Commit

Permalink
added label selector logs
Browse files Browse the repository at this point in the history
  • Loading branch information
raghavi101 committed Sep 4, 2023
1 parent da93c4a commit f053fc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions controllers/argocd/argocd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,18 @@ func (r *ReconcileArgoCD) Reconcile(ctx context.Context, request ctrl.Request) (
// Error reading the object - requeue the request.
return reconcile.Result{}, err
}
//debug line
fmt.Println(r.LabelSelector)

// Fetch labelSelector from r.LabelSelector (command-line option)
labelSelector, err := labels.Parse(r.LabelSelector)
if err != nil {
reqLogger.Info("error parsing the labelSelector '%s'.", labelSelector)
reqLogger.Info(fmt.Sprintf("error parsing the labelSelector '%s'.", labelSelector))
return reconcile.Result{}, err
}

// Match the value of labelSelector from ReconcileArgoCD to labels from the argocd instance
if !labelSelector.Matches(labels.Set(argocd.Labels)) {
reqLogger.Info("the ArgoCD instance does not match the label selector %s and skipping for reconcillation", r.LabelSelector)
reqLogger.Info(fmt.Sprintf("the ArgoCD instance does not match the label selector '%s' and skipping for reconcillation", r.LabelSelector))
return reconcile.Result{}, nil
}

Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func main() {
setupLog.Info("error parsing the labelSelector '%s'.", labelSelectorFlag)
os.Exit(1)
}
setupLog.Info(fmt.Sprintf("Watching labelselector \"%s\"", labelSelectorFlag))

// Inspect cluster to verify availability of extra features
if err := argocd.InspectCluster(); err != nil {
Expand Down Expand Up @@ -194,7 +195,8 @@ func main() {
os.Exit(1)
}
}

setupLog.Info("AAAAAAAAAAA0")
setupLog.Info(labelSelectorFlag)
if err = (&argocd.ReconcileArgoCD{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand Down

0 comments on commit f053fc9

Please sign in to comment.