module

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModuleFinalizer is set on a Module when it is first handled by the controller.
	// It ensures that FluxCD resources are properly cleaned up before the Module is deleted.
	ModuleFinalizer = "addons.otterscale.io/module-cleanup"

	// ConditionTypeReady indicates whether the module's FluxCD resources
	// have been successfully reconciled and are healthy.
	ConditionTypeReady = "Ready"

	// ConditionTypeUpgradeAvailable indicates that a newer ModuleTemplate
	// generation exists but has not yet been approved for deployment.
	ConditionTypeUpgradeAvailable = "UpgradeAvailable"

	// LabelModuleTemplate identifies the ModuleTemplate that this resource was created from.
	LabelModuleTemplate = "addons.otterscale.io/module-template"
)

Variables

This section is empty.

Functions

func DeleteHelmRelease

func DeleteHelmRelease(ctx context.Context, c client.Client, m *addonsv1alpha1.Module, namespace string) error

DeleteHelmRelease deletes the FluxCD HelmRelease associated with the Module. It returns nil if the resource is already gone.

func DeleteKustomization

func DeleteKustomization(ctx context.Context, c client.Client, m *addonsv1alpha1.Module, namespace string) error

DeleteKustomization deletes the FluxCD Kustomization associated with the Module. It returns nil if the resource is already gone.

func EnsureNamespace added in v0.1.2

func EnsureNamespace(ctx context.Context, c client.Client, name string) error

EnsureNamespace creates the namespace if it does not already exist.

func LabelsForModule

func LabelsForModule(moduleName, templateName, version string) map[string]string

LabelsForModule returns a standard set of labels for resources managed by a Module. It builds on the shared labels.Standard() base and adds the Module-specific template label.

func ReconcileHelmRelease

func ReconcileHelmRelease(
	ctx context.Context,
	c client.Client,
	scheme *runtime.Scheme,
	m *addonsv1alpha1.Module,
	mt *addonsv1alpha1.ModuleTemplate,
	version string,
) error

ReconcileHelmRelease ensures the FluxCD HelmRelease exists and matches the desired state derived from the ModuleTemplate and Module overrides.

The HelmRelease is created in the target namespace with OwnerReference pointing to the cluster-scoped Module for garbage collection.

func ReconcileKustomization

func ReconcileKustomization(
	ctx context.Context,
	c client.Client,
	scheme *runtime.Scheme,
	m *addonsv1alpha1.Module,
	mt *addonsv1alpha1.ModuleTemplate,
	version string,
) error

ReconcileKustomization ensures the FluxCD Kustomization exists and matches the desired state derived from the ModuleTemplate.

The Kustomization is created in the target namespace with OwnerReference pointing to the cluster-scoped Module for garbage collection.

func TargetNamespace

func TargetNamespace(m *addonsv1alpha1.Module, mt *addonsv1alpha1.ModuleTemplate) string

TargetNamespace resolves the effective namespace for a Module, preferring the Module's override, falling back to the ModuleTemplate default.

Types

type TemplateInvalidError

type TemplateInvalidError struct {
	Name    string
	Message string
}

TemplateInvalidError is a permanent error indicating the referenced ModuleTemplate has an invalid configuration (e.g. neither helmRelease nor kustomization is set).

func (*TemplateInvalidError) Error

func (e *TemplateInvalidError) Error() string

type TemplateNotFoundError

type TemplateNotFoundError struct {
	Name string
}

TemplateNotFoundError is a permanent error indicating the referenced ModuleTemplate does not exist.

func (*TemplateNotFoundError) Error

func (e *TemplateNotFoundError) Error() string

type UpgradeDecision

type UpgradeDecision int

UpgradeDecision represents the outcome of evaluating whether a Module should apply changes from its referenced ModuleTemplate.

const (
	// UpgradeNotNeeded indicates the template has not changed since the last apply.
	UpgradeNotNeeded UpgradeDecision = iota

	// UpgradeInitialInstall indicates this is the first reconciliation and
	// the template should be applied without requiring explicit approval.
	UpgradeInitialInstall

	// UpgradeApproved indicates the template has changed and the user has
	// approved the new generation (or approval is not configured).
	UpgradeApproved

	// UpgradePending indicates the template has changed but the user has
	// not yet approved the new generation.
	UpgradePending
)

func CheckUpgrade

CheckUpgrade is a pure function that determines whether a Module should apply template changes based on the current state. It has no side effects and performs no I/O.

Decision logic:

  • AppliedTemplateGeneration == 0 → first install, always apply
  • Template generation unchanged → nothing to do
  • ApprovedTemplateGeneration nil → auto-approve (backward compatible)
  • Approved >= template generation → approved by user
  • Otherwise → pending user approval

func (UpgradeDecision) ShouldApply

func (d UpgradeDecision) ShouldApply() bool

ShouldApply returns true when the decision permits applying template changes to the FluxCD resources.

Jump to

Keyboard shortcuts

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