staticresourcecontroller

package
v0.0.0-...-6018a90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 33 Imported by: 14

Documentation

Index

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(
	instanceName 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 (*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 (*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 (*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

  1. shouldCreateFnArg == true && shouldDeleteFnArg == true - produces an error
  2. shouldCreateFnArg == false && shouldDeleteFnArg == false - does nothing as expected
  3. shouldCreateFnArg == true applies the manifests
  4. 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

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

type StaticResourcesPreconditionsFuncType func(ctx context.Context) (bool, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL