helm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWritePermissions = 0760

	MaximumNewDirectoryAttempts = 1000
)
View Source
const (
	// ChartFileName file name for a chart
	ChartFileName = "Chart.yaml"
)

Variables

This section is empty.

Functions

func ContentTypeForFileName

func ContentTypeForFileName(name string) string

ContentTypeForFileName returns the MIME type for the given file name

func CopyDirOverwrite

func CopyDirOverwrite(src string, dst string) (err error)

CopyDirOverwrite copies from the source dir to the destination dir overwriting files along the way

func CopyDirPreserve

func CopyDirPreserve(src string, dst string) error

CopyDirPreserve copies from the src dir to the dst dir if the file does NOT already exist in dst

func CopyFileOrDir

func CopyFileOrDir(src string, dst string, force bool) (err error)

CopyFileOrDir copies the source file or directory to the given destination

func CreateUniqueDirectory

func CreateUniqueDirectory(dir string, name string, maximumAttempts int) (string, error)

CreateUniqueDirectory creates a new directory but if the combination of dir and name exists then append a number until a unique name is found

func DeleteDirContents

func DeleteDirContents(dir string) error

DeleteDirContents removes all the contents of the given directory

func DeleteDirContentsExcept

func DeleteDirContentsExcept(dir string, exceptDir string) error

func DeleteFile

func DeleteFile(fileName string) (err error)

DeleteFile deletes a file from the operating system. This should NOT be used to delete any sensitive information because it can easily be recovered. Use DestroyFile to delete sensitive information

func DestroyFile

func DestroyFile(filename string) error

DestroyFile will securely delete a file by first overwriting it with random bytes, then deleting it. This should always be used for deleting sensitive information

func DirExists

func DirExists(path string) (bool, error)

DirExists checks if path exists and is a directory

func FileExists

func FileExists(path string) (bool, error)

func FileIsEmpty

func FileIsEmpty(path string) (bool, error)

FileIsEmpty checks if a file is empty

func FilterFileExists

func FilterFileExists(paths []string) []string

FilterFileExists filters out files which do not exist

func FirstFileExists

func FirstFileExists(paths ...string) (string, error)

FirstFileExists returns the first file which exists or an error if we can't detect if a file that exists

func GlobAllFiles

func GlobAllFiles(basedir string, pattern string, fn func(string) error) error

GlobAllFiles performs a glob on the pattern and then processes all the files found. if a folder matches the glob its treated as another glob to recurse into the directory

func IgnoreFile

func IgnoreFile(path string, ignores []string) (bool, error)

IgnoreFile returns true if the path matches any of the ignores. The match is the same as filepath.Match.

func IsEmpty

func IsEmpty(name string) (bool, error)

func ListDirectory

func ListDirectory(root string, recurse bool) error

ListDirectory logs the directory at path

func LoadBytes

func LoadBytes(dir, name string) ([]byte, error)

loads a file

func Now

func Now() *timestamp.Timestamp

func PathWithBinary

func PathWithBinary(paths ...string) string

PathWithBinary Sets the $PATH variable. Accepts an optional slice of strings containing paths to add to $PATH

func RecreateDirs

func RecreateDirs(dirs ...string) error

DeleteDirContents removes all the contents of the given directory

func RenameDir

func RenameDir(src string, dst string, force bool) (err error)

func RenameFile

func RenameFile(src string, dst string) (err error)

func SplitManifests

func SplitManifests(bigFile string) map[string]string

SplitManifests takes a string of manifest and returns a map contains individual manifests

func Template

func Template(repo string, releaseName string, outputDir string, showNotes bool, stringValues []string) (res string, err error)

func Timestamp

func Timestamp(t time.Time) *timestamp.Timestamp

Types

type ChartSummary

type ChartSummary struct {
	Name         string
	ChartVersion string
	AppVersion   string
	Description  string
}

type Command

type Command struct {
	Errors             []error
	Dir                string
	Name               string
	Args               []string
	ExponentialBackOff *backoff.ExponentialBackOff
	Timeout            time.Duration
	Out                io.Writer
	Err                io.Writer
	Env                map[string]string
	// contains filtered or unexported fields
}

Command is a struct containing the details of an external command to be executed

func (*Command) Attempts

func (c *Command) Attempts() int

Attempts The number of times the command has been executed

func (*Command) CurrentArgs

func (c *Command) CurrentArgs() []string

CurrentArgs returns the current command arguments

