controller

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 74 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	AttrCodegenInputAPIHash   = "kdex.dev/codegen-input-api-hash"
	AttrCodegenInputGenerator = "kdex.dev/codegen-input-generator"
)

Attribute keys recorded on KDexFunction.Status.Attributes after a successful codegen run. handleBuildValid edge-triggers re-codegen when the live values differ from these recorded ones — letting users edit spec.api without manually flipping spec.origin.source.regenerate. See kdex-tech/host-manager#40.

View Source
const BackendServiceIndexKey = "spec.backend.service.namespacedName"

BackendServiceIndexKey indexes KDexFunctions by the namespaced name of the Service referenced in spec.backend.service. Used by Service/EndpointSlice watches to enqueue dependent functions when a backend Service or its EndpointSlices change.

View Source
const ConditionTypePackagesReady = "PackagesReady"

ConditionTypePackagesReady is a host status condition dedicated to the front-end packages image build. Surfacing front-end package state on its own condition (rather than collapsing it into the host's overall Ready/Degraded, which also covers backend functions) lets a front-end package failure be observed independently and keeps it from gating backend function delivery. See kdex-tech/host-manager#117.

View Source
const UTILITY_PAGE_FINALIZER = "kdex-tech/kdex-host-utility-page-finalizer"

Variables

This section is empty.

Functions

func CRDExists added in v0.2.24

func CRDExists(mgr ctrl.Manager, gvk schema.GroupVersionKind) (bool, error)

func CollectBackend

func CollectBackend(defaultServerImage string, requiredBackends *[]kdexv1alpha1.KDexObjectReference, obj client.Object)

func ControllerNamespace

func ControllerNamespace() string

func FindImportmapInLayers added in v0.2.65

func FindImportmapInLayers(ctx context.Context, layers []ImportmapLayer, fetch LayerFetcher) (string, error)

FindImportmapInLayers selects the right layer from a manifest's layer list and returns the importmap JSON contents.

Selection rules, in order of preference:

  1. A layer with mediaType "application/vnd.kdex.importmap+json" — the explicit kdex-cli-tools/package_image artifact type.
  2. A layer with mediaType "application/json" — raw importmap blob, no tarball wrapping.
  3. ALL layers with mediaType "application/vnd.oci.image.layer.v1.tar+gzip", sorted by Size ASCENDING. Try each in turn; first whose tarball contains importmap.json wins.

Why "smallest tar+gzip first": the auto-build packager (kdex-cli-tools' package_image script) emits TWO tar+gzip layers per packages image — a large layer.tar.gz containing node_modules plus a copy of importmap.json, then a small importmap.layer.tar.gz containing just importmap.json. Iterating manifest.Layers and breaking on the first tar+gzip match (the previous behavior) lands on the big node_modules layer first. Streaming that to find one tiny file is wasteful (hundreds of MB at scale), error-prone, and silently picks the wrong copy if the two importmap.json files disagree. Size-asc selection prefers the dedicated layer.

func HashScriptDef

func HashScriptDef(script kdexv1alpha1.ScriptDef) string

func LogConstructor

func LogConstructor(name string, mgr ctrl.Manager) func(request *reconcile.Request) logr.Logger

func MakeHandlerByReferencePath

func MakeHandlerByReferencePath(
	c client.Client,
	scheme *runtime.Scheme,
	watcherType client.Object,
	list client.ObjectList,
	referencePath ...string,
) handler.EventHandler

nolint:gocyclo

func ResolveContents

func ResolveContents(
	ctx context.Context,
	c client.Client,
	referrer client.Object,
	referrerConditions *[]metav1.Condition,
	contentEntries []kdexv1alpha1.ContentEntry,
	requeueDelay time.Duration,
) (map[string]page.ResolvedContentEntry, bool, ctrl.Result, error)

func ResolveHost

func ResolveHost(
	ctx context.Context,
	c client.Client,
	object client.Object,
	objectConditions *[]metav1.Condition,
	hostRef *corev1.LocalObjectReference,
	requeueDelay time.Duration,
	checkReady bool,
) (*kdexv1alpha1.KDexInternalHost, bool, ctrl.Result, error)

func ResolveKDexObjectReference

func ResolveKDexObjectReference(
	ctx context.Context,
	c client.Client,
	referrer client.Object,
	referrerConditions *[]metav1.Condition,
	objectRef *kdexv1alpha1.KDexObjectReference,
	requeueDelay time.Duration,
) (client.Object, bool, ctrl.Result, error)

func ResolveOrDefaultFaaSAdaptor added in v0.2.27

func ResolveOrDefaultFaaSAdaptor(ctx context.Context, c client.Client, referrer client.Object, referrerConditions *[]metav1.Condition, internalHost *kdexv1alpha1.KDexInternalHost, requeueDelay time.Duration) (client.Object, bool, ctrl.Result, error)

func ResolveOrDefaultPageArchetype added in v0.2.27

func ResolveOrDefaultPageArchetype(ctx context.Context, c client.Client, referrer client.Object, referrerConditions *[]metav1.Condition, pageArchetypeRef *kdexv1alpha1.KDexObjectReference, requeueDelay time.Duration) (client.Object, bool, ctrl.Result, error)

func ResolvePage added in v0.2.9

func ResolvePage(
	ctx context.Context,
	c client.Client,
	object client.Object,
	objectConditions *[]metav1.Condition,
	pageRef *corev1.LocalObjectReference,
	requeueDelay time.Duration,
) (*kdexv1alpha1.KDexPage, bool, ctrl.Result, error)

func ResolvePageNavigations

func ResolvePageNavigations(
	ctx context.Context,
	c client.Client,
	object client.Object,
	objectConditions *[]metav1.Condition,
	navigationRefs map[string]*kdexv1alpha1.KDexObjectReference,
	requeueDelay time.Duration,
) (map[string]page.ResolvedNavigation, bool, ctrl.Result, error)

func ResolveSecrets added in v0.2.26

func ResolveSecrets(ctx context.Context, c client.Client, objectStatus *kdexv1alpha1.KDexObjectStatus, namespace string, selector *metav1.LabelSelector) (kdexv1alpha1.Secrets, error)

func UniqueScriptDefs

func UniqueScriptDefs(scripts []kdexv1alpha1.ScriptDef) []kdexv1alpha1.ScriptDef

Types

type ImportmapLayer added in v0.2.65

type ImportmapLayer struct {
	MediaType string
	Digest    digest.Digest
	Size      int64
}

ImportmapLayer is a minimal descriptor of one layer in an OCI image manifest, scoped to what FindImportmapInLayers needs.

type KDexFunctionReconciler

type KDexFunctionReconciler struct {
	client.Client
	Configuration       configuration.NexusConfiguration
	ControllerNamespace string
	FocalHost           string
	// FunctionImagePrefix overrides the function-image path segment before
	// <func>. nil = unset (default to HostRef.Name+"/"); non-nil = literal
	// (may be "" for a flat path). From FUNCTION_IMAGE_PREFIX env in main.go.
	FunctionImagePrefix *string
	HostHandler         *host.HostHandler
	RequeueDelay        time.Duration
	Scheme              *runtime.Scheme
}

KDexFunctionReconciler reconciles a KDexFunction object

func (*KDexFunctionReconciler) Reconcile

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

func (*KDexFunctionReconciler) SetupWithManager

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

type KDexInternalHostReconciler

type KDexInternalHostReconciler struct {
	client.Client
	Configuration       configuration.NexusConfiguration
	ControllerNamespace string
	FocalHost           string
	HostHandler         *host.HostHandler
	Port                int32
	RefreshGraceWindow  time.Duration
	RequeueDelay        time.Duration
	Scheme              *runtime.Scheme
	ServiceName         string
	// contains filtered or unexported fields
}

KDexInternalHostReconciler reconciles a KDexInternalHost object

func (*KDexInternalHostReconciler) PullImportMap added in v0.2.9

func (r *KDexInternalHostReconciler) PullImportMap(ctx context.Context, imageRef string, secrets kdexv1alpha1.Secrets) (string, error)

func (*KDexInternalHostReconciler) Reconcile

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

nolint:gocyclo

func (*KDexInternalHostReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type KDexInternalPackageReferencesReconciler

type KDexInternalPackageReferencesReconciler struct {
	client.Client
	Configuration       configuration.NexusConfiguration
	ControllerNamespace string
	FocalHost           string
	RequeueDelay        time.Duration
	Scheme              *runtime.Scheme
}

KDexInternalPackageReferencesReconciler reconciles a KDexInternalPackageReferences object

func (*KDexInternalPackageReferencesReconciler) Reconcile

func (*KDexInternalPackageReferencesReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type KDexInternalTranslationReconciler

type KDexInternalTranslationReconciler struct {
	client.Client
	ControllerNamespace string
	FocalHost           string
	HostHandler         *host.HostHandler
	RequeueDelay        time.Duration
	Scheme              *runtime.Scheme
}

KDexInternalTranslationReconciler reconciles a KDexInternalTranslation object

func (*KDexInternalTranslationReconciler) Reconcile

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

func (*KDexInternalTranslationReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type KDexInternalUtilityPageReconciler

type KDexInternalUtilityPageReconciler struct {
	client.Client
	Configuration       configuration.NexusConfiguration
	ControllerNamespace string
	FocalHost           string
	HostHandler         *host.HostHandler
	RequeueDelay        time.Duration
	Scheme              *runtime.Scheme
}

KDexInternalUtilityPageReconciler reconciles a KDexInternalUtilityPage object

func (*KDexInternalUtilityPageReconciler) Reconcile

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

nolint:gocyclo

func (*KDexInternalUtilityPageReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type KDexPageReconciler added in v0.2.9

type KDexPageReconciler struct {
	client.Client
	Configuration       configuration.NexusConfiguration
	ControllerNamespace string
	FocalHost           string
	HostHandler         *host.HostHandler
	RequeueDelay        time.Duration
	Scheme              *runtime.Scheme
}

KDexPageReconciler reconciles a KDexPage object

func (*KDexPageReconciler) Reconcile added in v0.2.9

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

func (*KDexPageReconciler) SetupWithManager added in v0.2.9

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

SetupWithManager sets up the controller with the Manager.

type LayerFetcher added in v0.2.65

type LayerFetcher func(ctx context.Context, layer ImportmapLayer) (io.ReadCloser, error)

LayerFetcher returns the blob bytes for the given layer. The caller closes the returned ReadCloser. In production this hits a remote registry; in tests it reads from an in-memory map.

type VersionMismatch added in v0.4.24

type VersionMismatch struct {
	Package string
	Want    string
	Got     string // "" when the package is absent from the image entirely
}

VersionMismatch records one package whose installed version in a built packages image disagrees with the version pinned in the KIPR spec.

func VerifyPinnedVersions added in v0.4.24

func VerifyPinnedVersions(
	ctx context.Context,
	layers []ImportmapLayer,
	pins map[string]string,
	fetch LayerFetcher,
) ([]VersionMismatch, error)

VerifyPinnedVersions checks that a freshly built packages image actually contains the versions the KIPR pinned.

This is the post-build half of kdex-tech/host-manager#161. During GitLab's post-publish npm propagation window the aggregation can retain a package's PREVIOUS bytes instead of failing, so packages:N ships stale modules under a correct pin — indistinguishable from success in the logs, and frozen there because the KIPR won't rebuild for an unchanged generation.

Scope, deliberately: this compares the version each package DECLARES in its installed package.json against the pin. It is not a content check. The registry's dist.shasum covers a tarball, and the image holds an extracted tree, so the two are not comparable here — a tarball-integrity check has to happen where the fetch happens (node-tools' get_modules step; see #161). This catches the reported symptom — the previous VERSION baked into packages:N — and nothing weaker.

Returns the mismatches found. An empty slice means every pin was satisfied. Pins with a non-exact version (ranges like "^1.2.0", tags, URLs) are skipped: the pinned string is not a version to compare against, and the packager is free to resolve it however npm would.

func (VersionMismatch) String added in v0.4.24

func (m VersionMismatch) String() string

Jump to

Keyboard shortcuts

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