MCPcopy
hub / github.com/argoproj/argo-cd / canProcessApp

Method canProcessApp

controller/appcontroller.go:2409–2440  ·  view source on GitHub ↗
(obj any)

Source from the content-addressed store, hash-verified

2407}
2408
2409func (ctrl *ApplicationController) canProcessApp(obj any) bool {
2410 app, ok := obj.(*appv1.Application)
2411 if !ok {
2412 return false
2413 }
2414
2415 // Only process given app if it exists in a watched namespace, or in the
2416 // control plane's namespace.
2417 if !ctrl.isAppNamespaceAllowed(app) {
2418 return false
2419 }
2420
2421 if annotations := app.GetAnnotations(); annotations != nil {
2422 if skipVal, ok := annotations[common.AnnotationKeyAppSkipReconcile]; ok {
2423 logCtx := log.WithFields(applog.GetAppLogFields(app))
2424 if skipReconcile, err := strconv.ParseBool(skipVal); err == nil {
2425 if skipReconcile {
2426 logCtx.Debugf("Skipping Application reconcile based on annotation %s", common.AnnotationKeyAppSkipReconcile)
2427 return false
2428 }
2429 } else {
2430 logCtx.WithError(err).Debugf("Unable to determine if Application should skip reconcile based on annotation %s", common.AnnotationKeyAppSkipReconcile)
2431 }
2432 }
2433 }
2434
2435 destCluster, err := argo.GetDestinationCluster(context.Background(), app.Spec.Destination, ctrl.db)
2436 if err != nil {
2437 return ctrl.clusterSharding.IsManagedCluster(nil)
2438 }
2439 return ctrl.clusterSharding.IsManagedCluster(destCluster)
2440}
2441
2442func (ctrl *ApplicationController) newApplicationInformerAndLister() (cache.SharedIndexInformer, applisters.ApplicationLister) {
2443 watchNamespace := ctrl.namespace

Calls 4

isAppNamespaceAllowedMethod · 0.95
GetDestinationClusterFunction · 0.92
GetAnnotationsMethod · 0.80
IsManagedClusterMethod · 0.65

Tested by 2

Test_canProcessAppFunction · 0.64