flux

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package flux provides Terratest-style helpers for testing Flux resources such as Kustomizations, HelmReleases, GitRepositories, and HelmRepositories. These functions wait for Flux CRDs to become Ready using status conditions and standard polling logic.

Index

Constants

This section is empty.

Variables

View Source
var NewFluxClient = newFluxClient

NewFluxClient creates and returns a new controller-runtime client for interacting with Flux resources. It initializes a new runtime scheme, adds the Flux Kustomize, Helm, and Source controller APIs to the scheme, and constructs the client using the provided Kubernetes REST configuration.

Parameters:

  • t: The testing context.
  • options: The KubectlOptions containing the Kubernetes REST config.

Returns:

  • client.Client: A controller-runtime client configured for Flux resources.
  • error: An error if the client could not be created.

Functions

func ListBuckets added in v0.0.6

func ListBuckets(t *testing.T, options *k8s.KubectlOptions, namespace string, opts ...client.ListOption) []sourcev1.Bucket

ListBuckets retrieves a list of Flux Buckets in the specified Kubernetes namespace. It uses the provided testing context and kubectl options to create a Flux client, then lists all Bucket resources within the given namespace. The function fails the test if the client cannot be created or if listing the Buckets fails.

Parameters:

  • t: The testing context.
  • options: The kubectl options for connecting to the cluster.
  • namespace: The Kubernetes namespace to search for Buckets.

Returns:

  • A slice of sourcev1.Bucket objects found in the specified namespace.

func ListGitRepositories added in v0.0.6

func ListGitRepositories(t *testing.T, options *k8s.KubectlOptions, namespace string, opts ...client.ListOption) []sourcev1.GitRepository

ListGitRepositories retrieves all Flux GitRepository resources within the specified Kubernetes namespace. It uses the provided testing context and Kubectl options to create a Flux client, then lists the GitRepositories. If any error occurs during client creation or listing, the test will fail.

Parameters:

  • t: The testing context.
  • options: The Kubectl options for connecting to the Kubernetes cluster.
  • namespace: The namespace to search for GitRepository resources.

Returns:

  • A slice of sourcev1.GitRepository objects found in the specified namespace.

func ListHelmCharts added in v0.0.6

func ListHelmCharts(t *testing.T, options *k8s.KubectlOptions, namespace string, opts ...client.ListOption) []sourcev1.HelmChart

ListHelmCharts retrieves a list of HelmChart resources from the specified namespace using the provided Kubernetes options. It requires a testing context and will fail the test if unable to create the Flux client or if listing the HelmCharts fails. Returns a slice of HelmChart objects found in the namespace.

Parameters:

  • t: The testing context.
  • options: The kubectl options for connecting to the Kubernetes cluster.
  • namespace: The namespace from which to list HelmChart resources.

Returns:

  • A slice of sourcev1.HelmChart objects present in the specified namespace.

func ListHelmReleases added in v0.0.5

func ListHelmReleases(t *testing.T, options *k8s.KubectlOptions, namespace string, opts ...client.ListOption) []helmv2.HelmRelease

ListHelmReleases retrieves all HelmRelease resources in the specified namespace using the provided kubectl options. It requires a testing context and will fail the test if the Flux client cannot be created or if listing the HelmReleases fails.

Parameters:

  • t: The testing context.
  • options: The kubectl options for connecting to the Kubernetes cluster.
  • namespace: The namespace from which to list HelmRelease resources.

Returns:

  • A slice of helmv2.HelmRelease objects found in the specified namespace.

func ListHelmRepositories added in v0.0.5

func ListHelmRepositories(t *testing.T, options *k8s.KubectlOptions, namespace string, opts ...client.ListOption) []sourcev1.HelmRepository

ListHelmRepositories retrieves all HelmRepository resources in the specified namespace using the provided Kubernetes options. It returns a slice of HelmRepository objects. The function fails the test if it is unable to create a Flux client or if it encounters an error while listing the HelmRepositories.

Parameters:

  • t: The testing context.
  • options: The kubectl options to use for connecting to the Kubernetes cluster.
  • namespace: The namespace from which to list HelmRepository resources.

Returns:

  • A slice of sourcev1.HelmRepository objects found in the specified namespace.

func ListKustomization added in v0.0.6

func ListKustomization(t *testing.T, options *k8s.KubectlOptions, namespace string, opts ...client.ListOption) []kustomizev1.Kustomization

ListKustomization retrieves all Flux Kustomization resources in the specified namespace. It uses the provided testing context and kubectl options to create a Flux client, then lists the Kustomizations within the given namespace. The function fails the test if the client cannot be created or if listing the Kustomizations fails.

Parameters:

  • t: The testing context.
  • options: The kubectl options for connecting to the Kubernetes cluster.
  • namespace: The namespace from which to list Kustomizations.

Returns:

  • A slice of kustomizev1.Kustomization objects found in the specified namespace.

func ListOCIRepositories added in v0.0.6

