helmclient

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: Apache-2.0 Imports: 37 Imported by: 21

README

GoDoc CircleCI

helmclient

Package helmclient implements Helm related primitives to work against helm releases. Currently supports Helm 2 and connects to the Tiller gRPC API using a port forwarding connection.

Interface

See helmclient.Interface in spec.go for supported methods.

k8sportforward is used to establish a port forwarding conection with Tiller.

License

helmclient is under the Apache 2.0 license. See the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	PrometheusNamespace = "helmclient"
	PrometheusSubsystem = "library"
)

Variables

This section is empty.

Functions

func IsCannotReuseRelease

func IsCannotReuseRelease(err error) bool

IsCannotReuseRelease asserts cannotReuseReleaseError.

func IsEmptyChartTemplates

func IsEmptyChartTemplates(err error) bool

IsEmptyChartTemplates asserts emptyChartTemplatesError.

func IsExecutionFailed

func IsExecutionFailed(err error) bool

IsExecutionFailed asserts executionFailedError.

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsInvalidGZipHeader

func IsInvalidGZipHeader(err error) bool

IsInvalidGZipHeader asserts invalidGZipHeaderError.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound asserts notFoundError.

func IsPullChartFailedError

func IsPullChartFailedError(err error) bool

IsPullChartFailedError asserts pullChartFailedError.

func IsPullChartNotFound

func IsPullChartNotFound(err error) bool

IsPullChartNotFound asserts pullChartNotFoundError.

func IsPullChartTimeout

func IsPullChartTimeout(err error) bool

IsPullChartTimeout asserts pullChartTimeoutError.

func IsReleaseAlreadyExists

func IsReleaseAlreadyExists(err error) bool

IsReleaseAlreadyExists asserts releaseAlreadyExistsError.

func IsReleaseNameInvalid

func IsReleaseNameInvalid(err error) bool

IsReleaseNameInvalid asserts releaseNameInvalidError.

func IsReleaseNotDeployed

func IsReleaseNotDeployed(err error) bool

IsReleaseNotDeployed asserts releaseNotDeployedError.

func IsReleaseNotFound

func IsReleaseNotFound(err error) bool

IsReleaseNotFound asserts releaseNotFoundError.

func IsTarballNotFound

func IsTarballNotFound(err error) bool

IsTarballNotFound asserts tarballNotFoundError.

func IsTestReleaseFailure

func IsTestReleaseFailure(err error) bool

IsTestReleaseFailure asserts testReleaseFailureError.

func IsTestReleaseTimeout

func IsTestReleaseTimeout(err error) bool

IsTestReleaseTimeout asserts testReleaseTimeoutError.

func IsTillerInvalidVersion

func IsTillerInvalidVersion(err error) bool

IsTillerInvalidVersion asserts tillerInvalidVersionError.

func IsTillerNotFound

func IsTillerNotFound(err error) bool

IsTillerNotFound asserts tillerNotFoundError.

func IsTillerNotRunningError

func IsTillerNotRunningError(err error) bool

IsTillerNotRunningError asserts tillerNotRunningError.

func IsTillerOutdated

func IsTillerOutdated(err error) bool

IsTillerOutdated asserts tillerOutdatedError.

func IsTooManyResults

func IsTooManyResults(err error) bool

IsTooManyResults asserts tooManyResultsError.

func IsYamlConversionFailed

func IsYamlConversionFailed(err error) bool

IsYamlConversionFailed asserts yamlConversionFailedError.

func MergeValues

func MergeValues(destMap, srcMap map[string][]byte) (map[string]interface{}, error)

MergeValues merges config values so they can be used when installing or updating Helm releases. It takes in 2 maps with a string key and YAML values passed as a byte array.

A deep merge is performed into a single map[string]interface{} output. If a value is present in both then the source map is preferred.

The YAML values are parsed using yamlToStringMap. This is because the default behaviour of the YAML parser is to unmarshal into map[interface{}]interface{} which causes problems with the merge logic. See https://github.com/go-yaml/yaml/issues/139.

Types

type Chart

type Chart struct {
	// Version is the version of the Helm Chart.
	Version string
}

Chart returns information about a Helm Chart.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client knows how to talk with a Helm Tiller server.

func New

func New(config Config) (*Client, error)

New creates a new configured Helm client.

func (*Client) DeleteRelease

func (c *Client) DeleteRelease(ctx context.Context, releaseName string, options ...helmclient.DeleteOption) error

DeleteRelease uninstalls a chart given its release name.

func (*Client) EnsureTillerInstalled

func (c *Client) EnsureTillerInstalled(ctx context.Context) error

EnsureTillerInstalled installs Tiller by creating its deployment and waiting for it to start. A service account and cluster role binding are also created. As a first step, it checks if Tiller is already ready, in which case it returns early.

func (*Client) EnsureTillerInstalledWithValues

func (c *Client) EnsureTillerInstalledWithValues(ctx context.Context, values []string) error

EnsureTillerInstalledWithValues installs Tiller by creating its deployment and waiting for it to start. A service account and cluster role binding are also created. As a first step, it checks if Tiller is already ready, in which case it returns early. Values can be provided to pass through to Tiller and overwrite its deployment.

func (*Client) GetReleaseContent

func (c *Client) GetReleaseContent(ctx context.Context, releaseName string) (*ReleaseContent, error)

GetReleaseContent gets the current status of the Helm Release including any values provided when the chart was installed. The releaseName is the name of the Helm Release that is set when the Helm Chart is installed.

func (*Client) GetReleaseHistory

func (c *Client) GetReleaseHistory(ctx context.Context, releaseName string) (*ReleaseHistory, error)

