state

package
v0.75.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: MIT Imports: 25 Imported by: 10

Documentation

Index

Constants

View Source
const DefaultEnv = "default"
View Source
const MissingFileHandlerDebug = "Debug"
View Source
const MissingFileHandlerError = "Error"
View Source
const MissingFileHandlerInfo = "Info"
View Source
const MissingFileHandlerWarn = "Warn"
View Source
const ReleaseErrorCodeFailure = 1

Variables

This section is empty.

Functions

func NewChartDependencyManager

func NewChartDependencyManager(name string, logger *zap.SugaredLogger) *chartDependencyManager

Types

type AffectedReleases

type AffectedReleases struct {
	Upgraded []*ReleaseSpec
	Deleted  []*ReleaseSpec
	Failed   []*ReleaseSpec
}

AffectedReleases hold the list of released that where updated, deleted, or in error

func (*AffectedReleases) DisplayAffectedReleases

func (ar *AffectedReleases) DisplayAffectedReleases(logger *zap.SugaredLogger)

DisplayAffectedReleases logs the upgraded, deleted and in error releases

type ChartLockedRequirements

type ChartLockedRequirements struct {
	ResolvedDependencies []ResolvedChartDependency `yaml:"dependencies"`
	Digest               string                    `yaml:"digest"`
	Generated            string                    `yaml:"generated"`
}

type ChartMeta

type ChartMeta struct {
	Name string `yaml:"name"`
}

type ChartRequirements

type ChartRequirements struct {
	UnresolvedDependencies []unresolvedChartDependency `yaml:"dependencies"`
}

type EnvironmentSpec

type EnvironmentSpec struct {
	Values  []interface{} `yaml:"values"`
	Secrets []string      `yaml:"secrets"`

	// MissingFileHandler instructs helmfile to fail when unable to find a environment values file listed
	// under `environments.NAME.values`.
	//
	// Possible values are  "Error", "Warn", "Info", "Debug". The default is "Error".
	//
	// Use "Warn", "Info", or "Debug" if you want helmfile to not fail when a values file is missing, while just leaving
	// a message about the missing file at the log-level.
	MissingFileHandler *string `yaml:"missingFileHandler"`
}

type EnvironmentTemplateData

type EnvironmentTemplateData struct {
	// Environment is accessible as `.Environment` from any template executed by the renderer
	Environment environment.Environment
	// Namespace is accessible as `.Namespace` from any non-values template executed by the renderer
	Namespace string
	// Values is accessible as `.Values` and it contains default state values overrode by environment values and override values.
	Values map[string]interface{}
}

EnvironmentTemplateData provides variables accessible while executing golang text/template expressions in helmfile and values YAML files

type EnvironmentValuesLoader

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

func NewEnvironmentValuesLoader

func NewEnvironmentValuesLoader(storage *Storage, readFile func(string) ([]byte, error)) *EnvironmentValuesLoader

func (*EnvironmentValuesLoader) LoadEnvironmentValues

func (ld *EnvironmentValuesLoader) LoadEnvironmentValues(missingFileHandler *string, envValues []interface{}) (map[string]interface{}, error)

type HelmSpec

type HelmSpec struct {
	KubeContext     string   `yaml:"kubeContext"`
	TillerNamespace string   `yaml:"tillerNamespace"`
	Tillerless      bool     `yaml:"tillerless"`
	Args            []string `yaml:"args"`
	Verify          bool     `yaml:"verify"`
	// Devel, when set to true, use development versions, too. Equivalent to version '>0.0.0-0'
	Devel bool `yaml:"devel"`
	// Wait, if set to true, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful
	Wait bool `yaml:"wait"`
	// Timeout is the time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks, and waits on pod/pvc/svc/deployment readiness) (default 300)
	Timeout int `yaml:"timeout"`
	// RecreatePods, when set to true, instruct helmfile to perform pods restart for the resource if applicable
	RecreatePods bool `yaml:"recreatePods"`
	// Force, when set to true, forces resource update through delete/recreate if needed
	Force bool `yaml:"force"`
	// Atomic, when set to true, restore previous state in case of a failed install/upgrade attempt
	Atomic bool `yaml:"atomic"`

	TLS       bool   `yaml:"tls"`
	TLSCACert string `yaml:"tlsCACert"`
	TLSKey    string `yaml:"tlsKey"`
	TLSCert   string `yaml:"tlsCert"`
}

