Documentation ¶
Index ¶
- type StaticResourceController
- func (c *StaticResourceController) AddCategoryExpander(categoryExpander restmapper.CategoryExpander) *StaticResourceController
- func (c *StaticResourceController) AddInformer(informer cache.SharedIndexInformer) *StaticResourceController
- func (c *StaticResourceController) AddKubeInformers(kubeInformersByNamespace v1helpers.KubeInformersForNamespaces) *StaticResourceController
- func (c *StaticResourceController) AddNamespaceInformer(informer cache.SharedIndexInformer, namespaces ...string) *StaticResourceController
- func (c *StaticResourceController) AddRESTMapper(mapper meta.RESTMapper) *StaticResourceController
- func (c *StaticResourceController) Name() string
- func (c *StaticResourceController) RelatedObjects() ([]configv1.ObjectReference, error)
- func (c *StaticResourceController) Run(ctx context.Context, workers int)
- func (c *StaticResourceController) Sync(ctx context.Context, syncContext factory.SyncContext) error
- func (c *StaticResourceController) WithConditionalResources(manifests resourceapply.AssetFunc, files []string, ...) *StaticResourceController
- func (c *StaticResourceController) WithIgnoreNotFoundOnCreate() *StaticResourceController
- func (c *StaticResourceController) WithPrecondition(precondition StaticResourcesPreconditionsFuncType) *StaticResourceController
- type StaticResourcesPreconditionsFuncType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StaticResourceController ¶
type StaticResourceController struct {
// contains filtered or unexported fields
}
func NewStaticResourceController ¶
func NewStaticResourceController( name string, manifests resourceapply.AssetFunc, files []string, clients *resourceapply.ClientHolder, operatorClient v1helpers.OperatorClient, eventRecorder events.Recorder, ) *StaticResourceController
NewStaticResourceController returns a controller that maintains certain static manifests. Most "normal" types are supported, but feel free to add ones we missed. Use .AddInformer(), .AddKubeInformers(), .AddNamespaceInformer or to provide triggering conditions. By default, the controller sets <name>Degraded condition on error when syncing a manifest. Optionally, the controller can ignore NotFound errors. This is useful when syncing CRs for CRDs that may not yet exist when the controller runs, such as ServiceMonitor.
func (*StaticResourceController) AddCategoryExpander ¶
func (c *StaticResourceController) AddCategoryExpander(categoryExpander restmapper.CategoryExpander) *StaticResourceController
func (*StaticResourceController) AddInformer ¶
func (c *StaticResourceController) AddInformer(informer cache.SharedIndexInformer) *StaticResourceController
func (*StaticResourceController) AddKubeInformers ¶
func (c *StaticResourceController) AddKubeInformers(kubeInformersByNamespace v1helpers.KubeInformersForNamespaces) *StaticResourceController
func (*StaticResourceController) AddNamespaceInformer ¶
func (c *StaticResourceController) AddNamespaceInformer(informer cache.SharedIndexInformer, namespaces ...string) *StaticResourceController
func (*StaticResourceController) AddRESTMapper ¶
func (c *StaticResourceController) AddRESTMapper(mapper meta.RESTMapper) *StaticResourceController
func (*StaticResourceController) Name ¶
func (c *StaticResourceController) Name() string
func (*StaticResourceController) RelatedObjects ¶
func (c *StaticResourceController) RelatedObjects() ([]configv1.ObjectReference, error)
func (*StaticResourceController) Run ¶
func (c *StaticResourceController) Run(ctx context.Context, workers int)
func (*StaticResourceController) Sync ¶
func (c *StaticResourceController) Sync(ctx context.Context, syncContext factory.SyncContext) error
func (*StaticResourceController) WithConditionalResources ¶
func (c *StaticResourceController) WithConditionalResources(manifests resourceapply.AssetFunc, files []string, shouldCreateFnArg, shouldDeleteFnArg resourceapply.ConditionalFunction) *StaticResourceController
WithConditionalResources adds a set of manifests to be created when the shouldCreateFnArg is true and should be deleted when the shouldDeleteFnArg is true. If shouldCreateFnArg is nil, then it is always create. If shouldDeleteFnArg is nil, then it is !shouldCreateFnArg
- shouldCreateFnArg == true && shouldDeleteFnArg == true - produces an error
- shouldCreateFnArg == false && shouldDeleteFnArg == false - does nothing as expected
- shouldCreateFnArg == true applies the manifests
- shouldDeleteFnArg == true deletes the manifests
func (*StaticResourceController) WithIgnoreNotFoundOnCreate ¶
func (c *StaticResourceController) WithIgnoreNotFoundOnCreate() *StaticResourceController
WithIgnoreNotFoundOnCreate makes the controller to ignore NotFound errors when applying a manifest. Such error is returned by the API server when the controller tries to apply a CR for CRD that has not yet been created. This is useful when creating CRs for other operators that were not started yet (such as ServiceMonitors). NotFound errors are reported in <name>Degraded condition, but with Degraded=false.
func (*StaticResourceController) WithPrecondition ¶
func (c *StaticResourceController) WithPrecondition(precondition StaticResourcesPreconditionsFuncType) *StaticResourceController
WithPrecondition adds a precondition, which blocks the sync method from being executed. Preconditions might be chained using:
WithPrecondition(a).WithPrecondition(b).WithPrecondition(c).
If any of the preconditions is false, the sync will result in an error.
The requirement parameter should follow the convention described in the StaticResourcesPreconditionsFuncType.
When the requirement is not met, the controller reports degraded status.
type StaticResourcesPreconditionsFuncType ¶
StaticResourcesPreconditionsFuncType checks if the precondition is met (is true) and then proceeds with the sync. When the requirement is not met, the controller reports degraded status.
In case, the returned ready flag is false, a proper error with a valid description is recommended.