core

package
v3.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound               = errors.New("no configuration found")
	ErrMultipleInstancesFound = errors.New("multiple resources found")
)

Functions

func BuildReconcileRequests

func BuildReconcileRequests(ctx context.Context, client client.Client, scheme *runtime.Scheme, target client.Object, opts ...client.ListOption) []reconcile.Request

func ComputeEnvVar

func ComputeEnvVar(format string, keys ...string) string

func CopyDir

func CopyDir(f fs.FS, root, path string, ret *map[string]string)

func CreateOrUpdate

func CreateOrUpdate[T client.Object](ctx Context,
	key types.NamespacedName, mutators ...ObjectMutator[T]) (T, controllerutil.OperationResult, error)

func DeleteIfExists

func DeleteIfExists[T client.Object](ctx Context, name types.NamespacedName) error

func Env

func Env(name string, value string) corev1.EnvVar

func EnvFromBool

func EnvFromBool(name string, vb bool) corev1.EnvVar

func EnvFromConfig

func EnvFromConfig(name, configName, key string) corev1.EnvVar

func EnvFromSecret

func EnvFromSecret(name, secretName, key string) corev1.EnvVar

func EnvVarPlaceholder

func EnvVarPlaceholder(key string) string

func GetAllStackDependencies

func GetAllStackDependencies(ctx Context, stackName string, to any) error

func GetDevEnvVars

func GetDevEnvVars(stack *v1beta1.Stack, service interface {
	IsDebug() bool
	IsDev() bool
}) []corev1.EnvVar

TODO: The stack reconciler can create a config map container env var for dev and debug This way, we avoid the need to fetch the stack object at each reconciliation loop

func GetIfExists

func GetIfExists(ctx Context, stackName string, to client.Object) (bool, error)

func GetModuleVersion

func GetModuleVersion(ctx Context, stack *v1beta1.Stack, module v1beta1.Module) (string, error)

func GetNamespacedResourceName

func GetNamespacedResourceName(namespace, name string) types.NamespacedName

func GetObjectName

func GetObjectName(stack, name string) string

func GetResourceName

func GetResourceName(name string) types.NamespacedName

func GetSingleDependency

func GetSingleDependency(ctx Context, stackName string, to client.Object) error

func HasControllerReference

func HasControllerReference(ctx Context, owner client.Object, object client.Object) (bool, error)

func HasDependency

func HasDependency(ctx Context, stackName string, to client.Object) (bool, error)

func HasOwnerReference

func HasOwnerReference(ctx Context, owner client.Object, object client.Object) (bool, error)

func HashFromConfigMaps

func HashFromConfigMaps(configMaps ...*corev1.ConfigMap) string

func HashFromResources

func HashFromResources(resources ...*unstructured.Unstructured) string

func Init

func Init(i ...Initializer)

func IsApplicationError

func IsApplicationError(err error) bool

func IsGreaterOrEqual

func IsGreaterOrEqual(version string, than string) bool

func IsLower

func IsLower(version string, than string) bool

func ListEventPublishers

func ListEventPublishers(ctx Context, stackName string) ([]unstructured.Unstructured, error)

func LowerCamelCaseKind

func LowerCamelCaseKind(ctx Context, ob client.Object) string

func LowerCaseKind added in v3.7.2

func LowerCaseKind(ctx Context, ob client.Object) string

func MapObjectToReconcileRequests

func MapObjectToReconcileRequests[T client.Object](items ...T) []reconcile.Request

func NewContext

func NewContext(mgr Manager, ctx context.Context) *defaultContext

func NewDefaultManager

func NewDefaultManager(m ctrl.Manager, platform Platform) *defaultManager

func NewVolumeFromConfigMap

func NewVolumeFromConfigMap(name string, configMap *corev1.ConfigMap) corev1.Volume

func NewVolumeMount

func NewVolumeMount(name, mountPath string, readOnly bool) corev1.VolumeMount

func Setup

func Setup(mgr ctrl.Manager, platform Platform) error

func ShellScript

func ShellScript(cmd string, args ...any) []string

func Watch

func Watch(mgr Manager, t client.Object) func(ctx context.Context, object client.Object) []reconcile.Request

func WatchDependents

func WatchDependents(mgr Manager, t client.Object) func(ctx context.Context, object client.Object) []reconcile.Request

func WithTemporaryNamespace

func WithTemporaryNamespace(ctx Context, name string, callback func() error) error

func WithWatchVersions

func WithWatchVersions[T client.Object](options *ReconcilerOptions[T])

Types

type ApplicationError

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

func NewApplicationError

func NewApplicationError() *ApplicationError

func NewMissingSettingsError

func NewMissingSettingsError(msg string) *ApplicationError

func NewPendingError

func NewPendingError() *ApplicationError

func NewStackNotFoundError

func NewStackNotFoundError() *ApplicationError

func (*ApplicationError) Error

func (e *ApplicationError) Error() string