func (*Command) CurrentDir

func (c *Command) CurrentDir() string

CurrentDir returns the current Dir

func (*Command) CurrentEnv

func (c *Command) CurrentEnv() map[string]string

CurrentEnv returns the current envrionment variables

func (*Command) CurrentName

func (c *Command) CurrentName() string

CurrentName returns the current name of the command

func (*Command) DidError

func (c *Command) DidError() bool

DidError returns a boolean if any error occurred in any execution of the command

func (*Command) DidFail

func (c *Command) DidFail() bool

DidFail returns a boolean if the command could not complete (errored on every attempt)

func (*Command) Error

func (c *Command) Error() error

Error returns the last error

func (*Command) Run

func (c *Command) Run() (string, error)

Run Execute the command and block waiting for return values

func (*Command) RunWithoutRetry

func (c *Command) RunWithoutRetry() (string, error)

RunWithoutRetry Execute the command without retrying on failure and block waiting for return values

func (*Command) SetArgs

func (c *Command) SetArgs(args []string)

SetArgs Setter method for Args to enable use of interface instead of Command struct

func (*Command) SetDir

func (c *Command) SetDir(dir string)

SetDir Setter method for Dir to enable use of interface instead of Command struct

func (*Command) SetEnv

func (c *Command) SetEnv(env map[string]string)

SetEnv Setter method for Env to enable use of interface instead of Command struct

func (*Command) SetEnvVariable

func (c *Command) SetEnvVariable(name string, value string)

SetEnvVariable sets an environment variable into the environment

func (*Command) SetExponentialBackOff

func (c *Command) SetExponentialBackOff(backoff *backoff.ExponentialBackOff)

SetExponentialBackOff Setter method for ExponentialBackOff to enable use of interface instead of Command struct

func (*Command) SetName

func (c *Command) SetName(name string)

SetName Setter method for Name to enable use of interface instead of Command struct

func (*Command) SetTimeout

func (c *Command) SetTimeout(timeout time.Duration)

SetTimeout Setter method for Timeout to enable use of interface instead of Command struct

func (*Command) String

func (c *Command) String() string

type CommandError

type CommandError struct {
	Command Command
	Output  string
	// contains filtered or unexported fields
}

CommandError is the error object encapsulating an error from a Command

func (CommandError) Error

func (c CommandError) Error() string

type Commander

type Commander interface {
	DidError() bool
	DidFail() bool
	Error() error
	Run() (string, error)
	RunWithoutRetry() (string, error)
	SetName(string)
	CurrentName() string
	SetDir(string)
	CurrentDir() string
	SetArgs([]string)
	CurrentArgs() []string
	SetTimeout(time.Duration)
	SetExponentialBackOff(*backoff.ExponentialBackOff)
	SetEnv(map[string]string)
	CurrentEnv() map[string]string
	SetEnvVariable(string, string)
}

Commander defines the interface for a Command

type HelmCLI

type HelmCLI struct {
	Binary     string
	BinVersion Version
	CWD        string
	Runner     Commander
	Debug      bool
}

HelmCLI implements common helm actions based on helm CLI

func NewHelmCLI

func NewHelmCLI(binary string, version Version, cwd string, debug bool, args ...string) *HelmCLI

NewHelmCLI creates a new HelmCLI instance configured to use the provided helm CLI in the given current working directory

func NewHelmCLIWithRunner

func NewHelmCLIWithRunner(runner Commander, binary string, version Version, cwd string, debug bool) *HelmCLI

NewHelmCLIWithRunner creaets a new HelmCLI interface for the given runner

func (*HelmCLI) AddRepo

func (h *HelmCLI) AddRepo(repo, URL, username, password string) error

AddRepo adds a new helm repo with the given name and URL

func (*HelmCLI) BuildDependency

func (h *HelmCLI) BuildDependency() error

BuildDependency builds the helm dependencies of the helm chart from the current working directory

func (*HelmCLI) DecryptSecrets

func (h *HelmCLI) DecryptSecrets(location string) error

func (*HelmCLI) DeleteRelease

func (h *HelmCLI) DeleteRelease(ns string, releaseName string, purge bool) error

DeleteRelease removes the given release

func (*HelmCLI) Env

func (h *HelmCLI) Env() map[string]string

Env returns the environment variables for the helmer

func (*HelmCLI) FetchChart

func (h *HelmCLI) FetchChart(chart string, version string, untar bool, untardir string, repo string,
	username string, password string) error

