kubernetes

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MPL-2.0 Imports: 36 Imported by: ? 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 (
	// VersionMarkerConfigMapName is the ConfigMap, in the gitops namespace, that holds the marker.
	VersionMarkerConfigMapName = "windsor-version-marker"

	// VersionMarkerPhaseIdle marks a context with no upgrade in flight.
	VersionMarkerPhaseIdle = "idle"

	// VersionMarkerPhaseUpgrading marks a context with an upgrade in flight, which apply refuses.
	VersionMarkerPhaseUpgrading = "upgrading"
)

Variables

View Source
var ErrKustomizationFailed = errors.New("kustomization failed")

ErrKustomizationFailed marks a WaitForKustomizations error from a Kustomization that will not become Ready without a change. A BuildFailed condition and a failed HelmRelease match it.

Functions

func CheckKustomizePaths added in v0.10.0

func CheckKustomizePaths(bp *blueprintv1alpha1.Blueprint, projectRoot, basePrefix string) (problems []string, skipped []string)

CheckKustomizePaths returns one message for each kustomization of bp whose directory or component directory is missing from the project. It checks only kustomizations that read the project itself (the default source, a GitRepository named bp.Metadata.Name). It skips every other source, because a remote OCI or Git source holds its own files. The skipped list names the kustomizations it skipped. projectRoot is the project root and basePrefix is the base directory relative to it, as in FluxKustomization. An empty component is a conditional slot with no component, and the check ignores it.

func FindMisplacedKustomizeDirs added in v0.10.0

func FindMisplacedKustomizeDirs(projectRoot, basePrefix string) []string

FindMisplacedKustomizeDirs returns the kustomize directories under <base>/contexts, relative to the project root. Flux reads <base>/kustomize only, so manifests under contexts/_template/kustomize never resolve. It returns nil when contexts/ does not exist.

func FluxKustomization added in v0.10.0

func FluxKustomization(k *blueprintv1alpha1.Kustomization, basePrefix, namespace, defaultSourceName string, sources []blueprintv1alpha1.Source, mode constants.GitopsMode, configMaps ...map[string]map[string]string) kustomizev1.Kustomization

FluxKustomization converts k with Kustomization.ToFluxKustomization. When the result reads the default source as a GitRepository, the source is the project itself, and basePrefix goes in front of spec.path. basePrefix is the base directory relative to the project root, and is empty for none.

func MisplacedKustomizeMessage added in v0.10.0

func MisplacedKustomizeMessage(dir, basePrefix string) string

MisplacedKustomizeMessage formats the warning for a kustomize directory that Flux cannot reach.

func SourcesEqual added in v0.9.0

func SourcesEqual(a, b map[string]SourceRef) bool

SourcesEqual reports whether two applied-source sets are identical: the same source names, each carrying the same URL and resolved ref. It is the version-equality test the apply gate uses — equal sets mean the blueprint matches what is applied, so apply may reconcile in place rather than redirect to upgrade. SourceRef is a plain comparable struct, so values compare by field.

Types

type BaseKubernetesManager

type BaseKubernetesManager struct {
	Shims  *Shims
	Timing Timing
	// contains filtered or unexported fields
}

BaseKubernetesManager implements the KubernetesManager interface. Shims and Timing are exported so that a caller can replace the clock and the waits.

func NewKubernetesManager

func NewKubernetesManager(kubernetesClient client.KubernetesClient, configHandler config.ConfigHandler) *BaseKubernetesManager

NewKubernetesManager returns a BaseKubernetesManager with the default timing. It panics on a nil argument. The configHandler supplies the context name and id for the ownership labels.

func (*BaseKubernetesManager) ApplyBlueprint

func (k *BaseKubernetesManager) ApplyBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error

ApplyBlueprint applies a blueprint in this order: the namespace, the repository and the remote sources, the blueprint ConfigMaps, then each Kustomization with its values ConfigMap. It skips destroy-only Kustomizations and the local template source. Each Kustomization and, through CommonMetadata, each resource it manages gets the context ownership labels. It stops at the first step that fails.

func (*BaseKubernetesManager) ApplyConfigMap

func (k *BaseKubernetesManager) ApplyConfigMap(name, namespace string, data map[string]string) error

ApplyConfigMap creates or updates a ConfigMap using SSA. It returns a WindsorError, and writes nothing, when a value still holds an unresolved expression such as terraform_output().

func (*BaseKubernetesManager) ApplyGitRepository

func (k *BaseKubernetesManager) ApplyGitRepository(repo *sourcev1.GitRepository) error

ApplyGitRepository creates or updates a GitRepository resource using SSA

func (*BaseKubernetesManager) ApplyKustomization

func (k *BaseKubernetesManager) ApplyKustomization(kustomization kustomizev1.Kustomization) error

ApplyKustomization creates or updates a Kustomization resource using SSA

func (*BaseKubernetesManager) ApplyOCIRepository

func (k *BaseKubernetesManager) ApplyOCIRepository(repo *sourcev1.OCIRepository) error

ApplyOCIRepository creates or updates an OCIRepository resource using SSA

func (*BaseKubernetesManager) ApplySecret added in v0.9.0

func (k *BaseKubernetesManager) ApplySecret(name, namespace, secretType string, stringData map[string]string, owner string) error

ApplySecret creates or updates a Secret using SSA, with plaintext values in stringData that it never logs. A non-empty secretType sets the Secret type and keeps stringData unchanged. An empty secretType gets the type from the data: docker-username and docker-password, or a .dockerconfigjson key, give a dockerconfigjson Secret; other data gives an Opaque one. Kubernetes rejects a change of Secret.type, so it deletes a Secret of another type first. It sets the context labels and a secret-owner label that names owner, for PruneSecrets.

func (*BaseKubernetesManager) ApplyVersionMarker added in v0.9.0

func (k *BaseKubernetesManager) ApplyVersionMarker(namespace string, marker VersionMarker) error

ApplyVersionMarker writes the applied-version marker ConfigMap to the namespace, recording which blueprint version the context is running. The marker is stored as JSON in a single ConfigMap so its encoding can evolve without churning Kustomization labels.

func (*BaseKubernetesManager) CreateNamespace

func (k *BaseKubernetesManager) CreateNamespace(name string) error

CreateNamespace creates a new namespace

func (*BaseKubernetesManager) DeleteBlueprint

func (k *BaseKubernetesManager) DeleteBlueprint(ctx context.Context, blueprint *blueprintv1alpha1.Blueprint, namespace string) error

DeleteBlueprint runs the destroy-only Kustomizations, then deletes the regular ones, dependents first. Each delete waits under spec.deletionPolicy=WaitForTermination, so cloud resources release first. When a regular delete fails, it skips only the dependency closure of that Kustomization. A retry walks the full blueprint again, and a Kustomization that is already gone returns at once.

func (*BaseKubernetesManager) DeleteKustomization

func (k *BaseKubernetesManager) DeleteKustomization(ctx context.Context, name, namespace string) error

DeleteKustomization deletes a Kustomization and waits until it disappears. The wait grows to spec.timeout and with the inventory size. After the base timeout, the wait fails early when the only pods left in its terminating namespaces are being deleted on nodes that are not Ready. After the wait, it checks the last known inventory, and gives a live entry a few more polls before it reports that entry. The cluster stays up, so an object without a finalizer that is still live also counts as a leftover.

func (*BaseKubernetesManager) GetHelmReleasesForKustomization

func (k *BaseKubernetesManager) GetHelmReleasesForKustomization(name, namespace string) ([]helmv2.HelmRelease, error)

GetHelmReleasesForKustomization gets HelmReleases associated with a Kustomization

func (*BaseKubernetesManager) GetKustomizationInventory added in v0.9.0

func (k *BaseKubernetesManager) GetKustomizationInventory(name, namespace string) ([]InventoryEntry, error)

GetKustomizationInventory returns the resources in status.inventory of a Kustomization, which are the resources that Flux deletes with it. It returns nil when the Kustomization is absent, and an empty list when it has no inventory yet. It drops an entry that does not decode, so one bad entry does not fail a destroy preview. It returns an API read error.

func (*BaseKubernetesManager) GetKustomizationReadiness added in v0.9.0

func (k *BaseKubernetesManager) GetKustomizationReadiness(names []string) (map[string]bool, error)

GetKustomizationReadiness returns whether each named Kustomization currently reports Ready=True, in the gitops namespace. Unlike GetKustomizationStatus it never fails on a Kustomization in a failed state — a failed one is simply reported not-ready — so a convergence driver can keep nudging it toward Ready rather than aborting. Names absent from the cluster report false; only an API list error propagates.

func (*BaseKubernetesManager) GetKustomizationStatus

func (k *BaseKubernetesManager) GetKustomizationStatus(names []string) (map[string]bool, error)

GetKustomizationStatus returns a map indicating readiness for each specified kustomization in the default Flux system namespace. If a kustomization is not found, its status is set to false. If any kustomization has a Ready condition with Status False and a Reason in kustomizationFailureReasons, an error is returned with the failure message.

func (*BaseKubernetesManager) GetNodeNamesByAddress added in v0.10.0

func (k *BaseKubernetesManager) GetNodeNamesByAddress(_ context.Context, address string) ([]string, error)

GetNodeNamesByAddress returns the names of the Node objects that have address as an InternalIP, an ExternalIP, or a name. The result is empty when no Node object matches.

func (*BaseKubernetesManager) GetNodeReadyStatus

func (k *BaseKubernetesManager) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)

GetNodeReadyStatus returns the Ready condition status of each node in nodeNames. Each value matches a node by its name, InternalIP, or ExternalIP, and is the key in the result.

func (*BaseKubernetesManager) GetVersionMarker added in v0.9.0

func (k *BaseKubernetesManager) GetVersionMarker(namespace string) (VersionMarker, bool, error)

GetVersionMarker reads the version marker ConfigMap from namespace. It returns false when the ConfigMap is missing, before bootstrap, or has no data, on a legacy cluster. It returns an error only when a read or decode fails, so a caller can tell "no marker" from "cluster unreachable".

func (*BaseKubernetesManager) KustomizationExists added in v0.9.0

func (k *BaseKubernetesManager) KustomizationExists(name, namespace string) (bool, error)

KustomizationExists returns true if a Kustomization resource with the given name exists in the given namespace. Returns false (not an error) when the resource is simply absent; propagates other API errors.

func (*BaseKubernetesManager) ListPrunableKustomizations added in v0.9.0

func (k *BaseKubernetesManager) ListPrunableKustomizations(blueprint *blueprintv1alpha1.Blueprint, namespace string) ([]string, error)

ListPrunableKustomizations returns the names of this context's Kustomizations that the blueprint no longer declares — exactly what PruneBlueprint would delete, in reverse-dependency order. It is the read-only input to plan's prune preview and upgrade's confirmation gate; it deletes nothing.

func (*BaseKubernetesManager) NamespaceExists added in v0.9.0

func (k *BaseKubernetesManager) NamespaceExists(name string) (bool, error)

NamespaceExists reports whether the named namespace exists in the cluster. Namespaces are cluster-scoped, so the lookup passes an empty namespace to GetResource. A NotFound is reported as (false, nil); any other API error propagates.

func (*BaseKubernetesManager) PruneBlueprint added in v0.9.0

func (k *BaseKubernetesManager) PruneBlueprint(ctx context.Context, blueprint *blueprintv1alpha1.Blueprint, namespace string) error

PruneBlueprint deletes the Kustomizations of this context that the blueprint does not declare. It selects on the windsorcli.dev/context-id label, so it never touches another context's objects. It deletes dependents first, from the live spec.dependsOn, and joins the delete errors. The caller MUST pass the blueprint with its CRD layers, or prune deletes those layers.

func (*BaseKubernetesManager) PruneSecrets added in v0.9.0

func (k *BaseKubernetesManager) PruneSecrets(desired map[string]map[string]bool) error

PruneSecrets deletes each secret that the CLI placed for this context and that desired does not hold. desired maps a namespace to the set of secret names just placed there. It selects on the context id and the secret-owner label, which only ApplySecret sets. Thus it never deletes a Flux secret that has the context labels from CommonMetadata. It returns a WindsorError when the context id is empty or is not a valid label value.

func (*BaseKubernetesManager) RemoveStaleNodes added in v0.10.0

func (k *BaseKubernetesManager) RemoveStaleNodes(ctx context.Context, address string, previousNames []string) ([]string, error)

RemoveStaleNodes deletes the Node objects that a renamed node left behind. previousNames are the names that Node objects at address had before the node restarted. A Node object is deleted only when it is in previousNames, is not Ready, and a Ready Node object at address has a name that is not in previousNames. It never deletes a Ready Node object. It does nothing when the node kept its name. The replacement can register after the node reports healthy, so it polls until the replacement appears or Timing.NodeRegistrationTimeout ends. It returns the names it deleted.

func (*BaseKubernetesManager) RollWorkloadsForSecret added in v0.9.0

func (k *BaseKubernetesManager) RollWorkloadsForSecret(ctx context.Context, namespace, secretName, digest string) error

RollWorkloadsForSecret sets digest as a pod-template annotation on each Deployment, StatefulSet, and DaemonSet in namespace that consumes secretName, so Kubernetes rolls it. A workload consumes the Secret through envFrom, a secretKeyRef, or a secret volume, in any container or init container. It skips a workload that already has digest. It returns an error only on an API failure, and ctx bounds the patches.

func (*BaseKubernetesManager) SetBasePrefix added in v0.10.0

func (k *BaseKubernetesManager) SetBasePrefix(basePrefix string)

SetBasePrefix sets the base directory, relative to the project root, that goes in front of the kustomize path of the project's own git source. With no prefix, the manager writes the path as the blueprint names it.

func (*BaseKubernetesManager) WaitForKubernetesHealthy

func (k *BaseKubernetesManager) WaitForKubernetesHealthy(ctx context.Context, endpoint string, outputFunc func(string), nodeNames ...string) error

WaitForKubernetesHealthy waits until the API, and each named node, stays healthy for healthCheckSettleDuration. A machine config apply can restart the apiserver after a first healthy check, so one success is not enough. A failure during the settle period starts it again. The settle period is cut to fit the context deadline, less one poll interval, so a caller with a short timeout can still succeed. On timeout, the error carries the last failure.

func (*BaseKubernetesManager) WaitForKustomizations

func (k *BaseKubernetesManager) WaitForKustomizations(ctx context.Context, blueprint *blueprintv1alpha1.Blueprint, layers KustomizationReporter) error

WaitForKustomizations waits until each Kustomization is Ready, within the timeout of the longest dependency chain. It follows a watch on the Kustomizations and returns ctx.Err() on cancellation. BuildFailed fails at once. List errors, ReconciliationFailed, and ArtifactFailed fail after an error budget: a quarter of the total, or the own timeout of the Kustomization when that is shorter, and never less than the minimum. Flux reports ArtifactFailed for a short time when the source artifact changes during a reconcile, then retries. At the timeout, or when ReconciliationFailed or ArtifactFailed uses up its budget, a failed HelmRelease of a Kustomization that is not Ready fails the wait as a hard failure. Otherwise the timeout error names each Kustomization that is not Ready. A BuildFailed or HelmRelease failure matches ErrKustomizationFailed. It reports one step per Kustomization to layers, starting each when its dependencies are Ready and failing the one that fails the wait.

type InventoryEntry added in v0.9.0

type InventoryEntry struct {
	Group     string
	Kind      string
	Namespace string
	Name      string
}

InventoryEntry identifies one resource Flux is tracking for a Kustomization, decoded from a single .status.inventory.entries[] record. The encoded form flux writes is "<namespace>_<name>_<group>_<kind>"; namespace is empty for cluster-scoped resources, group is empty for core API objects ("v1"). These entries are exactly what flux deletes when a Kustomization is removed, so they are the truthful source for "what will go away on destroy."

type KubernetesManager

type KubernetesManager interface {
	DeleteKustomization(ctx context.Context, name, namespace string) error
	WaitForKustomizations(ctx context.Context, blueprint *blueprintv1alpha1.Blueprint, layers KustomizationReporter) error
	ApplySecret(name, namespace, secretType string, stringData map[string]string, owner string) error
	PruneSecrets(desired map[string]map[string]bool) error
	RollWorkloadsForSecret(ctx context.Context, namespace, secretName, digest string) error
	GetHelmReleasesForKustomization(name, namespace string) ([]helmv2.HelmRelease, error)
	GetKustomizationReadiness(names []string) (map[string]bool, error)
	KustomizationExists(name, namespace string) (bool, error)
	NamespaceExists(name string) (bool, error)
	GetKustomizationInventory(name, namespace string) ([]InventoryEntry, error)
	WaitForKubernetesHealthy(ctx context.Context, endpoint string, outputFunc func(string), nodeNames ...string) error
	GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
	GetNodeNamesByAddress(ctx context.Context, address string) ([]string, error)
	RemoveStaleNodes(ctx context.Context, address string, previousNames []string) ([]string, error)
	ApplyBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
	DeleteBlueprint(ctx context.Context, blueprint *blueprintv1alpha1.Blueprint, namespace string) error
	PruneBlueprint(ctx context.Context, blueprint *blueprintv1alpha1.Blueprint, namespace string) error
	ListPrunableKustomizations(blueprint *blueprintv1alpha1.Blueprint, namespace string) ([]string, error)
	ApplyVersionMarker(namespace string, marker VersionMarker) error
	GetVersionMarker(namespace string) (VersionMarker, bool, error)
}

KubernetesManager defines methods for Kubernetes resource management

type KustomizationReporter added in v0.10.0

type KustomizationReporter interface {
	Start(name string)
	Progress(name, text string)
	Done(name string)
	Fail(name string, err error)
}

KustomizationReporter receives the per-Kustomization steps of a readiness wait.

type MockKubernetesManager

