Documentation
¶
Overview ¶
Package helmrelease provides builders and wait conditions for Flux HelmRelease CRs, mirroring the ergonomics of the application package for Giant Swarm App CRs.
Building a HelmRelease ¶
Use New to create a builder, chain fluent setters, then call HelmRelease.Build:
hr, err := helmrelease.New("my-chart", "my-chart").
WithNamespace("org-acme").
WithClusterName(clusterName).
WithInCluster(false).
WithValuesFile("values.yaml", &helmrelease.TemplateValues{ClusterName: clusterName}).
Build()
OCIRepository ¶
An OCIRepository must exist before a HelmRelease can reconcile. Use EnsureOCIRepository and DeleteOCIRepository to manage its lifecycle:
err := helmrelease.EnsureOCIRepository(ctx, client, "my-chart", "org-acme", "my-chart")
Waiting for readiness ¶
IsHelmReleaseReady and IsAppOrHelmReleaseReady return wait.WaitCondition values compatible with wait.For:
err := wait.For(helmrelease.IsHelmReleaseReady(ctx, mcClient, "my-chart", "org-acme"))
Index ¶
- func AreAllReady(ctx context.Context, c cr.Client, names []types.NamespacedName) func() error
- func DeleteOCIRepository(ctx context.Context, c cr.Client, name, namespace string) error
- func EnsureOCIRepository(ctx context.Context, c cr.Client, name, namespace, chartName string) error
- func IsAppOrHelmReleaseReady(ctx context.Context, c *client.Client, name, namespace string) wait.WaitCondition
- func IsHelmReleaseReady(ctx context.Context, c cr.Client, name, namespace string) wait.WaitCondition
- type HelmRelease
- func (h *HelmRelease) Build() (*helmv2.HelmRelease, error)
- func (h *HelmRelease) MustWithValuesFile(path string, tv *TemplateValues) *HelmRelease
- func (h *HelmRelease) WithClusterName(clusterName string) *HelmRelease
- func (h *HelmRelease) WithInCluster(inCluster bool) *HelmRelease
- func (h *HelmRelease) WithNamespace(ns string) *HelmRelease
- func (h *HelmRelease) WithOCIRepoName(name string) *HelmRelease
- func (h *HelmRelease) WithReleaseName(name string) *HelmRelease
- func (h *HelmRelease) WithTargetNamespace(ns string) *HelmRelease
- func (h *HelmRelease) WithValues(values map[string]interface{}) *HelmRelease
- func (h *HelmRelease) WithValuesFile(path string, tv *TemplateValues) (*HelmRelease, error)
- type TemplateValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreAllReady ¶
AreAllReady returns a function that checks whether every HelmRelease in names has a Ready=True condition. Suitable for use with wait.Consistent.
func DeleteOCIRepository ¶
DeleteOCIRepository deletes the named OCIRepository, or is a no-op if it does not exist.
func EnsureOCIRepository ¶
EnsureOCIRepository creates an OCIRepository pointing at the Giant Swarm OCI registry for the given chart, or is a no-op if it already exists.
func IsAppOrHelmReleaseReady ¶
func IsAppOrHelmReleaseReady(ctx context.Context, c *client.Client, name, namespace string) wait.WaitCondition
IsAppOrHelmReleaseReady returns a WaitCondition that becomes true as soon as either an App CR or a HelmRelease with the given name/namespace reaches a Ready state. Use this for default apps that may be deployed as either kind depending on cluster chart version.
Get errors (including NotFound) are suppressed so the outer Eventually keeps polling until one of the two kinds appears and is Ready, or the timeout fires.
func IsHelmReleaseReady ¶
func IsHelmReleaseReady(ctx context.Context, c cr.Client, name, namespace string) wait.WaitCondition
IsHelmReleaseReady returns a WaitCondition that polls the named HelmRelease and becomes true when its Ready condition is True.
Types ¶
type HelmRelease ¶
type HelmRelease struct {
Name string
Namespace string
ReleaseName string
TargetNamespace string
ChartName string
OCIRepoName string
Values map[string]interface{}
// ClusterName is always required. Used for values templating and (when !InCluster)
// to locate the <ClusterName>-kubeconfig secret.
ClusterName string
// InCluster controls the deployment target: true = management cluster (no kubeConfig),
// false = workload cluster (kubeConfig from ClusterName secret).
InCluster bool
}
HelmRelease is a fluent builder for Flux HelmRelease CRs.
ClusterName must always be set — it is used for templating values and, when InCluster is false, for naming the kubeconfig secret (<clusterName>-kubeconfig).
func New ¶
func New(name, chartName string) *HelmRelease
New creates a new HelmRelease builder for the given chart. Defaults: ReleaseName=name, TargetNamespace=name, OCIRepoName=name, InCluster=false.
func (*HelmRelease) Build ¶
func (h *HelmRelease) Build() (*helmv2.HelmRelease, error)
Build constructs and returns the Flux HelmRelease CR. When InCluster is false, spec.kubeConfig.secretRef is set to <ClusterName>-kubeconfig.
func (*HelmRelease) MustWithValuesFile ¶
func (h *HelmRelease) MustWithValuesFile(path string, tv *TemplateValues) *HelmRelease
MustWithValuesFile is like WithValuesFile but panics on error.
func (*HelmRelease) WithClusterName ¶
func (h *HelmRelease) WithClusterName(clusterName string) *HelmRelease
WithClusterName sets the cluster name used for values templating and kubeconfig secret naming.
func (*HelmRelease) WithInCluster ¶
func (h *HelmRelease) WithInCluster(inCluster bool) *HelmRelease
WithInCluster sets whether the HelmRelease targets the management cluster (true) or a workload cluster (false, default).
func (*HelmRelease) WithNamespace ¶
func (h *HelmRelease) WithNamespace(ns string) *HelmRelease
WithNamespace sets the namespace of the HelmRelease CR itself.
func (*HelmRelease) WithOCIRepoName ¶
func (h *HelmRelease) WithOCIRepoName(name string) *HelmRelease
WithOCIRepoName sets the name of the OCIRepository chartRef.
func (*HelmRelease) WithReleaseName ¶
func (h *HelmRelease) WithReleaseName(name string) *HelmRelease
WithReleaseName sets the Helm release name (spec.releaseName).
func (*HelmRelease) WithTargetNamespace ¶
func (h *HelmRelease) WithTargetNamespace(ns string) *HelmRelease
WithTargetNamespace sets the namespace Helm installs into.
func (*HelmRelease) WithValues ¶
func (h *HelmRelease) WithValues(values map[string]interface{}) *HelmRelease
WithValues sets the chart values directly.
func (*HelmRelease) WithValuesFile ¶
func (h *HelmRelease) WithValuesFile(path string, tv *TemplateValues) (*HelmRelease, error)
WithValuesFile reads a YAML file, renders it as a Go template using tv, and sets the result as the chart values.
type TemplateValues ¶
TemplateValues holds the template variables available when rendering HelmRelease values files.