HelmSpec to defines helmDefault values

type HelmState

type HelmState struct {
	FilePath string

	// DefaultValues is the default values to be overrode by environment values and command-line overrides
	DefaultValues []interface{} `yaml:"values"`

	Environments map[string]EnvironmentSpec `yaml:"environments"`

	Bases              []string          `yaml:"bases"`
	HelmDefaults       HelmSpec          `yaml:"helmDefaults"`
	Helmfiles          []SubHelmfileSpec `yaml:"helmfiles"`
	DeprecatedContext  string            `yaml:"context"`
	DeprecatedReleases []ReleaseSpec     `yaml:"charts"`
	Namespace          string            `yaml:"namespace"`
	Repositories       []RepositorySpec  `yaml:"repositories"`
	Releases           []ReleaseSpec     `yaml:"releases"`
	Selectors          []string

	Templates map[string]TemplateSpec `yaml:"templates"`

	Env environment.Environment
	// contains filtered or unexported fields
}

HelmState structure for the helmfile

func (*HelmState) BuildDeps

func (st *HelmState) BuildDeps(helm helmexec.Interface) []error

BuildDeps wrapper for building dependencies on the releases

func (*HelmState) Clean

func (st *HelmState) Clean() []error

Clean will remove any generated secrets

func (*HelmState) DeleteReleases

func (st *HelmState) DeleteReleases(affectedReleases *AffectedReleases, helm helmexec.Interface, purge bool) []error

DeleteReleases wrapper for executing helm delete on the releases

func (*HelmState) DetectReleasesToBeDeleted

func (st *HelmState) DetectReleasesToBeDeleted(helm helmexec.Interface) ([]*ReleaseSpec, error)

func (*HelmState) DiffReleases

func (st *HelmState) DiffReleases(helm helmexec.Interface, additionalValues []string, workerLimit int, detailedExitCode, suppressSecrets bool, triggerCleanupEvents bool) ([]*ReleaseSpec, []error)

DiffReleases wrapper for executing helm diff on the releases It returns releases that had any changes

func (*HelmState) ExecuteTemplates

func (st *HelmState) ExecuteTemplates() (*HelmState, error)

func (*HelmState) ExpandedHelmfiles

func (st *HelmState) ExpandedHelmfiles() ([]SubHelmfileSpec, error)

func (*HelmState) FilterReleases

func (st *HelmState) FilterReleases() error

FilterReleases allows for the execution of helm commands against a subset of the releases in the helmfile.

func (*HelmState) LintReleases

func (st *HelmState) LintReleases(helm helmexec.Interface, additionalValues []string, args []string, workerLimit int) []error

LintReleases wrapper for executing helm lint on the releases

func (*HelmState) PrepareReleases

func (st *HelmState) PrepareReleases(helm helmexec.Interface, helmfileCommand string) []error

func (*HelmState) ReleaseStatuses

func (st *HelmState) ReleaseStatuses(helm helmexec.Interface, workerLimit int) []error

func (*HelmState) RenderValuesFileToBytes

func (st *HelmState) RenderValuesFileToBytes(path string) ([]byte, error)

func (*HelmState) ResolveDeps

func (st *HelmState) ResolveDeps() (*HelmState, error)

ResolveDeps returns a copy of this helmfile state with the concrete chart version numbers filled in for remote chart dependencies

func (*HelmState) SyncReleases

func (st *HelmState) SyncReleases(affectedReleases *AffectedReleases, helm helmexec.Interface, additionalValues []string, workerLimit int) []error

SyncReleases wrapper for executing helm upgrade on the releases

func (*HelmState) SyncRepos

func (st *HelmState) SyncRepos(helm RepoUpdater) []error

SyncRepos will update the given helm releases

func (*HelmState) TemplateReleases

func (st *HelmState) TemplateReleases(helm helmexec.Interface, additionalValues []string, args []string, workerLimit int) []error

TemplateReleases wrapper for executing helm template on the releases

func (*HelmState) TestReleases

func (st *HelmState) TestReleases(helm helmexec.Interface, cleanup bool, timeout int, concurrency int) []error

TestReleases wrapper for executing helm test on the releases

func (*HelmState) UpdateDeps

func (st *HelmState) UpdateDeps(helm helmexec.Interface) []error

