helm

package
v0.46.13 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 56

Documentation

Overview

Package helm provides common functionalities for testing helm charts, such as calling out to the helm client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRepo added in v0.30.24

func AddRepo(t testing.TestingT, options *Options, repoName string, repoURL string)

AddRepo will setup the provided helm repository to the local helm client configuration. This will fail the test if there is an error.

func AddRepoE added in v0.30.24

func AddRepoE(t testing.TestingT, options *Options, repoName string, repoURL string) error

AddRepoE will setup the provided helm repository to the local helm client configuration.

func Delete added in v0.13.28

func Delete(t testing.TestingT, options *Options, releaseName string, purge bool)

Delete will delete the provided release from Tiller. If you set purge to true, Tiller will delete the release object as well so that the release name can be reused. This will fail the test if there is an error.

func DeleteE added in v0.13.28

func DeleteE(t testing.TestingT, options *Options, releaseName string, purge bool) error

DeleteE will delete the provided release from Tiller. If you set purge to true, Tiller will delete the release object as well so that the release name can be reused.

func DiffAgainstSnapshot added in v0.46.9

func DiffAgainstSnapshot(t testing.TestingT, options *Options, yamlData string, releaseName string) int

DiffAgainstSnapshot compare the current manifests of a chart (e.g bitnami/nginx) with the previous manifests stored in the snapshot. see https://github.com/gruntwork-io/terratest/issues/1377 It returns the number of difference between the two manifests or -1 in case of error It will fail the test if there is an error while reading or writing the two manifests in the file system

func DiffAgainstSnapshotE added in v0.46.9

func DiffAgainstSnapshotE(t testing.TestingT, options *Options, yamlData string, releaseName string) (int, error)

DiffAgainstSnapshotE compare the current manifests of a chart (e.g bitnami/nginx) with the previous manifests stored in the snapshot. see https://github.com/gruntwork-io/terratest/issues/1377 It returns the number of difference between the manifests or -1 in case of error

func Install added in v0.13.28

func Install(t testing.TestingT, options *Options, chart string, releaseName string)

Install will install the selected helm chart with the provided options under the given release name. This will fail the test if there is an error.

func InstallE added in v0.13.28

func InstallE(t testing.TestingT, options *Options, chart string, releaseName string) error

InstallE will install the selected helm chart with the provided options under the given release name.

func RemoveRepo added in v0.30.24

func RemoveRepo(t testing.TestingT, options *Options, repoName string)

RemoveRepo will remove the provided helm repository from the local helm client configuration. This will fail the test if there is an error.

func RemoveRepoE added in v0.30.24

func RemoveRepoE(t testing.TestingT, options *Options, repoName string) error

RemoveRepoE will remove the provided helm repository from the local helm client configuration.

func RenderRemoteTemplate added in v0.46.6

func RenderRemoteTemplate(t testing.TestingT, options *Options, chartURL string, releaseName string, templateFiles []string, extraHelmArgs ...string) string

RenderTemplate runs `helm template` to render a *remote* chart given the provided options and returns stdout/stderr from the template command. If you pass in templateFiles, this will only render those templates. This function will fail the test if there is an error rendering the template.

func RenderRemoteTemplateE added in v0.46.6

func RenderRemoteTemplateE(t testing.TestingT, options *Options, chartURL string, releaseName string, templateFiles []string, extraHelmArgs ...string) (string, error)

RenderTemplate runs `helm template` to render a *remote* helm chart given the provided options and returns stdout/stderr from the template command. If you pass in templateFiles, this will only render those templates.

func RenderTemplate

func RenderTemplate(t testing.TestingT, options *Options, chartDir string, releaseName string, templateFiles []string, extraHelmArgs ...string) string

RenderTemplate runs `helm template` to render the template given the provided options and returns stdout/stderr from the template command. If you pass in templateFiles, this will only render those templates. This function will fail the test if there is an error rendering the template.

func RenderTemplateE

func RenderTemplateE(t testing.TestingT, options *Options, chartDir string, releaseName string, templateFiles []string, extraHelmArgs ...string) (string, error)

RenderTemplateE runs `helm template` to render the template given the provided options and returns stdout/stderr from the template command. If you pass in templateFiles, this will only render those templates.

func Rollback added in v0.17.6

func Rollback(t testing.TestingT, options *Options, releaseName string, revision string)

Rollback will downgrade the release to the specified version. This will fail the test if there is an error.

func RollbackE added in v0.17.6

func RollbackE(t testing.TestingT, options *Options, releaseName string, revision string) error

RollbackE will downgrade the release to the specified version

func RunHelmCommandAndGetOutputE

func RunHelmCommandAndGetOutputE(t testing.TestingT, options *Options, cmd string, additionalArgs ...string) (string, error)

RunHelmCommandAndGetOutputE runs helm with the given arguments and options and returns combined, interleaved stdout/stderr.

func RunHelmCommandAndGetStdOutE added in v0.32.18

