Documentation
¶
Index ¶
- Constants
- func SourcesEqual(a, b map[string]SourceRef) bool
- type BaseKubernetesManager
- func (k *BaseKubernetesManager) ApplyBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
- func (k *BaseKubernetesManager) ApplyConfigMap(name, namespace string, data map[string]string) error
- func (k *BaseKubernetesManager) ApplyGitRepository(repo *sourcev1.GitRepository) error
- func (k *BaseKubernetesManager) ApplyKustomization(kustomization kustomizev1.Kustomization) error
- func (k *BaseKubernetesManager) ApplyOCIRepository(repo *sourcev1.OCIRepository) error
- func (k *BaseKubernetesManager) ApplySecret(name, namespace string, stringData map[string]string, owner string) error
- func (k *BaseKubernetesManager) ApplyVersionMarker(namespace string, marker VersionMarker) error
- func (k *BaseKubernetesManager) CheckGitRepositoryStatus() error
- func (k *BaseKubernetesManager) CreateNamespace(name string) error
- func (k *BaseKubernetesManager) DeleteBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
- func (k *BaseKubernetesManager) DeleteKustomization(name, namespace string) error
- func (k *BaseKubernetesManager) DeleteNamespace(name string) error
- func (k *BaseKubernetesManager) GetHelmReleasesForKustomization(name, namespace string) ([]helmv2.HelmRelease, error)
- func (k *BaseKubernetesManager) GetKustomizationInventory(name, namespace string) ([]InventoryEntry, error)
- func (k *BaseKubernetesManager) GetKustomizationReadiness(names []string) (map[string]bool, error)
- func (k *BaseKubernetesManager) GetKustomizationStatus(names []string) (map[string]bool, error)
- func (k *BaseKubernetesManager) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
- func (k *BaseKubernetesManager) GetVersionMarker(namespace string) (VersionMarker, bool, error)
- func (k *BaseKubernetesManager) KustomizationExists(name, namespace string) (bool, error)
- func (k *BaseKubernetesManager) ListPrunableKustomizations(blueprint *blueprintv1alpha1.Blueprint, namespace string) ([]string, error)
- func (k *BaseKubernetesManager) NamespaceExists(name string) (bool, error)
- func (k *BaseKubernetesManager) PruneBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
- func (k *BaseKubernetesManager) PruneSecrets(desired map[string]map[string]bool) error
- func (k *BaseKubernetesManager) RollWorkloadsForSecret(ctx context.Context, namespace, secretName, digest string) error
- func (k *BaseKubernetesManager) WaitForKubernetesHealthy(ctx context.Context, endpoint string, outputFunc func(string), ...) error
- func (k *BaseKubernetesManager) WaitForKustomizations(ctx context.Context, message string, blueprint *blueprintv1alpha1.Blueprint) error
- type InventoryEntry
- type KubernetesManager
- type MockKubernetesManager
- func (m *MockKubernetesManager) ApplyBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
- func (m *MockKubernetesManager) ApplyConfigMap(name, namespace string, data map[string]string) error
- func (m *MockKubernetesManager) ApplyGitRepository(repo *sourcev1.GitRepository) error
- func (m *MockKubernetesManager) ApplyKustomization(kustomization kustomizev1.Kustomization) error
- func (m *MockKubernetesManager) ApplyOCIRepository(repo *sourcev1.OCIRepository) error
- func (m *MockKubernetesManager) ApplySecret(name, namespace string, stringData map[string]string, owner string) error
- func (m *MockKubernetesManager) ApplyVersionMarker(namespace string, marker VersionMarker) error
- func (m *MockKubernetesManager) CheckGitRepositoryStatus() error
- func (m *MockKubernetesManager) CreateNamespace(name string) error
- func (m *MockKubernetesManager) DeleteBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
- func (m *MockKubernetesManager) DeleteKustomization(name, namespace string) error
- func (m *MockKubernetesManager) DeleteNamespace(name string) error
- func (m *MockKubernetesManager) GetHelmReleasesForKustomization(name, namespace string) ([]helmv2.HelmRelease, error)
- func (m *MockKubernetesManager) GetKustomizationInventory(name, namespace string) ([]InventoryEntry, error)
- func (m *MockKubernetesManager) GetKustomizationReadiness(names []string) (map[string]bool, error)
- func (m *MockKubernetesManager) GetKustomizationStatus(names []string) (map[string]bool, error)
- func (m *MockKubernetesManager) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
- func (m *MockKubernetesManager) GetVersionMarker(namespace string) (VersionMarker, bool, error)
- func (m *MockKubernetesManager) KustomizationExists(name, namespace string) (bool, error)
- func (m *MockKubernetesManager) ListPrunableKustomizations(blueprint *blueprintv1alpha1.Blueprint, namespace string) ([]string, error)
- func (m *MockKubernetesManager) NamespaceExists(name string) (bool, error)
- func (m *MockKubernetesManager) PruneBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
- func (m *MockKubernetesManager) PruneSecrets(desired map[string]map[string]bool) error
- func (m *MockKubernetesManager) RollWorkloadsForSecret(ctx context.Context, namespace, secretName, digest string) error
- func (m *MockKubernetesManager) WaitForKubernetesHealthy(ctx context.Context, endpoint string, outputFunc func(string), ...) error
- func (m *MockKubernetesManager) WaitForKustomizations(ctx context.Context, message string, blueprint *blueprintv1alpha1.Blueprint) error
- type Shims
- type SourceRef
- type VersionMarker
Constants ¶
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 is the phase of a context with an upgrade in flight. apply's // version gate refuses any non-idle phase, so an interrupted upgrade is resumed, not reconciled. VersionMarkerPhaseUpgrading = "upgrading" )
Variables ¶
This section is empty.
Functions ¶
func SourcesEqual ¶ added in v0.9.0
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 {
// contains filtered or unexported fields
}
BaseKubernetesManager implements KubernetesManager interface
func NewKubernetesManager ¶
func NewKubernetesManager(kubernetesClient client.KubernetesClient, configHandler config.ConfigHandler) *BaseKubernetesManager
NewKubernetesManager creates a new instance of BaseKubernetesManager. The configHandler is used to retrieve context name and context ID for CommonMetadata labels.
func (*BaseKubernetesManager) ApplyBlueprint ¶
func (k *BaseKubernetesManager) ApplyBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
ApplyBlueprint applies the entire blueprint to the cluster in the proper sequence. It creates the target namespace, applies all blueprint source repositories (Git and OCI), applies all individual sources, applies any standalone ConfigMaps, and finally applies all kustomizations and their associated ConfigMaps. This orchestrates a complete blueprint installation following the intended order. Context ownership labels are stamped on each Kustomization's ObjectMeta (so the objects are selectable by context) and propagated to managed resources via CommonMetadata, using context info from the config handler. Returns an error if any step fails.
func (*BaseKubernetesManager) ApplyConfigMap ¶
func (k *BaseKubernetesManager) ApplyConfigMap(name, namespace string, data map[string]string) error
ApplyConfigMap creates or updates a ConfigMap using SSA
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 string, stringData map[string]string, owner string) error
ApplySecret creates or updates a Secret using SSA. Values are supplied as plaintext in stringData (write-only; the API server folds them into data) and are never logged. Mirrors ApplyConfigMap's server-side-apply handling, including its immutable-field guard: Kubernetes rejects an update that changes Secret.type, so if an existing Secret's type differs from the newly resolved one, ApplySecret deletes it first rather than SSA-merging a rejected change. It stamps the context ownership labels plus a secret-owner label naming the kustomization the secret belongs to; that label is set only by CLI placement (never by Flux), so PruneSecrets can find and reclaim CLI-placed secrets without ever touching a Flux-managed one. The Secret's type and stringData are resolved by secretTypeAndData: stringData already carrying ".dockerconfigjson", or carrying docker-username/docker-password (docker-server optional), produces a kubernetes.io/dockerconfigjson Secret for imagePullSecrets; anything else stays Opaque.
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) CheckGitRepositoryStatus ¶
func (k *BaseKubernetesManager) CheckGitRepositoryStatus() error
CheckGitRepositoryStatus checks the status of all GitRepository and OCIRepository resources
func (*BaseKubernetesManager) CreateNamespace ¶
func (k *BaseKubernetesManager) CreateNamespace(name string) error
CreateNamespace creates a new namespace
func (*BaseKubernetesManager) DeleteBlueprint ¶
func (k *BaseKubernetesManager) DeleteBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
DeleteBlueprint tears the blueprint down in two phases:
Destroy-only kustomizations: apply, wait ready, delete in reverse-topological order. These are blueprint entries that exist only at destroy time for bespoke teardown work (e.g. backups, snapshots, last-mile state exports). Any errors from this phase are joined and returned immediately — the destroy walk does not start until the destroy hooks succeed.
Regular kustomizations in reverse-topological order. Each Kustomization carries spec.deletionPolicy=WaitForTermination (set at apply time by ToFluxKustomization), so DELETE blocks until every managed resource is fully gone from etcd. The chain for cloud resources is:
K8s DELETE → controller's finalizer holds the object in etcd → controller calls cloud API to release external state → finalizer lifts → object NotFound → WaitForTermination satisfied
This is what makes CSI volumes, LB Services, Ingresses, and cert-manager Certificates clean up cloud-side without the orchestrator ever calling a cloud API. external-dns is the one outlier — it has no finalizer; the DNS record is removed on its next reconcile after the K8s object disappears.
Phase 2 aborts on the first per-Kustomization failure (typically an inventory item stuck on a cloud-controller finalizer). Continuing the walk would tear down upstream controllers (lb-base, dns, pki-base) still needed to lift those finalizers, turning a recoverable stuck-Kustomization into a cascade of orphaned cloud resources. Re-running destroy after the operator restores the controller picks up where it left off — already-deleted Kustomizations short-circuit to NotFound on retry.
func (*BaseKubernetesManager) DeleteKustomization ¶
func (k *BaseKubernetesManager) DeleteKustomization(name, namespace string) error
DeleteKustomization removes a Kustomization resource using background deletion. Background deletion allows the kustomization to enter "Terminating" state while its children are deleted in the background. The method waits for the deletion to complete.
On timeout (Flux's WaitForTermination has not lifted its finalizer within kustomizationReconcileTimeout), the method returns an error rather than stripping finalizers. The timeout almost always means an inventory item is stuck on a cloud-controller finalizer (CSI external-attacher, aws-load-balancer-controller's service.k8s.aws/resources, cert-manager) — stripping the Kustomization's own finalizer at that point reaps the Kustomization from etcd but leaves the inventory items orphaned in their namespace, where the controller that should lift their finalizers may already be torn down. The orphan then blocks namespace termination and (worse) lets terraform proceed to destroy the cluster while cloud resources (LBs, EBS volumes, DNS records) leak. Returning an error here surfaces the stuck state so the operator can re-deploy the controller, let it finish cleanup, and re-run destroy — vs. silently masking the failure.
func (*BaseKubernetesManager) DeleteNamespace ¶
func (k *BaseKubernetesManager) DeleteNamespace(name string) error
DeleteNamespace deletes the specified namespace using foreground deletion. Foreground deletion ensures all resources in the namespace are removed before the namespace is deleted. This method waits for the deletion to complete before returning. Returns nil if the namespace is deleted successfully, or an error if deletion fails or times out.
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 list of resources Flux is currently tracking for the named Kustomization, decoded from its .status.inventory.entries field. This is what flux uses to drive prune behavior, so it is the authoritative source for "what will be deleted when this Kustomization is removed." Returns (nil, nil) when the Kustomization itself is absent (a destroy-plan caller should treat that as "not deployed" rather than an error). Returns an empty slice when the Kustomization exists but has no inventory yet (e.g., suspended, or never reconciled). API errors reading the Kustomization or its inventory propagate. Individual entries that fail to decode (malformed IDs, unexpected field shapes) are silently dropped — flux always emits well-formed IDs, so this branch is rare in practice, and resilience matters more than completeness here: failing the whole destroy preview because of one corrupt entry would be worse than rendering a slightly truncated list.
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 Reason "ReconciliationFailed", an error is returned with the failure message.
func (*BaseKubernetesManager) GetNodeReadyStatus ¶
func (k *BaseKubernetesManager) GetNodeReadyStatus(ctx context.Context, nodeNames []string) (map[string]bool, error)
GetNodeReadyStatus returns a map of node names to their Ready condition status. Returns a map of node names to Ready status (true if Ready, false if NotReady), or an error if listing fails.
func (*BaseKubernetesManager) GetVersionMarker ¶ added in v0.9.0
func (k *BaseKubernetesManager) GetVersionMarker(namespace string) (VersionMarker, bool, error)
GetVersionMarker reads the applied-version marker ConfigMap from the namespace, reporting false when no marker is present — a missing ConfigMap (pre-bootstrap context) or one without marker data (legacy cluster). It returns an error only on a real read or decode failure, so callers can tell "no marker yet" (proceed as legacy) apart from "could not read the marker" (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(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
PruneBlueprint deletes Kustomizations belonging to the current context that are no longer part of the blueprint. It scopes strictly to this context — only objects carrying the windsorcli.dev/context-id label for this context are considered, so kustomizations owned by other contexts (or by no Windsor context) are never touched. Every non-DestroyOnly kustomization in the blueprint is treated as desired; the live remainder is deleted in reverse-dependency order (read from each object's live spec.dependsOn) so dependents tear down before their dependencies, each honoring its own deletionPolicy. The caller passes the same prepared blueprint Install applied (CRD layers included) so the synthesized crds/crds-<source> layers are recognized as desired and not pruned. Deletion errors are collected and joined rather than aborting on the first.
func (*BaseKubernetesManager) PruneSecrets ¶ added in v0.9.0
func (k *BaseKubernetesManager) PruneSecrets(desired map[string]map[string]bool) error
PruneSecrets deletes the CLI-placed secrets for this context that the latest placement no longer wants, reconciling the cluster to the desired set. desired maps a namespace to the set of secret names just placed there; a secret whose (namespace, name) is absent is deleted. It lists only secrets bearing this context's id and the secret-owner marker — a label set solely by ApplySecret, never by Flux — so it reclaims exactly what the CLI placed (a secret dropped from a fan-out list, a secret removed from a system, or every CLI secret when desired is empty) and never a Flux-managed secret that merely inherited the context labels via CommonMetadata. It fails closed when the context id is unset or is not a valid label value, since without a well-formed id pruning cannot be scoped to this context — a malformed id would otherwise build a selector the API server rejects, failing every placement with an opaque error rather than a message that names the bad id.
func (*BaseKubernetesManager) RollWorkloadsForSecret ¶ added in v0.9.0
func (k *BaseKubernetesManager) RollWorkloadsForSecret(ctx context.Context, namespace, secretName, digest string) error
RollWorkloadsForSecret rolls the workloads in a namespace that consume the named Secret so they pick up new content, the way Kubernetes only ever rolls on a pod-template change. Because the CLI holds the resolved plaintext, it passes a precomputed content digest and stamps it as a pod-template annotation (checksum.windsorcli.dev/<secret>) on every Deployment, StatefulSet, and DaemonSet whose pod spec references the Secret via envFrom, a secretKeyRef, or a secret volume — including init containers. The digest is one-way and never surfaced beyond the namespace, so a reader of the annotation learns nothing the Secret's own RBAC did not already grant. A workload already carrying the digest is left untouched (idempotent, so unchanged content does not churn pods); a workload that does not reference the Secret is never patched. Finding no consumers is not an error — on a first apply the workload is created later by Flux and reads the Secret fresh — so this returns an error only on an API failure. The caller's context bounds the patch calls so a slow API server cannot outlast its deadline.
func (*BaseKubernetesManager) WaitForKubernetesHealthy ¶
func (k *BaseKubernetesManager) WaitForKubernetesHealthy(ctx context.Context, endpoint string, outputFunc func(string), nodeNames ...string) error
WaitForKubernetesHealthy waits for the Kubernetes API to become healthy within the context deadline. If nodeNames are provided, verifies all specified nodes reach Ready state before returning. Returns an error if the API is unreachable or any specified nodes are not Ready within the deadline.
func (*BaseKubernetesManager) WaitForKustomizations ¶
func (k *BaseKubernetesManager) WaitForKustomizations(ctx context.Context, message string, blueprint *blueprintv1alpha1.Blueprint) error
WaitForKustomizations waits for kustomizations to be ready, calculating the timeout from the longest dependency chain in the blueprint. Outputs a debug message describing the total wait timeout being used before beginning polling. The wait also honors ctx: a cancelled or deadline-exceeded context ends the wait immediately and returns ctx.Err(), so a parent SIGTERM/Ctrl+C or command deadline can interrupt it (rather than requiring a SIGKILL that bypasses the caller's defer cleanup). A not-found GetResource error is treated as not-ready-yet and keeps polling. Any other error (auth, connection, RBAC) counts toward kustomizationWaitMaxConsecutiveErrors: a single transient blip (a brief apiserver restart, a load-balancer failover) is tolerated and retried on the next tick, but a persistent failure like broken cluster auth ends the wait immediately with the underlying error surfaced, rather than silently retrying it for the full timeout budget.
type InventoryEntry ¶ added in v0.9.0
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 {
ApplyKustomization(kustomization kustomizev1.Kustomization) error
DeleteKustomization(name, namespace string) error
WaitForKustomizations(ctx context.Context, message string, blueprint *blueprintv1alpha1.Blueprint) error
CreateNamespace(name string) error
DeleteNamespace(name string) error
ApplyConfigMap(name, namespace string, data map[string]string) error
ApplySecret(name, namespace 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)
ApplyGitRepository(repo *sourcev1.GitRepository) error
ApplyOCIRepository(repo *sourcev1.OCIRepository) error
CheckGitRepositoryStatus() error
GetKustomizationStatus(names []string) (map[string]bool, 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)
ApplyBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
DeleteBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
PruneBlueprint(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 MockKubernetesManager ¶
type MockKubernetesManager struct {
ApplyKustomizationFunc func(kustomization kustomizev1.Kustomization) error
DeleteKustomizationFunc func(name, namespace string) error
WaitForKustomizationsFunc func(ctx context.Context, message string, blueprint *blueprintv1alpha1.Blueprint) error
GetKustomizationStatusFunc func(names []string) (map[string]bool, error)
GetKustomizationReadinessFunc func(names []string) (map[string]bool, error)
CreateNamespaceFunc func(name string) error
DeleteNamespaceFunc func(name string) error
ApplyConfigMapFunc func(name, namespace string, data map[string]string) error
ApplySecretFunc func(name, namespace 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)
ApplyGitRepositoryFunc func(repo *sourcev1.GitRepository) error
ApplyOCIRepositoryFunc func(repo *sourcev1.OCIRepository) error
CheckGitRepositoryStatusFunc func() 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)
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) ApplyConfigMap ¶
func (m *MockKubernetesManager) ApplyConfigMap(name, namespace string, data map[string]string) error
ApplyConfigMap implements KubernetesManager interface
func (*MockKubernetesManager) ApplyGitRepository ¶
func (m *MockKubernetesManager) ApplyGitRepository(repo *sourcev1.GitRepository) error
ApplyGitRepository implements KubernetesManager interface
func (*MockKubernetesManager) ApplyKustomization ¶
func (m *MockKubernetesManager) ApplyKustomization(kustomization kustomizev1.Kustomization) error
ApplyKustomization implements KubernetesManager interface
func (*MockKubernetesManager) ApplyOCIRepository ¶
func (m *MockKubernetesManager) ApplyOCIRepository(repo *sourcev1.OCIRepository) error
ApplyOCIRepository implements KubernetesManager interface
func (*MockKubernetesManager) ApplySecret ¶ added in v0.9.0
func (m *MockKubernetesManager) ApplySecret(name, namespace 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) CheckGitRepositoryStatus ¶
func (m *MockKubernetesManager) CheckGitRepositoryStatus() error
CheckGitRepositoryStatus checks the status of all GitRepository resources
func (*MockKubernetesManager) CreateNamespace ¶
func (m *MockKubernetesManager) CreateNamespace(name string) error
CreateNamespace implements KubernetesManager interface
func (*MockKubernetesManager) DeleteBlueprint ¶
func (m *MockKubernetesManager) DeleteBlueprint(blueprint *blueprintv1alpha1.Blueprint, namespace string) error
DeleteBlueprint implements KubernetesManager interface
func (*MockKubernetesManager) DeleteKustomization ¶
func (m *MockKubernetesManager) DeleteKustomization(name, namespace string) error
DeleteKustomization implements KubernetesManager interface
func (*MockKubernetesManager) DeleteNamespace ¶
func (m *MockKubernetesManager) DeleteNamespace(name string) error
DeleteNamespace 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) GetKustomizationStatus ¶
func (m *MockKubernetesManager) GetKustomizationStatus(names []string) (map[string]bool, error)
GetKustomizationStatus implements KubernetesManager interface
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(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) 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, message string, blueprint *blueprintv1alpha1.Blueprint) error
WaitForKustomizations implements KubernetesManager interface
type Shims ¶
type Shims struct {
// Other operations
RegexpMatchString func(pattern string, s string) (bool, error)
YamlMarshal func(v any) ([]byte, error)
YamlUnmarshal func(data []byte, v any, opts ...yaml.JSONOpt) error
K8sYamlUnmarshal func(data []byte, v any, opts ...yaml.JSONOpt) error
TimeSleep func(d time.Duration)
ToUnstructured func(obj any) (map[string]any, error)
FromUnstructured func(obj map[string]any, target any) error
}
Shims provides testable interfaces for external dependencies
type SourceRef ¶ added in v0.9.0
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 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).