Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyDiff(ctx context.Context, config *helmaction.Configuration, ...) (*ssa.ChangeSet, error)
- func Diff(ctx context.Context, config *helmaction.Configuration, ...) (jsondiff.DiffSet, error)
- func Install(ctx context.Context, config *helmaction.Configuration, obj *v2.HelmRelease, ...) (*helmrelease.Release, error)
- func LastRelease(config *helmaction.Configuration, releaseName string) (*helmrelease.Release, error)
- func MustResetFailures(obj *v2.HelmRelease, chart *chart.Metadata, values common.Values) (string, bool)
- func NewCustomPodStatusReader(mapper meta.RESTMapper) engine.StatusReader
- func NewTraceLogger(ctx context.Context) slog.Handler
- func ReleaseTargetChanged(obj *v2.HelmRelease, chartName string) (string, bool)
- func Rollback(config *helmaction.Configuration, obj *v2.HelmRelease, releaseName string, ...) error
- func Test(_ context.Context, config *helmaction.Configuration, obj *v2.HelmRelease, ...) (*helmrelease.Release, error)
- func Uninstall(_ context.Context, config *helmaction.Configuration, obj *v2.HelmRelease, ...) (*helmrelease.UninstallReleaseResponse, error)
- func Upgrade(ctx context.Context, config *helmaction.Configuration, obj *v2.HelmRelease, ...) (*helmrelease.Release, error)
- func VerifyRelease(rls *helmrelease.Release, snapshot *v2.Snapshot, chrt *helmchart.Metadata, ...) error
- func VerifyReleaseObject(snapshot *v2.Snapshot, rls *helmrelease.Release) error
- func VerifySnapshot(config *helmaction.Configuration, snapshot *v2.Snapshot) (rls *helmrelease.Release, err error)
- type Client
- type ConfigFactory
- type ConfigFactoryOption
- func WithDriver(driver helmdriver.Driver) ConfigFactoryOption
- func WithResourceManager(mgr func(sr ...NewStatusReaderFunc) *ssa.ResourceManager) ConfigFactoryOption
- func WithStorage(driver, namespace string) ConfigFactoryOption
- func WithStorageLog(log slog.Handler) ConfigFactoryOption
- func WithWaitContext(ctx context.Context) ConfigFactoryOption
- type InstallOption
- type LogBuffer
- func (l *LogBuffer) Appendf(format string, v ...any)
- func (l *LogBuffer) Empty() bool
- func (l *LogBuffer) Enabled(context.Context, slog.Level) bool
- func (l *LogBuffer) Handle(_ context.Context, r slog.Record) error
- func (l *LogBuffer) String() string
- func (l *LogBuffer) WithAttrs(attrs []slog.Attr) slog.Handler
- func (l *LogBuffer) WithGroup(name string) slog.Handler
- type NewStatusReaderFunc
- type RollbackOption
- type TestOption
- type UninstallOption
- type UpgradeOption
Constants ¶
const ( // DefaultCRDPolicy is the default CRD policy. DefaultCRDPolicy = v2.Create )
const ( // DefaultStorageDriver is the default Helm storage driver. DefaultStorageDriver = helmdriver.SecretsDriverName )
Variables ¶
var ( ErrReleaseDisappeared = errors.New("release disappeared from storage") ErrReleaseNotFound = errors.New("no release found") ErrReleaseNotObserved = errors.New("release not observed to be made for object") ErrReleaseDigest = errors.New("release digest verification error") ErrChartChanged = errors.New("release chart changed") ErrConfigDigest = errors.New("release config values changed") )
var UseHelm3Defaults bool
UseHelm3Defaults must be set from the feature gate of same name in main.go.
Functions ¶
func ApplyDiff ¶
func ApplyDiff(ctx context.Context, config *helmaction.Configuration, diffSet jsondiff.DiffSet, fieldOwner string) (*ssa.ChangeSet, error)
ApplyDiff applies the changes described in the provided jsondiff.DiffSet to the Kubernetes cluster.
func Diff ¶
func Diff(ctx context.Context, config *helmaction.Configuration, rls *helmrelease.Release, fieldOwner string, disallowedFieldManagers []string, ignore ...v2.IgnoreRule) (jsondiff.DiffSet, error)
Diff returns a jsondiff.DiffSet of the changes between the state of the cluster and the Helm release.Release manifest.
func Install ¶
func Install(ctx context.Context, config *helmaction.Configuration, obj *v2.HelmRelease, chrt *helmchart.Chart, vals helmchartutil.Values, opts ...InstallOption) (*helmrelease.Release, error)
Install runs the Helm install action with the provided config, using the v2.HelmReleaseSpec of the given object to determine the target release and rollback configuration.
It performs the installation according to the spec, which includes installing the CRDs according to the defined policy.
It does not determine if there is a desire to perform the action, this is expected to be done by the caller. In addition, it does not take note of the action result. The caller is expected to listen to this using a storage.ObserveFunc, which provides superior access to Helm storage writes.
func LastRelease ¶
func LastRelease(config *helmaction.Configuration, releaseName string) (*helmrelease.Release, error)
LastRelease returns the last release object in the Helm storage with the given name. It returns an error of type ErrReleaseNotFound if there is no release with the given name. When the release name is too long, it will be shortened to the maximum allowed length using the release.ShortenName function.
func MustResetFailures ¶
func MustResetFailures(obj *v2.HelmRelease, chart *chart.Metadata, values common.Values) (string, bool)
MustResetFailures returns a reason and true if the HelmRelease's status indicates that the HelmRelease failure counters must be reset. This is the case if the data used to make the last (failed) attempt has changed in a way that indicates that a new attempt should be made. For example, a change in generation, chart version, or values. If no change is detected, an empty string is returned along with false.
func NewCustomPodStatusReader ¶ added in v1.5.0
func NewCustomPodStatusReader(mapper meta.RESTMapper) engine.StatusReader
func NewTraceLogger ¶ added in v1.5.0
NewTraceLogger returns an slog.Handler that logs to the logger from the context at Trace level.
func ReleaseTargetChanged ¶
func ReleaseTargetChanged(obj *v2.HelmRelease, chartName string) (string, bool)
ReleaseTargetChanged returns a reason and true if the given release and/or chart name have been mutated in such a way that it no longer has the same release target as recorded in the Status.History of the object, by comparing the (storage) namespace, and release and chart names. This can be used to e.g. trigger a garbage collection of the old release before installing the new one. If no change is detected, an empty string is returned along with false.
func Rollback ¶
func Rollback(config *helmaction.Configuration, obj *v2.HelmRelease, releaseName string, version int, opts ...RollbackOption) error
Rollback runs the Helm rollback action with the provided config. Targeting a specific release or enabling dry-run is possible by providing RollbackToVersion as option.
It does not determine if there is a desire to perform the action, this is expected to be done by the caller. In addition, it does not take note of the action result. The caller is expected to listen to this using a storage.ObserveFunc, which provides superior access to Helm storage writes.
func Test ¶
func Test(_ context.Context, config *helmaction.Configuration, obj *v2.HelmRelease, opts ...TestOption) (*helmrelease.Release, error)
Test runs the Helm test action with the provided config, using the v2.HelmReleaseSpec of the given object to determine the target release and test configuration.
It does not determine if there is a desire to perform the action, this is expected to be done by the caller. In addition, it does not take note of the action result. The caller is expected to listen to this using a storage.ObserveFunc, which provides superior access to Helm storage writes.
func Uninstall ¶
func Uninstall(_ context.Context, config *helmaction.Configuration, obj *v2.HelmRelease, releaseName string, opts ...UninstallOption) (*helmrelease.UninstallReleaseResponse, error)
Uninstall runs the Helm uninstall action with the provided config, using the v2.HelmReleaseSpec of the given object to determine the target release and uninstall configuration.
It does not determine if there is a desire to perform the action, this is expected to be done by the caller. In addition, it does not take note of the action result. The caller is expected to listen to this using a storage.ObserveFunc, which provides superior access to Helm storage writes.
func Upgrade ¶
func Upgrade(ctx context.Context, config *helmaction.Configuration, obj *v2.HelmRelease, chrt *helmchart.Chart, vals helmchartutil.Values, opts ...UpgradeOption) (*helmrelease.Release, error)
Upgrade runs the Helm upgrade action with the provided config, using the v2.HelmReleaseSpec of the given object to determine the target release and upgrade configuration.
It performs the upgrade according to the spec, which includes upgrading the CRDs according to the defined policy.
It does not determine if there is a desire to perform the action, this is expected to be done by the caller. In addition, it does not take note of the action result. The caller is expected to listen to this using a storage.ObserveFunc, which provides superior access to Helm storage writes.
func VerifyRelease ¶
func VerifyRelease(rls *helmrelease.Release, snapshot *v2.Snapshot, chrt *helmchart.Metadata, vals helmchartutil.Values) error
VerifyRelease verifies that the data of the given release matches the given chart metadata, and the provided values match the Snapshot.ConfigDigest. It returns either an error of type ErrReleaseNotFound, ErrChartChanged or ErrConfigDigest, or nil.
func VerifyReleaseObject ¶
func VerifyReleaseObject(snapshot *v2.Snapshot, rls *helmrelease.Release) error
VerifyReleaseObject verifies the data of the given v2.Snapshot matches the given Helm release object. It returns an error of type ErrReleaseDigest or ErrReleaseNotObserved indicating the reason for the verification failure, or nil.
For legacy snapshots (those with an APIVersion missing or not matching the current version), digest verification is skipped to allow graceful migration from older helm-controller versions.
func VerifySnapshot ¶
func VerifySnapshot(config *helmaction.Configuration, snapshot *v2.Snapshot) (rls *helmrelease.Release, err error)
VerifySnapshot verifies the data of the given v2.Snapshot matches the release object in the Helm storage. It returns the verified release, or an error of type ErrReleaseNotFound, ErrReleaseDisappeared, ErrReleaseDigest or ErrReleaseNotObserved indicating the reason for the verification failure.
Types ¶
type Client ¶ added in v1.5.0
type Client struct {
// We need to embed the struct and not helmkube.Interface
// as Helm adds more methods to the struct over time
// without adding them to the interface. This ensures
// we always embed all methods.
*helmkube.Client
// contains filtered or unexported fields
}
Client wraps a Helm kube Client to replace the kstatus implementation.
func NewClient ¶ added in v1.5.0
func NewClient(getter genericclioptions.RESTClientGetter) *Client
NewClient returns a new Helm kube Client that uses kstatus for waits.
func (*Client) GetWaiter ¶ added in v1.5.0
GetWaiter implements helmkube.InterfaceWaitOptions by returning a custom kstatus-based Waiter.
func (*Client) GetWaiterWithOptions ¶ added in v1.5.0
func (c *Client) GetWaiterWithOptions(strategy helmkube.WaitStrategy, opts ...helmkube.WaitOption) (helmkube.Waiter, error)
GetWaiterWithOptions implements helmkube.InterfaceWaitOptions by returning a custom kstatus-based Waiter.
type ConfigFactory ¶
type ConfigFactory struct {
// Getter is the RESTClientGetter used to get the RESTClient for the
// Kubernetes API.
Getter genericclioptions.RESTClientGetter
// KubeClient is the (wrapped) Helm Kubernetes client, it is Helm-specific and
// contains a factory used for lazy-loading.
KubeClient *Client
// Driver to use for the Helm action.
Driver helmdriver.Driver
// StorageLog is the logger to use for the Helm storage driver.
StorageLog slog.Handler
// NewResourceManager is the resource manager used to evaluate custom health checks.
NewResourceManager func(sr ...NewStatusReaderFunc) *ssa.ResourceManager
// WaitContext is the context used for waiting operations in the Helm
// Kubernetes client.
WaitContext context.Context
}
ConfigFactory is a factory for the Helm action configuration of a (series of) Helm action(s). It allows for sharing Kubernetes client(s) and the Helm storage driver between actions, where possible.
To get a Helm action.Configuration for an action, use the Build method on an initialized factory.
func NewConfigFactory ¶
func NewConfigFactory(getter genericclioptions.RESTClientGetter, opts ...ConfigFactoryOption) (*ConfigFactory, error)
NewConfigFactory returns a new ConfigFactory configured with the provided options.
func (*ConfigFactory) Build ¶
func (c *ConfigFactory) Build(log slog.Handler, observers ...storage.ObserveFunc) *helmaction.Configuration
Build returns a new Helm action.Configuration configured with the receiver values, and the provided logger and observer(s).
func (*ConfigFactory) NewStorage ¶
func (c *ConfigFactory) NewStorage(observers ...storage.ObserveFunc) *helmstorage.Storage
NewStorage returns a new Helm storage.Storage configured with any observer(s) and the Driver configured on the ConfigFactory.
func (*ConfigFactory) Valid ¶
func (c *ConfigFactory) Valid() error
Valid returns an error if the ConfigFactory is missing configuration required to run a Helm action.
type ConfigFactoryOption ¶
type ConfigFactoryOption func(*ConfigFactory) error
ConfigFactoryOption is a function that configures a ConfigFactory.
func WithDriver ¶
func WithDriver(driver helmdriver.Driver) ConfigFactoryOption
WithDriver sets the ConfigFactory.Driver.
func WithResourceManager ¶ added in v1.5.0
func WithResourceManager(mgr func(sr ...NewStatusReaderFunc) *ssa.ResourceManager) ConfigFactoryOption
WithResourceManager sets the ConfigFactory.ResourceManager.
func WithStorage ¶
func WithStorage(driver, namespace string) ConfigFactoryOption
WithStorage configures the ConfigFactory.Driver by constructing a new Helm driver.Driver using the provided driver name and namespace. It supports driver.ConfigMapsDriverName, driver.SecretsDriverName and driver.MemoryDriverName. It returns an error when the driver name is not supported, or the client configuration for the storage fails.
func WithStorageLog ¶
func WithStorageLog(log slog.Handler) ConfigFactoryOption
WithStorageLog sets the ConfigFactory.StorageLog.
func WithWaitContext ¶ added in v1.5.0
func WithWaitContext(ctx context.Context) ConfigFactoryOption
WithWaitContext sets the context used for waiting operations in the Helm Kubernetes client.
type InstallOption ¶
type InstallOption func(action *helmaction.Install)
InstallOption can be used to modify Helm's action.Install after the instructions from the v2.HelmRelease have been applied. This is for example useful to enable the dry-run setting as a CLI.
type LogBuffer ¶
type LogBuffer struct {
// contains filtered or unexported fields
}
LogBuffer implements slog.Handler by logging to a logr.Logger calling log.Info, and to a ring buffer if level is Debug.
func NewDebugLogBuffer ¶ added in v1.5.0
NewDebugLogBuffer returns an slog.Handler that logs to the logger from the context at Debug level, and also keeps a ring buffer of log messages.
type NewStatusReaderFunc ¶ added in v1.5.0
type NewStatusReaderFunc = func(apimeta.RESTMapper) engine.StatusReader
NewStatusReaderFunc is a function type that returns a kstatus StatusReader.
type RollbackOption ¶
type RollbackOption func(*helmaction.Rollback)
RollbackOption can be used to modify Helm's action.Rollback after the instructions from the v2.HelmRelease have been applied. This is for example useful to enable the dry-run setting as a CLI.
type TestOption ¶
type TestOption func(action *helmaction.ReleaseTesting)
TestOption can be used to modify Helm's action.ReleaseTesting after the instructions from the v2.HelmRelease have been applied. This is for example useful to enable the dry-run setting as a CLI.
type UninstallOption ¶
type UninstallOption func(cfg *helmaction.Uninstall)
UninstallOption can be used to modify Helm's action.Uninstall after the instructions from the v2.HelmRelease have been applied. This is for example useful to enable the dry-run setting as a CLI.
type UpgradeOption ¶
type UpgradeOption func(upgrade *helmaction.Upgrade)
UpgradeOption can be used to modify Helm's action.Upgrade after the instructions from the v2.HelmRelease have been applied. This is for example useful to enable the dry-run setting as a CLI.