helminstall

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TempChartFilePermissions = os.FileMode(0644)
	TempChartPrefix          = "temp-helm-chart"
)

Variables

View Source
var (
	ReleaseAlreadyInstalledErr = func(name, namespace string) error {
		return eris.Errorf("The helm release you are trying to install (%s) appears"+
			" to already exist in %s", name, namespace)
	}
)

Functions

func NewCLISettings

func NewCLISettings(kubeConfig, kubeContext, namespace string) *cli.EnvSettings

Build a Helm EnvSettings struct basically, abstracted cli.New() into our own function call because of the weirdness described in the big comment below also configure the Helm client with the Kube config/context of the cluster to perform installation on

func NewDefaultHelmClient

func NewDefaultHelmClient(
	fs FsHelper,
	resourceFetcher ResourceFetcher,
	helmLoaders HelmFactories) *defaultHelmClient

func NewNamespaceClient

func NewNamespaceClient(client v1.NamespaceInterface) *namespaceClient

Types

type ActionConfigFactory

type ActionConfigFactory interface {
	NewActionConfig(kubeConfig, helmKubeContext, namespace string) (*action.Configuration, *cli.EnvSettings, error)
}

func NewActionConfigFactory

func NewActionConfigFactory() ActionConfigFactory

type ActionListFactory

type ActionListFactory interface {
	ReleaseList(kubeConfig, helmKubeContext, namespace string) (ReleaseListRunner, error)
}

Returns a ReleaseListRunner

func NewActionListFactory

func NewActionListFactory(actionConfigFactory ActionConfigFactory) ActionListFactory

type ChartLoader

type ChartLoader interface {
	Load(name string) (*chart.Chart, error)
}

slim interface on top of loader to avoid unnecessary FS calls

func NewChartLoader

func NewChartLoader() ChartLoader

type FsHelper

type FsHelper interface {
	NewTempFile(dir, prefix string) (f afero.File, err error)
	WriteFile(filename string, data []byte, perm os.FileMode) error
	RemoveAll(path string) error
}

interface around needed afero functions

func NewFs

func NewFs(fs afero.Fs) FsHelper

type HelmClient

type HelmClient interface {
	// Prepare an installation object that can then be .Run() with a chart object
	NewInstall(kubeConfig, kubeContext, namespace, releaseName string, dryRun bool) (HelmInstaller, *cli.EnvSettings, error)

	// Prepare an un-installation object that can then be .Run() with a release name
	NewUninstall(kubeConfig, kubeContext, namespace string) (HelmUninstaller, error)

	// List the already-existing releases in the given namespace
	ReleaseList(kubeConfig, kubeContext, namespace string) (ReleaseListRunner, error)

	// Returns the Helm chart archive located at the given URI (can be either an http(s) address or a file path)
	DownloadChart(chartArchiveUri string) (*chart.Chart, error)

	// Returns true if the release with the given name exists in the given namespace
	ReleaseExists(kubeConfig, kubeContext, namespace, releaseName string) (releaseExists bool, err error)
}

This interface implements the Helm CLI actions. The implementation relies on the Helm 3 libraries.

func DefaultHelmClient

func DefaultHelmClient() HelmClient

a HelmClient that talks to the kube api server and creates resources

type HelmFactories

type HelmFactories struct {
	ActionConfigFactory ActionConfigFactory
	ActionListFactory   ActionListFactory
	ChartLoader         ChartLoader
}

func NewHelmFactories

func NewHelmFactories() HelmFactories

type HelmInstaller

type HelmInstaller interface {
	Run(chrt *chart.Chart, vals map[string]interface{}) (*release.Release, error)
}

an interface around Helm's action.Install struct

type HelmUninstaller

type HelmUninstaller interface {
	Run(name string) (*release.UninstallReleaseResponse, error)
}

an interface around Helm's action.Uninstall struct

type Installer

type Installer interface {
	Install(installerConfig *InstallerConfig) error
}

func MustInstaller

func MustInstaller() Installer

func NewInstaller

func NewInstaller(helmClient HelmClient, kubeNsClient NamespaceCLient, outputWriter io.Writer) Installer

visible for testing

type InstallerConfig

type InstallerConfig struct {
	// kube config containing the context of cluster to install on
	KubeConfig string
	// kube context of cluster to install on
	KubeContext      string
	DryRun           bool
	CreateNamespace  bool
	Verbose          bool
	InstallNamespace string
	ReleaseName      string
	// the uri to the helm chart, can either be a local file or a valid http/https link
	ReleaseUri  string
	ValuesFiles []string
	ExtraValues map[string]interface{}

	PreInstallMessage  string
	PostInstallMessage string
}

type NamespaceCLient

type NamespaceCLient interface {
	Create(ns *corev1.Namespace) (*corev1.Namespace, error)
	Delete(name string, options *metav1.DeleteOptions) error
	Get(name string, options metav1.GetOptions) (*corev1.Namespace, error)
	List(opts metav1.ListOptions) (*corev1.NamespaceList, error)
}

type ReleaseListRunner

type ReleaseListRunner interface {
	Run() ([]*release.Release, error)
	SetFilter(filter string)
}

an interface around Helm's action.List struct

type ResourceFetcher

type ResourceFetcher interface {
	GetResource(uri string) (io.ReadCloser, error)
}

func NewDefaultResourceFetcher

func NewDefaultResourceFetcher() ResourceFetcher

Directories

Path Synopsis
Package mock_helminstall is a generated GoMock package.
Package mock_helminstall is a generated GoMock package.

Jump to

Keyboard shortcuts

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