helpers

package
v0.0.0-...-4f6e424 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare[T any](a, b T, ins ...CompareStack[T]) map[string]string

func EnsureServiceAccount

func EnsureServiceAccount(ctx context.Context, client kubernetes.Interface, owner meta.OwnerReference, obj *sharedApi.ServiceAccount, name, namespace string, role, clusterRole []rbac.PolicyRule) (bool, error)

Types

type Action

type Action int
const (
	ActionOK Action = iota
	ActionReplace
	ActionUpdate
)

func EmptyDecision

func EmptyDecision[T Object](ctx context.Context, current, expected DecisionObject[T]) (Action, error)

func ReplaceChecksum

func ReplaceChecksum[T Object](ctx context.Context, current, expected DecisionObject[T]) (Action, error)

func UpdateChecksum

func UpdateChecksum[T Object](ctx context.Context, current, expected DecisionObject[T]) (Action, error)

func UpdateOwnerReference

func UpdateOwnerReference[T Object](ctx context.Context, current, expected DecisionObject[T]) (Action, error)

func (Action) Or

func (a Action) Or(b Action) Action

type Client

type Client[T Object] interface {
	Get(ctx context.Context, name string, options meta.GetOptions) (T, error)
	Update(ctx context.Context, object T, options meta.UpdateOptions) (T, error)
	Create(ctx context.Context, object T, options meta.CreateOptions) (T, error)
	Delete(ctx context.Context, name string, options meta.DeleteOptions) error
}

type ClientFactory

type ClientFactory[T Object] func(namespace string) Client[T]

type CompareStack

type CompareStack[T any] func(a, b T) map[string]string

func FromSimpleCompareStack

func FromSimpleCompareStack[T any](name string, c SimpleCompareStack[T]) CompareStack[T]

func SubCompare

func SubCompare[T, X any](prefix string, extract SubCompareExtract[T, X], ins ...CompareStack[X]) CompareStack[T]

type Config

type Config[T Object] struct {
	Events  event.RecorderInstance
	Logger  logging.Logger
	Factory ClientFactory[T]
	Kind    string
}

type Decision

type Decision[T Object] func(ctx context.Context, current, expected DecisionObject[T]) (Action, error)

func (Decision[T]) Call

func (d Decision[T]) Call(ctx context.Context, current, expected DecisionObject[T]) (Action, error)

func (Decision[T]) With

func (d Decision[T]) With(other ...Decision[T]) Decision[T]

type DecisionObject

type DecisionObject[T Object] struct {
	Checksum string
	Object   T
}

type Generate

type Generate[T Object] func(ctx context.Context, ref *sharedApi.Object) (T, bool, string, error)

type ImmutableFields

type ImmutableFields[T Object] func(a, b T, changes map[string]string) Action

func NewImmutableFields

func NewImmutableFields[T Object](in ImmutableFields[T]) ImmutableFields[T]

func (ImmutableFields[T]) Evaluate

func (i ImmutableFields[T]) Evaluate(ins ...CompareStack[T]) Decision[T]

type Object

type Object interface {
	comparable
	meta.Object
}

type SimpleCompareStack

type SimpleCompareStack[T any] func(a, b T) (string, bool)

type SubCompareExtract

type SubCompareExtract[T, X any] func(in T) X

type Updator

type Updator[T Object] interface {
	OperatorUpdate(ctx context.Context, namespace string, parent meta.Object, ref **sharedApi.Object, generator Generate[T], decisions ...Decision[T]) (T, bool, error)
	Update(ctx context.Context, namespace string, parent meta.Object, ref **sharedApi.Object, generator Generate[T], decisions ...Decision[T]) (T, bool, error)
}

func NewUpdator

func NewUpdator[T Object](config Config[T]) Updator[T]

Jump to

Keyboard shortcuts

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