action

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCRDPolicy is the default CRD policy.
	DefaultCRDPolicy = v2.Create
)
View Source
const DefaultLogBufferSize = 5

DefaultLogBufferSize is the default size of the LogBuffer.

View Source
const (
	// DefaultStorageDriver is the default Helm storage driver.
	DefaultStorageDriver = helmdriver.SecretsDriverName
)

Variables

View Source
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")
)

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, 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

Install runs the Helm install action with the provided config, using the v2beta2.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 chartutil.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 NewDebugLog

func NewDebugLog(log logr.Logger) helmaction.DebugLog

NewDebugLog returns an action.DebugLog that logs to the given logr.Logger.

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, 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 and/or RollbackDryRun as options.

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

Test runs the Helm test action with the provided config, using the v2beta2.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

Uninstall runs the Helm uninstall action with the provided config, using the v2beta2.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

Upgrade runs the Helm upgrade action with the provided config, using the v2beta2.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 v2beta2.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.

func VerifySnapshot

func VerifySnapshot(config *helmaction.Configuration, snapshot *v2.Snapshot) (rls *helmrelease.Release, err error)

VerifySnapshot verifies the data of the given v2beta2.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 ConfigFactory

type ConfigFactory struct {
	// Getter is the RESTClientGetter used to get the RESTClient for the
	// Kubernetes API.
	Getter genericclioptions.RESTClientGetter
	// KubeClient is the (Helm) Kubernetes client, it is Helm-specific and
	// contains a factory used for lazy-loading.
	KubeClient *helmkube.Client
	// Driver to use for the Helm action.
	Driver helmdriver.Driver
	// StorageLog is the logger to use for the Helm storage driver.
	StorageLog helmaction.DebugLog
}

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

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 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 helmaction.DebugLog) ConfigFactoryOption

WithStorageLog sets the ConfigFactory.StorageLog.

type InstallOption

type InstallOption func(action *helmaction.Install)

InstallOption can be used to modify Helm's action.Install after the instructions from the v2beta2.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 is a ring buffer that logs to a Helm action.DebugLog.

func NewLogBuffer

func NewLogBuffer(log helmaction.DebugLog, size int) *LogBuffer

NewLogBuffer creates a new LogBuffer with the given log function and a buffer of the given size. If size <= 0, it defaults to DefaultLogBufferSize.

func (*LogBuffer) Len

func (l *LogBuffer) Len() (count int)

Len returns the count of non-empty values in the buffer.

func (*LogBuffer) Log

func (l *LogBuffer) Log(format string, v ...interface{})

Log adds the log message to the ring buffer before calling the actual log function. It is safe to call this function from multiple goroutines.

func (*LogBuffer) Reset

func (l *LogBuffer) Reset()

Reset clears the buffer.

func (*LogBuffer) String

func (l *LogBuffer) String() string

String returns the contents of the buffer as a string.

type RollbackOption

type RollbackOption func(*helmaction.Rollback)

RollbackOption can be used to modify Helm's action.Rollback after the instructions from the v2beta2.HelmRelease have been applied. This is for example useful to enable the dry-run setting as a CLI.

func RollbackDryRun

func RollbackDryRun() RollbackOption

RollbackDryRun returns a RollbackOption which enables the dry-run setting.

func RollbackToVersion

func RollbackToVersion(version int) RollbackOption

RollbackToVersion returns a RollbackOption which sets the version to roll back to.

type TestOption

type TestOption func(action *helmaction.ReleaseTesting)

TestOption can be used to modify Helm's action.ReleaseTesting after the instructions from the v2beta2.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 v2beta2.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 v2beta2.HelmRelease have been applied. This is for example useful to enable the dry-run setting as a CLI.

Jump to

Keyboard shortcuts

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