func RunHelmCommandAndGetStdOutE(t testing.TestingT, options *Options, cmd string, additionalArgs ...string) (string, error)

RunHelmCommandAndGetStdOutE runs helm with the given arguments and options and returns stdout.

func UnmarshalK8SYaml

func UnmarshalK8SYaml(t testing.TestingT, yamlData string, destinationObj interface{})

UnmarshalK8SYaml is the same as UnmarshalK8SYamlE, but will fail the test if there is an error.

func UnmarshalK8SYamlE

func UnmarshalK8SYamlE(t testing.TestingT, yamlData string, destinationObj interface{}) error

UnmarshalK8SYamlE can be used to take template outputs and unmarshal them into the corresponding client-go struct. For example, suppose you render the template into a Deployment object. You can unmarshal the yaml as follows:

var deployment appsv1.Deployment UnmarshalK8SYamlE(t, renderedOutput, &deployment)

At the end of this, the deployment variable will be populated.

func UpdateSnapshot added in v0.46.9

func UpdateSnapshot(t testing.TestingT, options *Options, yamlData string, releaseName string)

UpdateSnapshot creates or updates the k8s manifest snapshot of a chart (e.g bitnami/nginx). It is one of the two functions needed to implement snapshot based testing for helm. see https://github.com/gruntwork-io/terratest/issues/1377 A snapshot is used to compare the current manifests of a chart with the previous manifests. A global diff is run against the two snapshosts and the number of differences is returned.

func UpdateSnapshotE added in v0.46.9

func UpdateSnapshotE(t testing.TestingT, options *Options, yamlData string, releaseName string) error

UpdateSnapshotE creates or updates the k8s manifest snapshot of a chart (e.g bitnami/nginx). It is one of the two functions needed to implement snapshot based testing for helm. see https://github.com/gruntwork-io/terratest/issues/1377 A snapshot is used to compare the current manifests of a chart with the previous manifests. A global diff is run against the two snapshosts and the number of differences is returned. It will failed the test if there is an error while writing the manifests' snapshot in the file system

func Upgrade added in v0.17.6

func Upgrade(t testing.TestingT, options *Options, chart string, releaseName string)

Upgrade will upgrade the release and chart will be deployed with the lastest configuration. This will fail the test if there is an error.

func UpgradeE added in v0.17.6

func UpgradeE(t testing.TestingT, options *Options, chart string, releaseName string) error

UpgradeE will upgrade the release and chart will be deployed with the lastest configuration.

Types

type ChartNotFoundError added in v0.13.28

type ChartNotFoundError struct {
	Path string
}

ChartNotFoundError is returned when a provided chart dir is not found

func (ChartNotFoundError) Error added in v0.13.28

func (err ChartNotFoundError) Error() string

type Options

type Options struct {
	ValuesFiles       []string            // List of values files to render.
	SetValues         map[string]string   // Values that should be set via the command line.
	SetStrValues      map[string]string   // Values that should be set via the command line explicitly as `string` types.
	SetJsonValues     map[string]string   // Values that should be set via the command line in JSON format.
	SetFiles          map[string]string   // Values that should be set from a file. These should be file paths. Use to avoid logging secrets.
	KubectlOptions    *k8s.KubectlOptions // KubectlOptions to control how to authenticate to kubernetes cluster. `nil` => use defaults.
	HomePath          string              // The path to the helm home to use when calling out to helm. Empty string means use default ($HOME/.helm).
	EnvVars           map[string]string   // Environment variables to set when running helm
	Version           string              // Version of chart
	Logger            *logger.Logger      // Set a non-default logger that should be used. See the logger package for more info. Use logger.Discard to not print the output while executing the command.
	ExtraArgs         map[string][]string // Extra arguments to pass to the helm install/upgrade/rollback/delete and helm repo add commands. The key signals the command (e.g., install) while the values are the extra arguments to pass through.
	BuildDependencies bool                // If true, helm dependencies will be built before rendering template, installing or upgrade the chart.
	SnapshotPath      string              // The path to the snapshot directory when using snapshot based testing. Empty string means use default ($PWD/__snapshot__).
}

type SetFileNotFoundError

type SetFileNotFoundError struct {
	Path string
}

SetFileNotFoundError is returned when a provided set file input is not found on the host path.

func (SetFileNotFoundError) Error

func (err SetFileNotFoundError) Error() string

type TemplateFileNotFoundError

type TemplateFileNotFoundError struct {
	Path     string
	ChartDir string
}

TemplateFileNotFoundError is returned when a provided template file input is not found in the chart

func (TemplateFileNotFoundError) Error

func (err TemplateFileNotFoundError) Error() string

type ValuesFileNotFoundError

type ValuesFileNotFoundError struct {
	Path string
}

ValuesFileNotFoundError is returned when a provided values file input is not found on the host path.

func (ValuesFileNotFoundError) Error

func (err ValuesFileNotFoundError) Error() string

Jump to

Keyboard shortcuts

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