func (*ApplicationError) Is

func (e *ApplicationError) Is(err error) bool

func (*ApplicationError) WithMessage

func (e *ApplicationError) WithMessage(msg string, args ...any) *ApplicationError

type Context

type Context interface {
	context.Context
	GetClient() client.Client
	GetScheme() *runtime.Scheme
	GetAPIReader() client.Reader
	GetPlatform() Platform
}

type Finalizer

type Finalizer[T client.Object] func(ctx Context, t T) error

type Initializer

type Initializer func(mgr Manager) error

func WithIndex

func WithIndex[T client.Object](name string, eval func(t T) []string) Initializer

func WithModuleReconciler

func WithModuleReconciler[T v1beta1.Module](fn func(ctx Context, stack *v1beta1.Stack, req T, version string) error, opts ...ReconcilerOption[T]) Initializer

func WithResourceReconciler

func WithResourceReconciler[T v1beta1.Dependent](fn func(ctx Context, stack *v1beta1.Stack, req T) error, opts ...ReconcilerOption[T]) Initializer

func WithSimpleIndex

func WithSimpleIndex[T client.Object](name string, eval func(t T) string) Initializer

func WithStackDependencyReconciler

func WithStackDependencyReconciler[T v1beta1.Dependent](fn func(ctx Context, stack *v1beta1.Stack, req T) error, opts ...ReconcilerOption[T]) Initializer

func WithStdReconciler

func WithStdReconciler[T v1beta1.Object](ctrl func(ctx Context, req T) error, opts ...ReconcilerOption[T]) Initializer

type Manager

type Manager interface {
	ctrl.Manager
	GetPlatform() Platform
}

type ModuleController

type ModuleController[T v1beta1.Module] func(ctx Context, stack *v1beta1.Stack, reconcilerOptions *ReconcilerOptions[T], req T, version string) error

type ObjectController

type ObjectController[T client.Object] func(ctx Context, reconcilerOptions *ReconcilerOptions[T], req T) error

func ForObjectController

func ForObjectController[T v1beta1.Object](controller ObjectController[T]) ObjectController[T]

func ForStackDependency

func ForStackDependency[T v1beta1.Dependent](ctrl StackDependentObjectController[T], allowDeleted bool) ObjectController[T]

type ObjectMutator

type ObjectMutator[T any] func(t T) error

func WithAnnotations

func WithAnnotations[T client.Object](newAnnotations map[string]string) ObjectMutator[T]

func WithController

func WithController[T client.Object](scheme *runtime.Scheme, owner client.Object) ObjectMutator[T]

func WithLabels

func WithLabels[T client.Object](newLabels map[string]string) ObjectMutator[T]

func WithOwner

func WithOwner[T client.Object](scheme *runtime.Scheme, owner client.Object) ObjectMutator[T]

type Platform

type Platform struct {
	// Cloud region where the stack is deployed
	Region string
	// Cloud environment where the stack is deployed: staging, production,
	// sandbox, etc.
	Environment string
	// The licence information
	LicenceSecret string
	// The operator utils image version
	UtilsVersion string
}

type ReconcilerOption

type ReconcilerOption[T client.Object] func(*ReconcilerOptions[T])

func WithFinalizer

func WithFinalizer[T client.Object](name string, callback Finalizer[T]) ReconcilerOption[T]

func WithOwn

func WithOwn[T client.Object](v client.Object, opts ...builder.OwnsOption) ReconcilerOption[T]

func WithRaw

func WithRaw[T client.Object](fn func(Context, *builder.Builder) error) ReconcilerOption[T]

func WithWatch

func WithWatch[T client.Object, WATCHED client.Object](fn func(ctx Context, object WATCHED) []reconcile.Request) ReconcilerOption[T]

func WithWatchDependency

func WithWatchDependency[T client.Object](t v1beta1.Dependent) ReconcilerOption[T]

func WithWatchSettings

func WithWatchSettings[T client.Object]() ReconcilerOption[T]

func WithWatchStack

func WithWatchStack[T client.Object]() ReconcilerOption[T]

type ReconcilerOptions

type ReconcilerOptions[T client.Object] struct {
	Owns       map[client.Object][]builder.OwnsOption
	Watchers   map[client.Object]ReconcilerOptionsWatch
	Finalizers []finalizerConfig[T]
	Raws       []func(Context, *builder.Builder) error
}

type ReconcilerOptionsWatch

type ReconcilerOptionsWatch struct {
	Handler func(mgr Manager, builder *builder.Builder, target client.Object) (handler.EventHandler, []builder.WatchesOption)
}

type StackDependentObjectController

type StackDependentObjectController[T v1beta1.Dependent] func(ctx Context, stack *v1beta1.Stack, reconcilerOptions *ReconcilerOptions[T], req T) error

func ForModule

func ForModule[T v1beta1.Module](underlyingController ModuleController[T]) StackDependentObjectController[T]

Jump to

Keyboard shortcuts

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