controllers

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: BSD-3-Clause Imports: 48 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.

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

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.

type CacheSizeCollector

type CacheSizeCollector struct {
	ManagedResourceReconciler *ManagedResourceReconciler
}

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"
)

type ManagedResourceReconciler

type ManagedResourceReconciler struct {
	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)

func (*ManagedResourceReconciler) Setup

func (r *ManagedResourceReconciler) Setup(cfg *rest.Config, mgr ctrl.Manager) error

Setup sets up the controller with the Manager.

func (*ManagedResourceReconciler) SetupWithName added in v0.4.1

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

SetupWithName sets up the controller with the Manager and a name for the global metrics registry.

type ManifestImporter

type ManifestImporter struct {
	client.Client

	Namespace string
}

ManifestImporter imports data from espejotev1alpha1.JsonnetLibraries.

func (*ManifestImporter) Import

func (importer *ManifestImporter) Import(_, importedPath string) (contents jsonnet.Contents, foundAt string, err error)

Import fetches from espejotev1alpha1.JsonnetLibraries in the cluster The first path segment is the name of the JsonnetLibrary object. The second path segment is the key in the JsonnetLibrary object.

type MultiImporter

type MultiImporter struct {
	Importers []MultiImporterConfig

	Cache map[string]MultiImporterCacheEntry
}

MultiImporter imports from multiple importers. It tries each importer in order until one succeeds. If all importers fail, it returns an error combining all errors. Lookup results are cached for the lifetime of the importer and can be accessed through the Cache field. The cache is not thread-safe. Same as the upstream FileImporter.

func FromClientImporter

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

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

func (*MultiImporter) Import

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

Import fetches from the first importer that succeeds.

type MultiImporterCacheEntry

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

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

type MultiImporterConfig

type MultiImporterConfig struct {
	Importer       jsonnet.Importer
	TrimPathPrefix string
}

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 {
	NamespacedName types.NamespacedName
	// Include more trigger info
	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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