manager

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 30 Imported by: 42

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResourceError is raised when this is used with an unsupported resource
	// kind.
	ErrResourceError = errors.New("unable to assert resource type")
)

Functions

func AddResourceReference added in v1.8.0

func AddResourceReference(ctx context.Context, cli client.Client, resource client.Object, key client.ObjectKey, reference string) error

AddResourceReference adds the given resource reference to the specified resource. This is typically run by a controller before the resource is consumed.

func AddResourceReferences added in v1.8.0

func AddResourceReferences(ctx context.Context, cli client.Client, resources client.ObjectList, options *client.ListOptions, reference string, ids []string) error

AddResourceReferences adds the given resource reference to all resources that match the selector and that are in the given set of IDs. An error is raised if an ID is not present. This is typically run by a controller before the resource is consumed.

func ClearResourceReferences added in v1.8.0

func ClearResourceReferences(ctx context.Context, cli client.Client, resources client.ObjectList, options *client.ListOptions, reference string) error

ClearResourceReferences is used by controllers whose object may reference one of many other resources e.g. a server can reference multiple security groups. This is used to clean them out during the finalizing phase of deletion.

func FromContext

func FromContext(ctx context.Context) manager.Manager

func GenerateResourceReference added in v1.8.0

func GenerateResourceReference(client client.Client, resource client.Object) (string, error)

GenerateResourceReference takes a resource and generates a unique reference for use with blocking deletion.

func GetResourceReferences added in v1.8.0

func GetResourceReferences(object client.Object) []string

GetResourceReferences returns all resource references attached to a resource. This is used primarily to poll a resource to see if it's in use, and thus its deletion will have consequences. It may also be used to inhibit deletion in certain cercumstances.

func NewContext

func NewContext(ctx context.Context, manager manager.Manager) context.Context

func RemoveResourceReference added in v1.8.0

func RemoveResourceReference(ctx context.Context, cli client.Client, resource client.Object, key client.ObjectKey, reference string) error

RemoveResourceReference removes the given resource reference from the selected resource. This is typically run by a controller after a resource has stopped being used.

func RemoveResourceReferences added in v1.8.0

func RemoveResourceReferences(ctx context.Context, cli client.Client, resources client.ObjectList, options *client.ListOptions, reference string, ids []string) error

RemoveResourceReferences removes the given resource reference from all resources that match the selector and that are not in the given set of IDs. This is typically run by a controller after a resource has stopped being used.

func ResourceReady added in v1.8.0

func ResourceReady(ctx context.Context, resource corev1.ManagableResourceInterface) error

ResourceReady reads a resource, and checks its readiness status. If available, then it can be used by a child, and it returns nil, otherwise returns ErrYield.

func Run

func Run(f ControllerFactory)

Run provides common manager initialization and execution.

Types

type ControllerFactory

type ControllerFactory interface {
	// Metadata returns the application, version and revision.
	Metadata() util.ServiceDescriptor

	// Options may be nil, otherwise it's a controller specific set of
	// options that are added to the flagset on start up and passed to the
	// reonciler.
	Options() ControllerOptions

	// Reconciler returns a new reconciler instance.
	Reconciler(options *options.Options, controllerOptions ControllerOptions, manager manager.Manager) reconcile.Reconciler

	// RegisterWatches adds any watches that would trigger a reconcile.
	RegisterWatches(manager manager.Manager, controller controller.Controller) error

	// Schemes allows controllers to add types to the client beyond
	// the defaults defined in this repository.
	Schemes() []coreclient.SchemeAdder
}

ControllerFactory allows creation of a Unikorn controller with minimal code.

type ControllerOptions added in v0.1.65

type ControllerOptions interface {
	// AddFlags adds a set of flags to the flagset.
	AddFlags(f *pflag.FlagSet)
}

ControllerOptions abstracts controller specific flags.

type ControllerUpgrader added in v1.7.0

type ControllerUpgrader interface {
	// Upgrade allows version based upgrades of managed resources.
	Upgrade(ctx context.Context, cli client.Client, options *options.Options) error
}

ControllerUpgrader optionally allows the factory to define an upgrade procedure. DO NOT MODIFY THE SPEC EVER, you have CRD defaulting to fill in any blanks. Only things like metadata can be touched, or the resources can be moved around. Typically you would want to attach a controller version annotation to define what API the resource is using, then drive upgrades based on that.

type ProvisionerCreateFunc

type ProvisionerCreateFunc func(ControllerOptions) provisioners.ManagerProvisioner

ProvisionerCreateFunc provides a type agnosic method to create a root provisioner.

type Reconciler

type Reconciler struct {
	// contains filtered or unexported fields
}

Reconciler is a generic reconciler for all manager types.

func NewReconciler

func NewReconciler(options *options.Options, controllerOptions ControllerOptions, manager manager.Manager, createProvisioner ProvisionerCreateFunc) *Reconciler

NewReconciler creates a new reconciler.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)

Reconcile is the top-level reconcile interface that controller-runtime will dispatch to. It initialises the provisioner, extracts the request object and based on whether it exists or not, reconciles or deletes the object respectively.

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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