GetReleaseHistory gets the current installed version of the Helm Release. The releaseName is the name of the Helm Release that is set when the Helm Chart is installed.

func (*Client) InstallReleaseFromTarball

func (c *Client) InstallReleaseFromTarball(ctx context.Context, path, ns string, options ...helmclient.InstallOption) error

InstallReleaseFromTarball installs a chart packaged in the given tarball.

func (*Client) ListReleaseContents

func (c *Client) ListReleaseContents(ctx context.Context) ([]*ReleaseContent, error)

ListReleaseContents gets the current status of all Helm Releases.

func (*Client) LoadChart

func (c *Client) LoadChart(ctx context.Context, chartPath string) (Chart, error)

LoadChart loads a Helm Chart and returns relevant parts of its structure.

func (*Client) PingTiller

func (c *Client) PingTiller(ctx context.Context) error

PingTiller proxies the underlying Helm client PingTiller method.

func (*Client) PullChartTarball

func (c *Client) PullChartTarball(ctx context.Context, tarballURL string) (string, error)

PullChartTarball downloads a tarball from the provided tarball URL, returning the file path.

func (*Client) RunReleaseTest

func (c *Client) RunReleaseTest(ctx context.Context, releaseName string, options ...helmclient.ReleaseTestOption) error

RunReleaseTest runs the tests for a Helm Release. The releaseName is the name of the Helm Release that is set when the Helm Chart is installed. This is the same action as running the helm test command.

func (*Client) UpdateReleaseFromTarball

func (c *Client) UpdateReleaseFromTarball(ctx context.Context, releaseName, path string, options ...helmclient.UpdateOption) error

UpdateReleaseFromTarball updates the given release using the chart packaged in the tarball.

type Config

type Config struct {
	Fs afero.Fs
	// HelmClient sets a helm client used for all operations of the initiated
	// client. If this is nil, a new helm client will be created for each
	// operation via proper port forwarding. Setting the helm client here manually
	// might only be sufficient for testing or whenever you know what you do.
	HelmClient helmclient.Interface
	K8sClient  kubernetes.Interface
	Logger     micrologger.Logger

	EnsureTillerInstalledMaxWait time.Duration
	RestConfig                   *rest.Config
	TillerImageName              string
	TillerImageRegistry          string
	TillerNamespace              string
	TillerUpgradeEnabled         bool
}

Config represents the configuration used to create a helm client.

type Interface

type Interface interface {
	// DeleteRelease uninstalls a chart given its release name.
	DeleteRelease(ctx context.Context, releaseName string, options ...helm.DeleteOption) error
	// EnsureTillerInstalled installs Tiller by creating its deployment and waiting
	// for it to start. A service account and cluster role binding are also created.
	// As a first step, it checks if Tiller is already ready, in which case it
	// returns early.
	EnsureTillerInstalled(ctx context.Context) error
	// EnsureTillerInstalledWithValues installs Tiller by creating its deployment
	// and waiting for it to start. A service account and cluster role binding are
	// also created. Values can be provided to pass through to Tiller
	// and overwrite its deployment defaults.
	EnsureTillerInstalledWithValues(ctx context.Context, values []string) error
	// GetReleaseContent gets the current status of the Helm Release. The
	// releaseName is the name of the Helm Release that is set when the Chart
	// is installed.
	GetReleaseContent(ctx context.Context, releaseName string) (*ReleaseContent, error)
	// GetReleaseHistory gets the current installed version of the Helm Release.
	// The releaseName is the name of the Helm Release that is set when the Helm
	// Chart is installed.
	GetReleaseHistory(ctx context.Context, releaseName string) (*ReleaseHistory, error)
	// InstallReleaseFromTarball installs a Helm Chart packaged in the given tarball.
	InstallReleaseFromTarball(ctx context.Context, path, ns string, options ...helm.InstallOption) error
	// ListReleaseContents gets the current status of all Helm Releases.
	ListReleaseContents(ctx context.Context) ([]*ReleaseContent, error)
	// LoadChart loads a Helm Chart and returns its structure.
	LoadChart(ctx context.Context, chartPath string) (Chart, error)
	// PingTiller proxies the underlying Helm client PingTiller method.
	PingTiller(ctx context.Context) error
	// PullChartTarball downloads a tarball from the provided tarball URL,
	// returning the file path.
	PullChartTarball(ctx context.Context, tarballURL string) (string, error)
	// RunReleaseTest runs the tests for a Helm Release. This is the same
	// action as running the helm test command.
	RunReleaseTest(ctx context.Context, releaseName string, options ...helm.ReleaseTestOption) error
	// UpdateReleaseFromTarball updates the given release using the chart packaged
	// in the tarball.
	UpdateReleaseFromTarball(ctx context.Context, releaseName, path string, options ...helm.UpdateOption) error
}

Interface describes the methods provided by the helm client.

type ReleaseContent

type ReleaseContent struct {
	// Name is the name of the Helm Release.
	Name string
	// Status is the Helm status code of the Release.
	Status string
	// Values are the values provided when installing the Helm Release.
	Values map[string]interface{}
}

ReleaseContent returns status information about a Helm Release.

type ReleaseHistory

type ReleaseHistory struct {
	// AppVersion is the app version of the Helm Chart that has been deployed.
	AppVersion string
	// Description is a human-friendly "log entry" about this Helm release.
	Description string
	// LastDeployed is the time the Helm Chart was last deployed.
	LastDeployed time.Time
	// Name is the name of the Helm Release.
	Name string
	// Version is the version of the Helm Chart that has been deployed.
	Version string
}

ReleaseHistory returns version information about a Helm Release.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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