Documentation
¶
Overview ¶
Package flux implements providers.GitOpsProvider for Flux: it reads Flux Kustomizations and their GitRepository sources from the cluster and emits engine-agnostic Changes, each diffable through whatchanged.Differ.
Index ¶
- type KustomizationEvent
- type Provider
- func (p *Provider) Changes(ctx context.Context, _ providers.TimeWindow, sel providers.Selector) ([]providers.Change, error)
- func (p *Provider) DependencyTree(ctx context.Context, w providers.Workload) (providers.DepNode, error)
- func (p *Provider) Diff(ctx context.Context, c providers.Change) (providers.Diff, error)
- func (p *Provider) ResourceStatus(ctx context.Context, w providers.Workload) (providers.ResourceStatus, error)
- func (p *Provider) WatchFailures(ctx context.Context) (<-chan providers.FailureEvent, error)
- type Reader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KustomizationEvent ¶
type KustomizationEvent struct {
Kustomization kustomization
}
KustomizationEvent is a single watch event for a Kustomization.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements providers.GitOpsProvider for Flux.
func New ¶
func New(reader Reader, differ *whatchanged.Differ) *Provider
New builds a Flux provider from a Reader and a Differ.
func (*Provider) Changes ¶
func (p *Provider) Changes(ctx context.Context, _ providers.TimeWindow, sel providers.Selector) ([]providers.Change, error)
Changes lists Flux Kustomizations and emits a Change per workload: its source repo + path and the currently applied revision (ToRev). FromRev is left empty, meaning "the change introduced by ToRev" — resolved at diff time.
NOTE (v1 scope): the window is accepted but not yet used to filter by commit time; each Change reflects the current applied revision. Git-log-based time-windowing is a follow-up.
func (*Provider) DependencyTree ¶
func (p *Provider) DependencyTree(ctx context.Context, w providers.Workload) (providers.DepNode, error)
DependencyTree walks a resource's dependsOn + sourceRef edges, returning the tree with each node's Ready state so the root failure (a not-Ready or missing node) is visible. Best-effort: child read errors don't abort the walk.
func (*Provider) Diff ¶
Diff resolves a Change's diff via the Differ. Changes from a non-Git source (OCIRepository/Bucket/ExternalArtifact) carry no Git URL — there is no Git diff to show, so return an empty diff rather than failing. ctx is threaded into the Differ so a hung clone/patch on a large monorepo is cancellable (per-investigation deadline).
func (*Provider) ResourceStatus ¶
func (p *Provider) ResourceStatus(ctx context.Context, w providers.Workload) (providers.ResourceStatus, error)
ResourceStatus returns a Flux/K8s object's Ready condition, key spec refs (sourceRef, dependsOn, url) and recent Events — the "why is it failing" lens. A missing object is reported via NotFound (often the cascade root), not an error.
func (*Provider) WatchFailures ¶
WatchFailures watches Flux Kustomizations and emits a FailureEvent whenever one is Ready=False (a failed/blocked reconcile). The returned channel closes when the watch ends or ctx is done.
type Reader ¶
type Reader interface {
ListKustomizations(ctx context.Context) ([]kustomization, error)
GetGitRepository(ctx context.Context, namespace, name string) (gitRepository, error)
// SourceRevision returns a source's current synced revision
// (status.artifact.revision) for a GitRepository/OCIRepository/Bucket/
// ExternalArtifact, used to find a failing Kustomization's HEAD.
SourceRevision(ctx context.Context, kind, namespace, name string) (string, error)
WatchKustomizations(ctx context.Context) (<-chan KustomizationEvent, error)
// GetResource fetches one object by kind/namespace/name (kinds in kindToGVR).
GetResource(ctx context.Context, kind, namespace, name string) (*unstructured.Unstructured, error)
// ListEvents returns recent Event lines for an involved object.
ListEvents(ctx context.Context, namespace, name, kind string) ([]string, error)
}
Reader is the cluster-read surface the provider depends on. The dynamic client-go implementation lives in dynamic.go; tests use a fake.
func NewDynamicReader ¶
NewDynamicReader builds a Reader backed by a client-go dynamic client.