flux

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

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

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

func (p *Provider) WatchFailures(ctx context.Context) (<-chan providers.FailureEvent, error)

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

func NewDynamicReader(client dynamic.Interface) Reader

NewDynamicReader builds a Reader backed by a client-go dynamic client.

Jump to

Keyboard shortcuts

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