FetchChart fetches a Helm Chart

func (*HelmCLI) FindChart

func (h *HelmCLI) FindChart() (string, error)

FindChart find a chart in the current working directory, if no chart file is found an error is returned

func (*HelmCLI) HelmBinary

func (h *HelmCLI) HelmBinary() string

HelmBinary return the configured helm CLI

func (*HelmCLI) Init

func (h *HelmCLI) Init(clientOnly bool, serviceAccount string, tillerNamespace string, upgrade bool) error

Init executes the helm init command according with the given flags

func (*HelmCLI) InstallChart

func (h *HelmCLI) InstallChart(chart string, releaseName string, ns string, version string, timeout int,
	values []string, valueFiles []string, repo string, username string, password string) error

InstallChart installs a helm chart according with the given flags

func (*HelmCLI) IsRepoMissing

func (h *HelmCLI) IsRepoMissing(URL string) (bool, error)

IsRepoMissing checks if the repository with the given URL is missing from helm

func (*HelmCLI) Lint

func (h *HelmCLI) Lint() (string, error)

Lint lints the helm chart from the current working directory and returns the warnings in the output

func (*HelmCLI) ListCharts

func (h *HelmCLI) ListCharts() (string, error)

ListCharts execute the helm list command and returns its output

func (*HelmCLI) ListRepos

func (h *HelmCLI) ListRepos() (map[string]string, error)

ListRepos list the installed helm repos together with their URL

func (*HelmCLI) PackageChart

func (h *HelmCLI) PackageChart() error

PackageChart packages the chart from the current working directory

func (*HelmCLI) RemoveRepo

func (h *HelmCLI) RemoveRepo(repo string) error

RemoveRepo removes the given repo from helm

func (*HelmCLI) RemoveRequirementsLock

func (h *HelmCLI) RemoveRequirementsLock() error

RemoveRequirementsLock removes the requirements.lock file from the current working directory

func (*HelmCLI) SearchChartVersions

func (h *HelmCLI) SearchChartVersions(chart string) ([]string, error)

SearchChartVersions search all version of the given chart

func (*HelmCLI) SearchCharts

func (h *HelmCLI) SearchCharts(filter string) ([]ChartSummary, error)

SearchCharts searches for all the charts matching the given filter

func (*HelmCLI) SetCWD

func (h *HelmCLI) SetCWD(dir string)

SetCWD configures the common working directory of helm CLI

func (*HelmCLI) SetHelmBinary

func (h *HelmCLI) SetHelmBinary(binary string)

SetHelmBinary configure a new helm CLI

func (*HelmCLI) SetHost

func (h *HelmCLI) SetHost(tillerAddress string)

SetHost is used to point at a locally running tiller

func (*HelmCLI) StatusRelease

func (h *HelmCLI) StatusRelease(ns string, releaseName string) error

StatusRelease returns the output of the helm status command for a given release

func (*HelmCLI) Template

func (h *HelmCLI) Template(chart string, releaseName string, ns string, outDir string, upgrade bool,
	values []string, valueFiles []string) error

Template generates the YAML from the chart template to the given directory

func (*HelmCLI) UpdateRepo

func (h *HelmCLI) UpdateRepo() error

UpdateRepo updates the helm repositories

func (*HelmCLI) UpgradeChart

func (h *HelmCLI) UpgradeChart(chart string, releaseName string, ns string, version string, install bool,
	timeout int, force bool, wait bool, values []string, valueFiles []string, repo string, username string,
	password string) error

UpgradeChart upgrades a helm chart according with given helm flags

func (*HelmCLI) Version

func (h *HelmCLI) Version(tls bool) (string, error)

Version executes the helm version command and returns its output

func (*HelmCLI) VersionWithArgs

func (h *HelmCLI) VersionWithArgs(tls bool, extraArgs ...string) (string, error)

VersionWithArgs executes the helm version command and returns its output

type SimpleHead

type SimpleHead struct {
	Version  string `json:"apiVersion"`
	Kind     string `json:"kind,omitempty"`
	Metadata *struct {
		Name        string            `json:"name"`
		Annotations map[string]string `json:"annotations"`
	} `json:"metadata,omitempty"`
}

SimpleHead defines what the structure of the head of a manifest file

type Version

type Version int

Version defines the helm version

const (
	V2 Version = 2
	V3         = 3
)

Jump to

Keyboard shortcuts

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