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
- Variables
- type Client
- type KustomizationInfo
- type ReconcileOptions
- type Reconciler
- func (r *Reconciler) ListKustomizationPaths(ctx context.Context) ([]KustomizationInfo, error)
- func (r *Reconciler) TriggerKustomizationReconciliation(ctx context.Context) error
- func (r *Reconciler) TriggerNamedKustomizationReconciliation(ctx context.Context, name string) error
- func (r *Reconciler) TriggerOCIRepositoryReconciliation(ctx context.Context) error
- func (r *Reconciler) WaitForAllKustomizationsReady(ctx context.Context, timeout time.Duration) error
- func (r *Reconciler) WaitForKustomizationReady(ctx context.Context, timeout time.Duration) error
- func (r *Reconciler) WaitForOCIRepositoryReady(ctx context.Context, timeout time.Duration) error
Constants ¶
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 ¶
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") )
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.
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.
type KustomizationInfo ¶
KustomizationInfo holds the name and spec.path 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) 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) 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) WaitForAllKustomizationsReady ¶
func (r *Reconciler) WaitForAllKustomizationsReady( ctx context.Context, timeout time.Duration, ) error
WaitForAllKustomizationsReady waits for all Kustomizations in the namespace to be ready. This ensures the full Flux dependency chain has propagated after the root kustomization is ready.
func (*Reconciler) WaitForKustomizationReady ¶
WaitForKustomizationReady waits for the Kustomization to be ready.
func (*Reconciler) WaitForOCIRepositoryReady ¶
WaitForOCIRepositoryReady waits for the OCIRepository to be ready. If timeout is zero or negative, the default ociRepositoryReadyTimeout is used.