controller

package
v0.0.0-...-a36a61a Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFinalizer

func AddFinalizer(o client.Object) bool

func CtrlResultForErr

func CtrlResultForErr(err error) (ctrl.Result, error)

CtrlResultForErr is a helper function to convert an error into a ctrl.Result passing through ngrok error mappings

func HasFinalizer

func HasFinalizer(o client.Object) bool

func IsDelete

func IsDelete(o client.Object) bool

func IsUpsert

func IsUpsert(o client.Object) bool

func RegisterAndSyncFinalizer

func RegisterAndSyncFinalizer(ctx context.Context, c client.Writer, o client.Object) error

func RemoveAndSyncFinalizer

func RemoveAndSyncFinalizer(ctx context.Context, c client.Writer, o client.Object) error

func RemoveFinalizer

func RemoveFinalizer(o client.Object) bool

Types

type BaseController

type BaseController[T client.Object] struct {
	// Kube is the base client for interacting with the Kubernetes API
	Kube client.Client

	// Log is the logger for the controller
	Log logr.Logger

	// Recorder is the event recorder for the controller
	Recorder record.EventRecorder

	// Namespace is optional for controllers
	Namespace *string

	StatusID  func(obj T) string
	Create    func(ctx context.Context, obj T) error
	Update    func(ctx context.Context, obj T) error
	Delete    func(ctx context.Context, obj T) error
	ErrResult func(op BaseControllerOp, obj T, err error) (ctrl.Result, error)
}

BaseController is our standard pattern for writing controllers

Note: Non-provided methods are not called during reconcile

func (*BaseController[T]) NewEnqueueRequestForMapFunc

func (self *BaseController[T]) NewEnqueueRequestForMapFunc(f func(ctx context.Context, obj client.Object) []reconcile.Request) handler.EventHandler

NewEnqueueRequestForMapFunc wraps a map function to be used as an event handler. It also takes care to make sure that the controllers logger is passed through to the map function, so that we can use our common pattern of getting the logger from the context.

func (*BaseController[T]) Reconcile

func (self *BaseController[T]) Reconcile(ctx context.Context, req ctrl.Request, obj T) (ctrl.Result, error)

reconcile is the primary function that a manager calls for this controller to reconcile an event for the give client.Object

func (*BaseController[T]) ReconcileStatus

func (self *BaseController[T]) ReconcileStatus(ctx context.Context, obj T, origErr error) error

ReconcileStatus is a helper function to reconcile the status of an object and requeue on update errors Note: obj must be the latest resource version from k8s api

type BaseControllerOp

type BaseControllerOp int

BaseControllerOp is an enum for the different operations that can be performed by a BaseController

const (
	// createOp is the operation for creating a resource
	CreateOp BaseControllerOp = iota

	// updateOp is the operation for updating a resource (upsert)
	UpdateOp

	// deleteOp is the operation for deleting a resource (and finalizers)
	DeleteOp
)

type IpPolicyResolver

type IpPolicyResolver struct {
	Client client.Reader
}

func (*IpPolicyResolver) ResolveIPPolicyNamesorIds

func (r *IpPolicyResolver) ResolveIPPolicyNamesorIds(ctx context.Context, namespace string, namesOrIds []string) ([]string, error)

Resolves and IP policy names or IDs to IDs. If the input is not found, it is assumed to be an ID and is returned as is.

func (*IpPolicyResolver) ValidateIPPolicyNames

func (r *IpPolicyResolver) ValidateIPPolicyNames(ctx context.Context, namespace string, namesOrIds []string) error

type SecretResolver

type SecretResolver struct {
	Client client.Reader
}

func (*SecretResolver) GetSecret

func (r *SecretResolver) GetSecret(ctx context.Context, namespace, name, key string) (string, error)

type StatusError

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

StatusError wraps .Status().*() errors returned from k8s client

func (StatusError) Error

func (e StatusError) Error() string

func (StatusError) Unwrap

func (e StatusError) Unwrap() error

Directories

Path Synopsis
MIT License
MIT License
MIT License
MIT License
MIT License
MIT License

Jump to

Keyboard shortcuts

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