flux

package
v7.11.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package flux provides a Flux client implementation using Flux Kubernetes APIs.

This package wraps Flux CD controller APIs (HelmRelease, Kustomization, Sources) and provides client functionality for creating and managing Flux resources on Kubernetes clusters.

Index

Constants

View Source
const (
	// DefaultNamespace is the default namespace for Flux resources.
	DefaultNamespace = "flux-system"
	// SplitParts is the number of parts when splitting strings like "namespace/name" or "name.namespace".
	SplitParts = 2
)

Variables

View Source
var (
	// ErrTypeMismatch is returned when type assertion fails in copySpec.
	ErrTypeMismatch = errors.New("type mismatch in copySpec")
	// ErrUnsupportedResourceType is returned when an unsupported resource type is passed to copySpec.
	ErrUnsupportedResourceType = errors.New("unsupported resource type")
)
View Source
var (
	// ErrReconcileTimeout is returned when reconciliation times out.
	ErrReconcileTimeout = errors.New(
		"timeout waiting for flux kustomization reconciliation - " +
			"verify cluster health, Flux controllers status, and network/connectivity to the cluster",
	)
	// ErrOCIRepositoryNotReady is returned when the OCIRepository is not ready.
	ErrOCIRepositoryNotReady = errors.New(
		"flux OCIRepository is not ready - ensure you have pushed an artifact with 'ksail workload push'",
	)
	// ErrKustomizationFailed is returned when the Kustomization reconciliation fails.
	ErrKustomizationFailed = errors.New(
		"flux kustomization reconciliation failed - check the Kustomization status and Flux controller logs for details",
	)
)

Reconciler errors.

View Source
var ErrOCIRefRequired = errors.New("one of --tag, --tag-semver or --digest is required")

ErrOCIRefRequired is returned when none of tag, semver, or digest is specified for OCI repository.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps flux API functionality.

func NewClient

func NewClient(ioStreams genericiooptions.IOStreams, kubeconfigPath string) *Client

NewClient creates a new flux client instance.

func (*Client) CreateCreateCommand

func (c *Client) CreateCreateCommand(kubeconfigPath string) *cobra.Command

CreateCreateCommand returns the flux create command tree.

type KustomizationInfo

type KustomizationInfo struct {
	Name      string
	Path      string
	DependsOn []string
}

KustomizationInfo holds the name, spec.path, and dependency information of a Flux Kustomization CR.

type ReconcileOptions

type ReconcileOptions struct {
	// Timeout for waiting for OCIRepository readiness and Kustomization reconciliation.
	Timeout time.Duration
}

ReconcileOptions configures the reconciliation behavior.

type Reconciler

type Reconciler struct {
	*reconciler.Base
}

Reconciler handles Flux reconciliation operations.

func NewReconciler

func NewReconciler(kubeconfigPath string) (*Reconciler, error)

NewReconciler creates a new Flux reconciler from kubeconfig path.

func (*Reconciler) CheckNamedKustomizationReady

func (r *Reconciler) CheckNamedKustomizationReady(
	ctx context.Context,
	name string,
) (bool, string, error)

CheckNamedKustomizationReady performs a single-poll readiness check for a specific Kustomization CR identified by name. Returns (ready, status, error) where status is a human-readable string.

func (*Reconciler) ListKustomizationPaths

func (r *Reconciler) ListKustomizationPaths(
	ctx context.Context,
) ([]KustomizationInfo, error)

ListKustomizationPaths lists all Flux Kustomization CRs in the default namespace and returns their names and spec.path values.

func (*Reconciler) ListKustomizations

func (r *Reconciler) ListKustomizations(
	ctx context.Context,
) ([]KustomizationInfo, error)

ListKustomizations lists all Flux Kustomization CRs in the default namespace and returns their names, spec.path values, and dependency information.

func (*Reconciler) ListStuckHelmReleases added in v7.10.0

func (r *Reconciler) ListStuckHelmReleases(
	ctx context.Context,
) ([]StuckHelmRelease, error)

ListStuckHelmReleases returns all HelmReleases across all namespaces that are stuck in a non-recoverable state. A HelmRelease is considered stuck when its Ready condition is False with a failure reason (e.g., InstallFailed, UpgradeFailed) or when the Stalled condition is True. Returns an empty list without error when the HelmRelease CRD is not installed.

func (*Reconciler) ResetStuckHelmReleases added in v7.10.0

func (r *Reconciler) ResetStuckHelmReleases(
	ctx context.Context,
	releases []StuckHelmRelease,
) (int, error)

ResetStuckHelmReleases performs a suspend/resume cycle on the given HelmReleases to clear their failure status. Returns the number of HelmReleases that were successfully reset. Errors on individual releases are collected and returned as a joined error; the operation is best-effort.

The resume phase uses a context detached from any deadline so that HelmReleases are always resumed even if the parent context has expired.

func (*Reconciler) TriggerKustomizationReconciliation

func (r *Reconciler) TriggerKustomizationReconciliation(ctx context.Context) error

TriggerKustomizationReconciliation triggers Kustomization reconciliation without waiting. It uses retry logic to handle optimistic concurrency conflicts that can occur when the Flux controller updates the resource between our Get and Update calls.

func (*Reconciler) TriggerNamedKustomizationReconciliation

func (r *Reconciler) TriggerNamedKustomizationReconciliation(
	ctx context.Context,
	name string,
) error

TriggerNamedKustomizationReconciliation triggers reconciliation for a specific Kustomization CR identified by name. It uses the same retry logic as TriggerKustomizationReconciliation.

func (*Reconciler) TriggerOCIRepositoryReconciliation

func (r *Reconciler) TriggerOCIRepositoryReconciliation(ctx context.Context) error

TriggerOCIRepositoryReconciliation triggers OCIRepository reconciliation without waiting. It uses retry logic to handle optimistic concurrency conflicts that can occur when the Flux controller updates the resource between our Get and Update calls.

func (*Reconciler) WaitForOCIRepositoryReady

func (r *Reconciler) WaitForOCIRepositoryReady(ctx context.Context, timeout time.Duration) error

WaitForOCIRepositoryReady waits for the OCIRepository to be ready. If timeout is zero or negative, the default ociRepositoryReadyTimeout is used.

type StuckHelmRelease added in v7.10.0

type StuckHelmRelease struct {
	Name      string
	Namespace string
	Reason    string
	Message   string
}

StuckHelmRelease holds the identity and failure details of a HelmRelease that is stuck in a non-recoverable state.

Jump to

Keyboard shortcuts

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