UpdateDeps wrapper for updating dependencies on the releases

func (*HelmState) Values added in v0.71.0

func (st *HelmState) Values() (map[string]interface{}, error)

type LabelFilter

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

LabelFilter matches a release with the given positive lables. Negative labels invert the match for cases such as tier!=backend

func ParseLabels

func ParseLabels(l string) (LabelFilter, error)

ParseLabels takes a label in the form foo=bar,baz!=bat and returns a LabelFilter that will match the labels

func (LabelFilter) Match

func (l LabelFilter) Match(r ReleaseSpec) bool

Match will match a release that has the same labels as the filter

type ReleaseError

type ReleaseError struct {
	*ReleaseSpec

	Code int
	// contains filtered or unexported fields
}

func (*ReleaseError) Error

func (e *ReleaseError) Error() string

type ReleaseFilter

type ReleaseFilter interface {
	// Match returns true if the ReleaseSpec matches the Filter
	Match(r ReleaseSpec) bool
}

ReleaseFilter is used to determine if a given release should be used during helmfile execution

type ReleaseSpec

type ReleaseSpec struct {
	// Chart is the name of the chart being installed to create this release
	Chart   string `yaml:"chart"`
	Version string `yaml:"version"`
	Verify  *bool  `yaml:"verify"`
	// Devel, when set to true, use development versions, too. Equivalent to version '>0.0.0-0'
	Devel *bool `yaml:"devel"`
	// Wait, if set to true, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful
	Wait *bool `yaml:"wait"`
	// Timeout is the time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks, and waits on pod/pvc/svc/deployment readiness) (default 300)
	Timeout *int `yaml:"timeout"`
	// RecreatePods, when set to true, instruct helmfile to perform pods restart for the resource if applicable
	RecreatePods *bool `yaml:"recreatePods"`
	// Force, when set to true, forces resource update through delete/recreate if needed
	Force *bool `yaml:"force"`
	// Installed, when set to true, `delete --purge` the release
	Installed *bool `yaml:"installed"`
	// Atomic, when set to true, restore previous state in case of a failed install/upgrade attempt
	Atomic *bool `yaml:"atomic"`

	// MissingFileHandler is set to either "Error" or "Warn". "Error" instructs helmfile to fail when unable to find a values or secrets file. When "Warn", it prints the file and continues.
	// The default value for MissingFileHandler is "Error".
	MissingFileHandler *string `yaml:"missingFileHandler"`

	// Hooks is a list of extension points paired with operations, that are executed in specific points of the lifecycle of releases defined in helmfile
	Hooks []event.Hook `yaml:"hooks"`

	// Name is the name of this release
	Name      string            `yaml:"name"`
	Namespace string            `yaml:"namespace"`
	Labels    map[string]string `yaml:"labels"`
	Values    []interface{}     `yaml:"values"`
	Secrets   []string          `yaml:"secrets"`
	SetValues []SetValue        `yaml:"set"`

	// The 'env' section is not really necessary any longer, as 'set' would now provide the same functionality
	EnvValues []SetValue `yaml:"env"`

	ValuesPathPrefix string `yaml:"valuesPathPrefix"`

	TillerNamespace string `yaml:"tillerNamespace"`
	Tillerless      *bool  `yaml:"tillerless"`

	TLS       *bool  `yaml:"tls"`
	TLSCACert string `yaml:"tlsCACert"`
	TLSKey    string `yaml:"tlsKey"`
	TLSCert   string `yaml:"tlsCert"`
	// contains filtered or unexported fields
}

ReleaseSpec defines the structure of a helm release

func (ReleaseSpec) Clone

func (r ReleaseSpec) Clone() (*ReleaseSpec, error)

func (ReleaseSpec) Desired

func (r ReleaseSpec) Desired() bool

func (ReleaseSpec) ExecuteTemplateExpressions

func (r ReleaseSpec) ExecuteTemplateExpressions(renderer *tmpl.FileRenderer) (*ReleaseSpec, error)

type RepoUpdater

type RepoUpdater interface {
	AddRepo(name, repository, certfile, keyfile, username, password string) error
	UpdateRepo() error
}

type RepositorySpec

