controllers

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: BSD-3-Clause Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const MetricsNamespace = "espejote"

Variables

View Source
var ErrCacheNotReady = errors.New("cache not ready")
View Source
var ErrFailedSyncCache = errors.New("failed to sync cache")
View Source
var EspejoteLibsonnet string

Functions

func ErrorIsTransient added in v0.4.1

func ErrorIsTransient(err error) bool

ErrorIsTransient returns true if the error is transient and the reconciliation should be retried without an error log and backoff.

func MakeAbsoluteImportPath added in v0.7.0

func MakeAbsoluteImportPath(importedFrom, importPath string) string

MakeAbsoluteImportPath makes an absolute import path from the given importedFrom and importPath. It handles relative imports and absolute imports and knows about the topology of the espejote imports.

Types

type AdmissionReconciler added in v0.3.0

type AdmissionReconciler struct {
	client.Client

	MutatingWebhookName   string
	ValidatingWebhookName string

	WebhookPort         int32
	WebhookServiceName  string
	ControllerNamespace string
}

AdmissionReconciler reconciles Admission objects.

func (*AdmissionReconciler) Reconcile added in v0.3.0

func (r *AdmissionReconciler) Reconcile(ctx context.Context, _ admissionRequest) (ctrl.Result, error)

Reconcile adds admissions to the MutatingWebhookConfiguration and ValidatingWebhookConfigurations.

func (*AdmissionReconciler) SetupWithManager added in v0.3.0

func (r *AdmissionReconciler) SetupWithManager(mgr ctrl.Manager) error

Setup sets up the controller with the Manager. All fields must be populated before calling this function.

type CacheSizeCollector

type CacheSizeCollector struct {
	ControllerManager *ManagedResourceControllerManager
}

CacheSizeCollector collects cache size metrics. It loops over all caches and collects the number of cached objects and the size of the cache.

func (*CacheSizeCollector) Collect

func (c *CacheSizeCollector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*CacheSizeCollector) Describe

func (c *CacheSizeCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type EspejoteError

type EspejoteError struct {
	Type EspejoteErrorType
	// contains filtered or unexported fields
}

func (EspejoteError) Error

func (e EspejoteError) Error() string

func (EspejoteError) Transient added in v0.4.1

func (e EspejoteError) Transient() bool

Transient returns true if the error is transient and the reconciliation should be retried without an error log and backoff.

type EspejoteErrorType

type EspejoteErrorType string
const (
	ServiceAccountError          EspejoteErrorType = "ServiceAccountError"
	WaitingForCacheSync          EspejoteErrorType = "WaitingForCacheSync"
	DependencyConfigurationError EspejoteErrorType = "DependencyConfigurationError"
	TemplateError                EspejoteErrorType = "TemplateError"
	ApplyError                   EspejoteErrorType = "ApplyError"
	TemplateReturnError          EspejoteErrorType = "TemplateReturnError"
	ControllerInstantiationError EspejoteErrorType = "ControllerInstantiationError"
)

type ImporterCacheEntry added in v0.7.0

type ImporterCacheEntry struct {
	Contents jsonnet.Contents
	FoundAt  string
	Err      error
}

ImporterCacheEntry is a cache entry for MultiImporter. It holds the result of the last import.

type ManagedResourceControllerManager added in v0.11.0

type ManagedResourceControllerManager struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder

	ControllerLifetimeCtx   context.Context
	JsonnetLibraryNamespace string
	// contains filtered or unexported fields
}

func (*ManagedResourceControllerManager) Reconcile added in v0.11.0

func (*ManagedResourceControllerManager) SetupWithManager added in v0.11.0

func (r *ManagedResourceControllerManager) SetupWithManager(name string, cfg *rest.Config, mgr ctrl.Manager) error

type ManagedResourceReconciler

type ManagedResourceReconciler struct {
	// For identifies the managed resource being reconciled.
	// This reconciler does not work like a classic reconciler.
	// One instance of this reconciler exists for each managed resource and it only ever reconciles that resource.
	// ManagedResourceControllerManager dynamically creates and manages these reconciler instances.
	For types.NamespacedName

	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder

	ControllerLifetimeCtx   context.Context
	JsonnetLibraryNamespace string
	// contains filtered or unexported fields
}

func (*ManagedResourceReconciler) Reconcile

func (r *ManagedResourceReconciler) Reconcile(ctx context.Context, req Request) (ctrl.Result, error)

type ManagedResourceStatusCollector added in v0.6.0

type ManagedResourceStatusCollector struct {
	client.Reader
}

ManagedResourceStatusCollector collects status metrics for managed resources. It loops over all managed resources and collects the infomation in the .status field.

func (*ManagedResourceStatusCollector) Collect added in v0.6.0

func (c *ManagedResourceStatusCollector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*ManagedResourceStatusCollector) Describe added in v0.6.0

func (c *ManagedResourceStatusCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type ManifestImporter

type ManifestImporter struct {
	client.Client

	// Namespace is the namespace for local imports.
	// If Namespace is empty, local imports are not allowed.
	Namespace string
	// LibraryNamespace is the namespace for library imports.
	LibraryNamespace string

	Cache map[string]ImporterCacheEntry
}

ManifestImporter imports data from espejotev1alpha1.JsonnetLibraries.

func FromClientImporter

func FromClientImporter(c client.Client, localNamespace, libNamespace string) *ManifestImporter

FromClientImporter returns an importer that fetches libraries from the cluster using the given client. "espejote.libsonnet" is statically embedded.

func (*ManifestImporter) Import

func (im *ManifestImporter) Import(importedFrom, importPath string) (contents jsonnet.Contents, foundAt string, err error)

Import know about the topology of the espejote imports. It handles relative imports and absolute imports. It also caches the results of the imports. The cache is non thread-safe, same as the upstream file importer. The import "espejote.libsonnet" is statically embedded and always resolves to the built-in library. If a local "espejote.libsonnet" import is required it can be prefixed with "./". Relative imports by JsonnetLibraries always resolve to the same local or library namespace.

type Renderer

type Renderer struct {
	Importer jsonnet.Importer

	TriggerClientGetter func(triggerName string) (client.Reader, error)
	ContextClientGetter func(contextName string) (client.Reader, error)
}

Render renders the given ManagedResource.

func (*Renderer) Render

func (r *Renderer) Render(ctx context.Context, managedResource espejotev1alpha1.ManagedResource, ti TriggerInfo) (string, error)

Render renders the given ManagedResource.

type Request

type Request struct {
	TriggerInfo TriggerInfo
}

type TriggerInfo

type TriggerInfo struct {
	TriggerName string

	WatchResource WatchResource
}

type WatchResource

type WatchResource struct {
	APIVersion string `json:"apiVersion,omitempty"`
	Group      string `json:"group,omitempty"`
	Kind       string `json:"kind,omitempty"`
	Name       string `json:"name,omitempty"`
	Namespace  string `json:"namespace,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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