func ListOCIRepositories(t *testing.T, options *k8s.KubectlOptions, namespace string, opts ...client.ListOption) []sourcev1.OCIRepository

ListOCIRepositories retrieves a list of OCIRepository resources from the specified namespace using the provided Kubernetes options. It returns a slice of sourcev1.OCIRepository objects. The function requires a testing.T instance for error handling and test context propagation. It fails the test if the Flux client cannot be created or if listing the OCIRepositories fails.

Parameters:

  • t: The testing.T instance used for test context and assertions.
  • options: The KubectlOptions specifying the Kubernetes context and configuration.
  • namespace: The namespace from which to list OCIRepository resources.

Returns:

  • []sourcev1.OCIRepository: A slice containing the retrieved OCIRepository resources.

func WaitForBucketReady

func WaitForBucketReady(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForBucketReady waits until the specified Flux Bucket resource reaches the "Ready" condition within the given timeout. It polls the Kubernetes API at regular intervals to check the Bucket's status. If the Bucket does not become ready within the timeout, the test fails. Parameters:

t        - The testing context.
options  - Kubectl options containing the REST config for Kubernetes API access.
name     - The name of the Bucket resource.
namespace- The namespace where the Bucket resource is located.
timeout  - The maximum duration to wait for the Bucket to become ready.

func WaitForGitRepositoryReady

func WaitForGitRepositoryReady(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForGitRepositoryReady waits until the specified Flux GitRepository resource becomes Ready within the given timeout. It polls the resource status every 2 seconds and fails the test if the resource does not become Ready in time.

Parameters:

t        - The testing context.
options  - The kubectl options containing the REST config for the Kubernetes cluster.
name     - The name of the GitRepository resource.
namespace- The namespace where the GitRepository resource is located.
timeout  - The maximum duration to wait for the resource to become Ready.

Fails the test if the GitRepository does not reach the Ready condition within the timeout.

func WaitForHelmChartReady

func WaitForHelmChartReady(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForHelmChartReady waits until the specified HelmChart resource in the given namespace becomes Ready within the provided timeout. It uses the Flux client to poll the HelmChart status and checks for the Ready condition. If the HelmChart does not become Ready within the timeout, the test fails with a fatal error.

Parameters:

t        - The testing context.
options  - Kubectl options containing the Kubernetes REST config.
name     - The name of the HelmChart resource.
namespace- The namespace where the HelmChart is deployed.
timeout  - The maximum duration to wait for the HelmChart to become Ready.

Fails the test if the HelmChart does not reach the Ready condition within the timeout.

func WaitForHelmReleaseReady

func WaitForHelmReleaseReady(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForHelmReleaseReady waits until the specified HelmRelease resource in the given namespace reaches the Ready condition or the timeout is exceeded. It polls the resource status at regular intervals and fails the test if the resource does not become Ready within the timeout period.

Parameters:

t        - The testing context.
options  - The kubectl options containing the Kubernetes REST config.
name     - The name of the HelmRelease resource.
namespace- The namespace where the HelmRelease is located.
timeout  - The maximum duration to wait for the HelmRelease to become Ready.

The function will call t.Fatalf if the HelmRelease does not become Ready within the timeout.

func WaitForHelmRepositoryReady

func WaitForHelmRepositoryReady(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForHelmRepositoryReady waits until the specified Flux HelmRepository resource becomes Ready within the given timeout. It polls the resource status every 2 seconds and fails the test if the resource does not become Ready in time. Parameters:

  • t: The testing context.
  • options: Kubectl options containing the Kubernetes REST config.
  • name: The name of the HelmRepository resource.
  • namespace: The namespace of the HelmRepository resource.
  • timeout: The maximum duration to wait for the resource to become Ready.

Fails the test if the HelmRepository does not reach the Ready condition within the timeout.

func WaitForKustomizationReady

func WaitForKustomizationReady(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForKustomizationReady waits until the specified Flux Kustomization resource reaches the Ready condition within the given timeout. It polls the resource status at regular intervals and fails the test if the resource does not become Ready in time. Parameters:

  • t: The testing context.
  • options: Kubectl options containing the Kubernetes REST config.
  • name: The name of the Kustomization resource.
  • namespace: The namespace of the Kustomization resource.
  • timeout: The maximum duration to wait for the resource to become Ready.

The function will fail the test if the Kustomization does not become Ready within the timeout.

func WaitForOCIRepositoryReady

func WaitForOCIRepositoryReady(t *testing.T, options *k8s.KubectlOptions, name, namespace string, timeout time.Duration)

WaitForOCIRepositoryReady waits until the specified Flux OCIRepository resource becomes Ready within the given timeout. It polls the resource status at regular intervals and fails the test if the resource does not become Ready in time.

Parameters:

t        - The testing context.
options  - Kubectl options containing the REST config for the Kubernetes cluster.
name     - The name of the OCIRepository resource.
namespace- The namespace where the OCIRepository resource is located.
timeout  - The maximum duration to wait for the resource to become Ready.

Fails the test if the OCIRepository does not reach the Ready condition within the timeout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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