knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/controller/options.go (about)

     1  /*
     2  Copyright 2020 The Knative Authors
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      https://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package controller
    18  
    19  import "knative.dev/pkg/reconciler"
    20  
    21  // Options is additional resources a Controller might want to use depending
    22  // on implementation.
    23  type Options struct {
    24  	// ConfigStore is used to attach the frozen configuration to the context.
    25  	ConfigStore reconciler.ConfigStore
    26  
    27  	// FinalizerName is the name of the finalizer this reconciler uses. This
    28  	// overrides a default finalizer name assigned by the generator if needed.
    29  	FinalizerName string
    30  
    31  	// UseServerSideApplyForFinalizers enables server-side apply for finalizer management.
    32  	// When enabled, this reconciler will use server-side apply instead of merge patch
    33  	// to manage its finalizer, reducing conflicts when multiple controllers manage
    34  	// different finalizers on the same resource.
    35  	UseServerSideApplyForFinalizers bool
    36  
    37  	// FinalizerFieldManager specifies the field manager name for server-side apply
    38  	// finalizer operations. This is required when UseServerSideApplyForFinalizers
    39  	// is true and should be unique to avoid conflicts with other controllers.
    40  	FinalizerFieldManager string
    41  
    42  	// ForceApplyFinalizers configures whether to use the Force option when applying
    43  	// finalizers via server-side apply. This can resolve conflicts but should be
    44  	// used carefully as it can override other field managers.
    45  	ForceApplyFinalizers bool
    46  
    47  	// AgentName is the name of the agent this reconciler uses. This overrides
    48  	// the default controller's agent name.
    49  	AgentName string
    50  
    51  	// SkipStatusUpdates configures this reconciler to either do automated status
    52  	// updates (default) or skip them if this is set to true.
    53  	SkipStatusUpdates bool
    54  
    55  	// DemoteFunc configures the demote function this reconciler uses
    56  	DemoteFunc func(b reconciler.Bucket)
    57  
    58  	// Concurrency - The number of workers to use when processing the controller's workqueue.
    59  	Concurrency int
    60  
    61  	// PromoteFilterFunc filters the objects that are enqueued when the reconciler is promoted to leader.
    62  	// Objects that pass the filter (return true) will be reconciled when a new leader is promoted.
    63  	// If no filter is specified, all objects will be reconciled.
    64  	PromoteFilterFunc func(obj interface{}) bool
    65  
    66  	// PromoteFunc is called when a reconciler is promoted for the given bucket
    67  	// The provided function must not block execution.
    68  	PromoteFunc func(bkt reconciler.Bucket)
    69  }
    70  
    71  // OptionsFn is a callback method signature that accepts an Impl and returns
    72  // Options. Used for controllers that need access to the members of Options but
    73  // to build Options, integrators need an Impl.
    74  type OptionsFn func(impl *Impl) Options