ctrl

package
v0.20.21 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(ctx context.Context) *k8s.Client

func Logger

func Logger(ctx context.Context) *slog.Logger

func RootLogger

func RootLogger(ctx context.Context) *slog.Logger

func Terminal added in v0.20.19

func Terminal(err error) error

Terminal marks an error as terminal. The controller will consider this error as non-retryable and will not requeue the event. ctrl.Result Requeue / RequeueAfter takes precedence.

func Terminalf added in v0.20.20

func Terminalf(format string, args ...any) error

Terminalf is a convenience wrapper to build a terminal error using fmt.Errorf.

Types

type Entry

type Entry struct {
	GroupKind  schema.GroupKind
	Forwarders []schema.GroupKind
	Funcs      Funcs
}

type Event

type Event struct {
	Name      string
	Namespace string
	schema.GroupKind
	// contains filtered or unexported fields
}

func (Event) String

func (evt Event) String() string

func (Event) WithoutMeta

func (evt Event) WithoutMeta() Event

type Funcs

type Funcs struct {
	Handler  HandleFunc
	Teardown func()
}

type HandleFunc

type HandleFunc func(context.Context, Event) (Result, error)

type Instance

type Instance struct {
	Params
	// contains filtered or unexported fields
}

func Inst

func Inst(ctx context.Context) *Instance

func NewController

func NewController(params Params) *Instance

func (*Instance) IsListeningForGK

func (instance *Instance) IsListeningForGK(gk schema.GroupKind) bool

func (*Instance) Register

func (instance *Instance) Register(entries ...Entry) error

func (*Instance) Run

func (instance *Instance) Run(ctx context.Context) error

func (*Instance) SendEvent

func (instance *Instance) SendEvent(evt Event)

func (*Instance) ShutdownGK

func (instance *Instance) ShutdownGK(gk schema.GroupKind)

type Params

type Params struct {
	Client      *k8s.Client
	Logger      *slog.Logger
	Concurrency int
}

type Queue

type Queue[T fmt.Stringer] struct {
	C    chan T
	Stop func()
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T fmt.Stringer](concurrency int) *Queue[T]

NewQueue returns a queue that will dedup events based on its string representation as determined by fmt.Stringer.

func (*Queue[T]) Enqueue

func (queue *Queue[T]) Enqueue(value T)

func (*Queue[T]) Pull

func (queue *Queue[T]) Pull() <-chan T

type ResourceCache added in v0.20.16

type ResourceCache[T any] struct {
	// contains filtered or unexported fields
}

func Cache added in v0.20.16

func Cache[T any, obj internalk8s.MetaObject[T]](ctx context.Context, gk schema.GroupKind, ns string) *ResourceCache[T]

func CacheFromEvent added in v0.20.16

func CacheFromEvent[T any, obj internalk8s.MetaObject[T]](ctx context.Context, evt Event) *ResourceCache[T]

func (ResourceCache[T]) Get added in v0.20.16

func (r ResourceCache[T]) Get(name string) (*T, error)

func (ResourceCache[T]) List added in v0.20.16

func (r ResourceCache[T]) List(selector labels.Selector) ([]*T, error)

type Result

type Result struct {
	Requeue      bool
	RequeueAfter time.Duration
}

Jump to

Keyboard shortcuts

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