type MockKubernetesManager struct {
	DeleteKustomizationFunc             func(name, namespace string) error
	WaitForKustomizationsFunc           func(ctx context.Context, blueprint *blueprintv1alpha1.Blueprint, layers KustomizationReporter) error
	GetKustomizationReadinessFunc       func(names []string) (map[string]bool, error)
	ApplySecretFunc                     func(name, namespace, secretType string, stringData map[string]string, owner string) error
	PruneSecretsFunc                    func(desired map[string]map[string]bool) error
	RollWorkloadsForSecretFunc          func(ctx context.Context, namespace, secretName, digest string) error
	ApplyVersionMarkerFunc              func(namespace string, marker VersionMarker) error
	GetVersionMarkerFunc                func(namespace string) (VersionMarker, bool, error)
	GetHelmReleasesForKustomizationFunc func(name, namespace string) ([]helmv2.HelmRelease, error)
	KustomizationExistsFunc             func(name, namespace string) (bool, error)
	NamespaceExistsFunc                 func(name string) (bool, error)
	GetKustomizationInventoryFunc       func(name, namespace string) ([]InventoryEntry, error)
	WaitForKubernetesHealthyFunc        func(ctx context.Context, endpoint string, outputFunc func(string), nodeNames ...string) error
	GetNodeReadyStatusFunc              func(ctx context.Context, nodeNames []string) (map[string]bool, error)
	GetNodeNamesByAddressFunc           func(ctx context.Context, address string) ([]string, error)
	RemoveStaleNodesFunc                func(ctx context.Context, address string, previousNames []string) ([]string, error)
	ApplyBlueprintFunc                  func(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
	DeleteBlueprintFunc                 func(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
	PruneBlueprintFunc                  func(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
	ListPrunableKustomizationsFunc      func(blueprint *blueprintv1alpha1.Blueprint, namespace string) ([]string, error)
}

MockKubernetesManager is a mock implementation of KubernetesManager interface for testing

func NewMockKubernetesManager

func NewMockKubernetesManager() *MockKubernetesManager

NewMockKubernetesManager creates a new instance of MockKubernetesManager

func (*MockKubernetesManager) ApplyBlueprint

func (m *MockKubernetesManager) ApplyBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error

ApplyBlueprint implements KubernetesManager interface

func (*MockKubernetesManager) ApplySecret added in v0.9.0

func (m *MockKubernetesManager) ApplySecret(name, namespace, secretType string, stringData map[string]string, owner string) error

ApplySecret implements KubernetesManager interface

func (*MockKubernetesManager) ApplyVersionMarker added in v0.9.0

func (m *MockKubernetesManager) ApplyVersionMarker(namespace string, marker VersionMarker) error

ApplyVersionMarker implements KubernetesManager interface

func (*MockKubernetesManager) DeleteBlueprint

func (m *MockKubernetesManager) DeleteBlueprint(_ context.Context, blueprint *blueprintv1alpha1.Blueprint, namespace string) error

DeleteBlueprint implements KubernetesManager interface

func (*MockKubernetesManager) DeleteKustomization

func (m *MockKubernetesManager) DeleteKustomization(_ context.Context, name, namespace string) error

DeleteKustomization implements KubernetesManager interface

func (*MockKubernetesManager) GetHelmReleasesForKustomization

func (m *MockKubernetesManager) GetHelmReleasesForKustomization(name, namespace string) ([]helmv2.HelmRelease, error)

GetHelmReleasesForKustomization implements KubernetesManager interface

func (*MockKubernetesManager) GetKustomizationInventory added in v0.9.0

func (m *MockKubernetesManager) GetKustomizationInventory(name, namespace string) ([]InventoryEntry, error)

GetKustomizationInventory implements KubernetesManager interface

func (*MockKubernetesManager) GetKustomizationReadiness added in v0.9.0

func (m *MockKubernetesManager) GetKustomizationReadiness(names []string) (map[string]bool, error)

GetKustomizationReadiness implements KubernetesManager interface. The default reports every requested kustomization Ready so a convergence pass returns immediately in tests that do not exercise it; tests that drive convergence set GetKustomizationReadinessFunc.

func (*MockKubernetesManager) GetNodeNamesByAddress added in v0.10.0

func (m *MockKubernetesManager) GetNodeNamesByAddress(ctx context.Context, address string) ([]string, error)

GetNodeNamesByAddress implements KubernetesManager interface. The default returns no names.

func (*MockKubernetesManager) GetNodeReadyStatus

func (m *MockKubernetesManager) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)

GetNodeReadyStatus returns a map of node names to their Ready condition status.

func (*MockKubernetesManager) GetVersionMarker added in v0.9.0

func (m *MockKubernetesManager) GetVersionMarker(namespace string) (VersionMarker, bool, error)

GetVersionMarker implements KubernetesManager interface

func (*MockKubernetesManager) KustomizationExists added in v0.9.0

func (m *MockKubernetesManager) KustomizationExists(name, namespace string) (bool, error)

KustomizationExists implements KubernetesManager interface

func (*MockKubernetesManager) ListPrunableKustomizations added in v0.9.0

func (m *MockKubernetesManager) ListPrunableKustomizations(blueprint *blueprintv1alpha1.Blueprint, namespace string) ([]string, error)

ListPrunableKustomizations implements KubernetesManager interface

func (*MockKubernetesManager) NamespaceExists added in v0.9.0

func (m *MockKubernetesManager) NamespaceExists(name string) (bool, error)

NamespaceExists implements KubernetesManager interface

func (*MockKubernetesManager) PruneBlueprint added in v0.9.0

func (m *MockKubernetesManager) PruneBlueprint(_ context.Context, blueprint *blueprintv1alpha1.Blueprint, namespace string) error

PruneBlueprint implements KubernetesManager interface

func (*MockKubernetesManager) PruneSecrets added in v0.9.0

func (m *MockKubernetesManager) PruneSecrets(desired map[string]map[string]bool) error

PruneSecrets implements KubernetesManager interface

func (*MockKubernetesManager) RemoveStaleNodes added in v0.10.0

func (m *MockKubernetesManager) RemoveStaleNodes(ctx context.Context, address string, previousNames []string) ([]string, error)

RemoveStaleNodes implements KubernetesManager interface. The default deletes nothing.

func (*MockKubernetesManager) RollWorkloadsForSecret added in v0.9.0

func (m *MockKubernetesManager) RollWorkloadsForSecret(ctx context.Context, namespace, secretName, digest string) error

RollWorkloadsForSecret implements KubernetesManager interface

func (*MockKubernetesManager) WaitForKubernetesHealthy

func (m *MockKubernetesManager) WaitForKubernetesHealthy(ctx context.Context, endpoint string, outputFunc func(string), nodeNames ...string) error

WaitForKubernetesHealthy waits for the Kubernetes API endpoint to be healthy with polling and timeout

func (*MockKubernetesManager) WaitForKustomizations

func (m *MockKubernetesManager) WaitForKustomizations(ctx context.Context, blueprint *blueprintv1alpha1.Blueprint, layers KustomizationReporter) error

WaitForKustomizations implements KubernetesManager interface

type Shims

type Shims struct {
	TimeSleep        func(d time.Duration)
	TimeNow          func() time.Time
	ToUnstructured   func(obj any) (map[string]any, error)
	FromUnstructured func(obj map[string]any, target any) error
}

Shims provides testable interfaces for external dependencies

func NewShims

func NewShims() *Shims

NewShims creates a new Shims instance with default implementations

type SourceRef added in v0.9.0

type SourceRef struct {
	URL string `json:"url,omitempty"`
	Ref string `json:"ref,omitempty"`
}

SourceRef records one blueprint source as applied: its URL and resolved human reference (tag/branch/semver/commit). The resolved digest is recorded later, when the version gate that consumes it is built.

type Timing added in v0.10.0

type Timing struct {
	KustomizationWaitPollInterval        time.Duration
	KustomizationWaitMaxReadFailures     int
	KustomizationWaitMinErrorDuration    time.Duration
	KustomizationReconcileTimeout        time.Duration
	KustomizationReconcileSleep          time.Duration
	KustomizationDeletionPerEntryTimeout time.Duration
	KustomizationDeletionMaxExtraTimeout time.Duration
	KustomizationSpecTimeoutCeiling      time.Duration
	KustomizationDeleteTimeoutCeiling    time.Duration
	KustomizationAbandonedGraceMaxExtra  time.Duration
	LoadBalancerTeardownTimeout          time.Duration
	NotReadyDescribeBudget               time.Duration
	HealthCheckPollInterval              time.Duration
	HealthCheckSettleDuration            time.Duration
	NodeReadyPollInterval                time.Duration
	NodeRegistrationTimeout              time.Duration
}

Timing holds the poll intervals, timeouts, and retry limits of a BaseKubernetesManager. DefaultTiming returns the production values. Tests set small values to avoid real waits.

func DefaultTiming added in v0.10.0

func DefaultTiming() Timing

DefaultTiming returns the poll intervals, timeouts, and retry limits that Windsor uses in production.

type VersionMarker added in v0.9.0

type VersionMarker struct {
	SchemaVersion  int                  `json:"schemaVersion"`
	Phase          string               `json:"phase"`
	AppliedSources map[string]SourceRef `json:"appliedSources,omitempty"`
	TargetSources  map[string]SourceRef `json:"targetSources,omitempty"`
}

VersionMarker is the authoritative record of the blueprint version a context is running. Because a context can carry several independently-versioned sources, the "version" is the set of source refs, not a single string. Phase tracks an in-flight upgrade (idle for a settled context); the target source set is recorded by upgrade and is absent at bootstrap.

func BuildTransitionMarker added in v0.9.0

func BuildTransitionMarker(applied map[string]SourceRef, blueprint *blueprintv1alpha1.Blueprint) (VersionMarker, error)

BuildTransitionMarker returns an in-flight marker for an upgrade toward blueprint: the applied source set (empty for a legacy context) plus the blueprint's set as the target, under the upgrading phase. WriteVersionMarker replaces it with a settled marker once the upgrade succeeds.

func BuildVersionMarker added in v0.9.0

func BuildVersionMarker(blueprint *blueprintv1alpha1.Blueprint) (VersionMarker, error)

BuildVersionMarker captures a settled (idle) marker from the applied blueprint: the repository source (keyed by the blueprint name) and every declared remote source, each with its resolved reference. Local template sources are skipped — they track the working tree and have no version. It errors on a source-name collision (two sources sharing a name, or a source matching the repository's blueprint name) rather than silently overwriting and misrepresenting what was applied.

func ParseVersionMarker added in v0.9.0

func ParseVersionMarker(data map[string]string) (VersionMarker, bool, error)

ParseVersionMarker decodes a marker from ConfigMap data, reporting false when no marker is present.

func (VersionMarker) ToConfigMapData added in v0.9.0

func (m VersionMarker) ToConfigMapData() (map[string]string, error)

ToConfigMapData encodes the marker as ConfigMap data (a single JSON document).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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