type RepositorySpec struct {
	Name     string `yaml:"name"`
	URL      string `yaml:"url"`
	CertFile string `yaml:"certFile"`
	KeyFile  string `yaml:"keyFile"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

RepositorySpec that defines values for a helm repo

type ResolvedChartDependency

type ResolvedChartDependency struct {
	// ChartName identifies the dependant chart. In Helmfile, ChartName for `chart: stable/envoy` would be just `envoy`.
	// It can't be collided with other charts referenced in the same helmfile spec.
	// That is, collocating `chart: incubator/foo` and `chart: stable/foo` isn't allowed. Name them differently for a work-around.
	ChartName string `yaml:"name"`
	// Repository contains the URL for the helm chart repository that hosts the chart identified by ChartName
	Repository string `yaml:"repository"`
	// Version is the version number of the dependent chart.
	// In the context of helmfile this can be omitted. When omitted, it is considered `*` which results helm/helmfile fetching the latest version.
	Version string `yaml:"version"`
}

type ResolvedDependencies

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

func (*ResolvedDependencies) Get

func (d *ResolvedDependencies) Get(chart, versionConstraint string) (string, error)

type SetValue

type SetValue struct {
	Name   string   `yaml:"name"`
	Value  string   `yaml:"value"`
	File   string   `yaml:"file"`
	Values []string `yaml:"values"`
}

SetValue are the key values to set on a helm release

type StateCreator

type StateCreator struct {
	Strict bool

	LoadFile func(inheritedEnv *environment.Environment, baseDir, file string, evaluateBases bool) (*HelmState, error)
	// contains filtered or unexported fields
}

func NewCreator

func NewCreator(logger *zap.SugaredLogger, readFile func(string) ([]byte, error), fileExists func(string) (bool, error), abs func(string) (string, error), glob func(string) ([]string, error)) *StateCreator

func (*StateCreator) LoadEnvValues

func (c *StateCreator) LoadEnvValues(target *HelmState, env string, ctxEnv *environment.Environment) (*HelmState, error)

LoadEnvValues loads environment values files relative to the `baseDir`

func (*StateCreator) Parse

func (c *StateCreator) Parse(content []byte, baseDir, file string) (*HelmState, error)

Parse parses YAML into HelmState

func (*StateCreator) ParseAndLoad

func (c *StateCreator) ParseAndLoad(content []byte, baseDir, file string, envName string, evaluateBases bool, envValues *environment.Environment) (*HelmState, error)

Parses YAML into HelmState, while loading environment values files relative to the `baseDir`

type StateLoadError

type StateLoadError struct {
	Cause error
	// contains filtered or unexported fields
}

func (*StateLoadError) Error

func (e *StateLoadError) Error() string

type Storage

type Storage struct {
	FilePath string
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage(forFile string, logger *zap.SugaredLogger, glob func(string) ([]string, error)) *Storage

func (*Storage) ExpandPaths

func (st *Storage) ExpandPaths(globPattern string) ([]string, error)

func (*Storage) JoinBase

func (st *Storage) JoinBase(relPath string) string

JoinBase returns an absolute path in the form basePath/relative

type SubHelmfileSpec

type SubHelmfileSpec struct {
	Path               string   //path or glob pattern for the sub helmfiles
	Selectors          []string //chosen selectors for the sub helmfiles
	SelectorsInherited bool     //do the sub helmfiles inherits from parent selectors

	Environment SubhelmfileEnvironmentSpec
}

SubHelmfileSpec defines the subhelmfile path and options

func (*SubHelmfileSpec) UnmarshalYAML

func (hf *SubHelmfileSpec) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML will unmarshal the helmfile yaml section and fill the SubHelmfileSpec structure this is required to keep allowing string scalar for defining helmfile

type SubhelmfileEnvironmentSpec

type SubhelmfileEnvironmentSpec struct {
	OverrideValues []interface{} `yaml:"values"`
}

type TemplateSpec

type TemplateSpec struct {
	ReleaseSpec `yaml:",inline"`
}

TemplateSpec defines the structure of a reusable and composable template for helm releases.

type UndefinedEnvError

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

func (*UndefinedEnvError) Error

func (e *UndefinedEnvError) Error() string

type UnresolvedDependencies

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

func (*UnresolvedDependencies) Add

func (d *UnresolvedDependencies) Add(chart, url, versionConstraint string) error

func (*UnresolvedDependencies) ToChartRequirements

func (d *UnresolvedDependencies) ToChartRequirements() *ChartRequirements

Jump to

Keyboard shortcuts

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