state

package
v0.164.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 42 Imported by: 9

Documentation

Index

Constants

View Source
const (
	DefaultHelmBinary       = "helm"
	DefaultKustomizeBinary  = "kustomize"
	DefaultHCLFileExtension = ".hcl"
)
View Source
const DefaultEnv = "default"

DefaultEnv is the default environment to use for helm commands

View Source
const (
	// EmptyTimeout represents the `--timeout` value passed to helm commands not being specified via helmfile flags.
	// This is used by an interim solution to make the urfave/cli command report to the helmfile internal about that the
	// --timeout flag is missingl
	EmptyTimeout = -1
)
View Source
const MissingFileHandlerDebug = "Debug"

MissingFileHandlerDebug is the debug returned when a file is missing

View Source
const MissingFileHandlerError = "Error"

MissingFileHandlerError is the error returned when a file is missing

View Source
const MissingFileHandlerInfo = "Info"

MissingFileHandlerInfo is the info returned when a file is missing

View Source
const MissingFileHandlerWarn = "Warn"

MissingFileHandlerWarn is the warning returned when a file is missing

View Source
const ReleaseErrorCodeFailure = 1

Variables

View Source
var DefaultFetchOutputDirTemplate = filepath.Join(
	"{{ .OutputDir }}{{ if .Release.Namespace }}",
	"{{ .Release.Namespace }}{{ end }}{{ if .Release.KubeContext }}",
	"{{ .Release.KubeContext }}{{ end }}",
	"{{ .Release.Name }}",
	"{{ .ChartName }}",
	"{{ or .Release.Version \"latest\" }}",
)

Functions

func ConditionEnabled

func ConditionEnabled(r ReleaseSpec, values map[string]any) (bool, error)

ConditionEnabled checks if a release condition is enabled based on the provided values. It takes a ReleaseSpec and a map of values as input. If the condition is not specified, it returns true. If the condition is specified but not in the form 'foo.enabled', it returns an error. If the condition is specified and the corresponding value is found in the values map, it checks if the 'enabled' field is set to true. If so, it returns true. Otherwise, it returns false. If the condition is specified but the corresponding value is not found in the values map, it returns an error.

func GroupReleasesByDependency

func GroupReleasesByDependency(releases []Release, opts PlanOptions) ([][]Release, error)

func HashObject

func HashObject(obj any) (string, error)

func Logs

func Logs(v bool) func(*TestOpts)

func NewChartDependencyManager

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

func ReleaseToID

func ReleaseToID(r *ReleaseSpec) string

func SortedReleaseGroups

func SortedReleaseGroups(releases []Release, opts PlanOptions) ([][]Release, error)

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 {
	Version              string                    `yaml:"version"`
	ResolvedDependencies []ResolvedChartDependency `yaml:"dependencies"`
	Digest               string                    `yaml:"digest"`
	Generated            string                    `yaml:"generated"`
}

type ChartMeta

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

type ChartPrepareOptions

type ChartPrepareOptions struct {
	ForceDownload bool
	SkipRepos     bool
	SkipDeps      bool
	SkipResolve   bool
	SkipCleanup   bool
	// Validate is a helm-3-only option. When it is set to true, it configures chartify to pass --validate to helm-template run by it.
	// It's required when one of your chart relies on Capabilities.APIVersions in a template
	Validate               bool
	IncludeCRDs            *bool
	Wait                   bool
	WaitForJobs            bool
	OutputDir              string
	OutputDirTemplate      string
	IncludeTransitiveNeeds bool
	Concurrency            int
	KubeVersion            string
	Set                    []string
	// Delete wait
	DeleteWait    bool
	DeleteTimeout int
}

type ChartRequirements

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

type Chartify

type Chartify struct {
	Opts  *chartify.ChartifyOpts
	Clean func()
}

type CyclicReleaseTemplateInheritanceError added in v0.150.0

type CyclicReleaseTemplateInheritanceError struct {
	Message string
}

func (CyclicReleaseTemplateInheritanceError) Error added in v0.150.0

type Dependency

type Dependency struct {
	Chart   string `yaml:"chart"`
	Version string `yaml:"version"`
	Alias   string `yaml:"alias"`
}

type DiffOpt

type DiffOpt interface{ Apply(*DiffOpts) }

type DiffOpts

type DiffOpts struct {
	Context int
	Output  string
	// Color forces the color output on helm-diff.
	// This takes effect only when NoColor is false.
	Color bool
	// NoColor forces disabling the color output on helm-diff.
	// If this is true, Color has no effect.
	NoColor                 bool
	Set                     []string
	SkipCleanup             bool
	SkipDiffOnInstall       bool
	DiffArgs                string
	ReuseValues             bool
	ResetValues             bool
	PostRenderer            string
	PostRendererArgs        []string
	SuppressOutputLineRegex []string
}

func (*DiffOpts) Apply

func (o *DiffOpts) Apply(opts *DiffOpts)

type EnvironmentSpec

type EnvironmentSpec struct {
	Values      []any    `yaml:"values,omitempty"`
	Secrets     []string `yaml:"secrets,omitempty"`
	KubeContext string   `yaml:"kubeContext,omitempty"`

	// 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,omitempty"`
	// MissingFileHandlerConfig is composed of various settings for the MissingFileHandler
	MissingFileHandlerConfig MissingFileHandlerConfig `yaml:"missingFileHandlerConfig,omitempty"`
}

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]any
	StateValues *map[string]any
}

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

func NewEnvironmentTemplateData

func NewEnvironmentTemplateData(environment environment.Environment, namespace string, values map[string]any) *EnvironmentTemplateData

type EnvironmentValuesLoader

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

func NewEnvironmentValuesLoader

func NewEnvironmentValuesLoader(storage *Storage, fs *filesystem.FileSystem, logger *zap.SugaredLogger, remote *remote.Remote) *EnvironmentValuesLoader

func (*EnvironmentValuesLoader) LoadEnvironmentValues

func (ld *EnvironmentValuesLoader) LoadEnvironmentValues(missingFileHandler *string, valuesEntries []any, ctxEnv *environment.Environment, envName string) (map[string]any, error)

type HelmSpec

type HelmSpec struct {
	KubeContext string   `yaml:"kubeContext,omitempty"`
	Args        []string `yaml:"args,omitempty"`
	DiffArgs    []string `yaml:"diffArgs,omitempty"`
	SyncArgs    []string `yaml:"syncArgs,omitempty"`
	Verify      bool     `yaml:"verify"`
	Keyring     string   `yaml:"keyring,omitempty"`
	// EnableDNS, when set to true, enable DNS lookups when rendering templates
	EnableDNS bool `yaml:"enableDNS"`
	// 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"`
	// WaitForJobs, if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout
	WaitForJobs bool `yaml:"waitForJobs"`
	// 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"`
	// CleanupOnFail, when set to true, the --cleanup-on-fail helm flag is passed to the upgrade command
	CleanupOnFail bool `yaml:"cleanupOnFail,omitempty"`
	// HistoryMax, limit the maximum number of revisions saved per release. Use 0 for no limit (default 10)
	HistoryMax *int `yaml:"historyMax,omitempty"`
	// CreateNamespace, when set to true (default), --create-namespace is passed to helm3 on install/upgrade (ignored for helm2)
	CreateNamespace *bool `yaml:"createNamespace,omitempty"`
	// SkipDeps disables running `helm dependency up` and `helm dependency build` on this release's chart.
	// This is relevant only when your release uses a local chart or a directory containing K8s manifests or a Kustomization
	// as a Helm chart.
	SkipDeps bool `yaml:"skipDeps"`
	// on helm upgrade/diff, reuse values currently set in the release and merge them with the ones defined within helmfile
	ReuseValues bool `yaml:"reuseValues"`
	// Propagate '--post-renderer' to helmv3 template and helm install
	PostRenderer *string `yaml:"postRenderer,omitempty"`
	// Propagate '--post-renderer-args' to helmv3 template and helm install
	PostRendererArgs []string `yaml:"postRendererArgs,omitempty"`
	// Cascade '--cascade' to helmv3 delete, available values: background, foreground, or orphan, default: background
	Cascade *string `yaml:"cascade,omitempty"`
	// SuppressOutputLineRegex is a list of regexes to suppress output lines
	SuppressOutputLineRegex []string `yaml:"suppressOutputLineRegex,omitempty"`

	DisableValidation        *bool `yaml:"disableValidation,omitempty"`
	DisableOpenAPIValidation *bool `yaml:"disableOpenAPIValidation,omitempty"`
	// InsecureSkipTLSVerify is true if the TLS verification should be skipped when fetching remote chart
	InsecureSkipTLSVerify bool `yaml:"insecureSkipTLSVerify,omitempty"`
	// Wait, if set to true, will wait until all resources are deleted before mark delete command as successful
	DeleteWait bool `yaml:"deleteWait"`
	// Timeout is the time in seconds to wait for helmfile delete command (default 300)
	DeleteTimeout int `yaml:"deleteTimeout"`
}

HelmSpec to defines helmDefault values

type HelmState

type HelmState struct {
	FilePath string

	ReleaseSetSpec `yaml:",inline"`

	// RenderedValues is the helmfile-wide values that is `.Values`
	// which is accessible from within the whole helmfile go template.
	// Note that this is usually computed by DesiredStateLoader from ReleaseSetSpec.Env
	RenderedValues map[string]any
	// contains filtered or unexported fields
}

HelmState structure for the helmfile

func (*HelmState) ApplyOverrides

func (st *HelmState) ApplyOverrides(spec *ReleaseSpec)

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, concurrency int, purge bool, cascade string) []error

DeleteReleases wrapper for executing helm delete on the releases

func (*HelmState) DeleteReleasesForSync

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

DeleteReleasesForSync deletes releases that are marked for deletion

func (*HelmState) DetectReleasesToBeDeleted

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

func (*HelmState) DetectReleasesToBeDeletedForSync

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

func (*HelmState) DiffReleases

func (st *HelmState) DiffReleases(helm helmexec.Interface, additionalValues []string, workerLimit int, detailedExitCode bool, stripTrailingCR bool, includeTests bool, suppress []string, suppressSecrets, showSecrets, noHooks bool, suppressDiff, triggerCleanupEvents bool, opt ...DiffOpt) ([]ReleaseSpec, []error)

DiffReleases wrapper for executing helm diff on the releases It returns releases that had any changes, and errors if any.

This function has responsibility to stabilize the order of writes to stdout from multiple concurrent helm-diff runs. It's required to use the stdout from helmfile-diff to detect if there was another change(s) between 2 points in time. For example, terraform-provider-helmfile runs a helmfile-diff on `terraform plan` and another on `terraform apply`. `terraform`, by design, fails when helmfile-diff outputs were not equivalent. Stabilized helmfile-diff output rescues that.

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(includeTransitiveNeeds bool) error

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

func (*HelmState) FullFilePath added in v0.148.0

func (st *HelmState) FullFilePath() (string, error)

func (*HelmState) GenerateOutputDir

func (st *HelmState) GenerateOutputDir(outputDir string, release *ReleaseSpec, outputDirTemplate string) (string, error)

func (*HelmState) GenerateOutputFilePath

func (st *HelmState) GenerateOutputFilePath(release *ReleaseSpec, outputFileTemplate string) (string, error)

func (*HelmState) GetReleasesWithOverrides

func (st *HelmState) GetReleasesWithOverrides() ([]ReleaseSpec, error)

func (*HelmState) GetRepositoryAndNameFromChartName

func (st *HelmState) GetRepositoryAndNameFromChartName(chartName string) (*RepositorySpec, string)

func (*HelmState) GetSelectedReleases added in v0.148.1

func (st *HelmState) GetSelectedReleases(includeTransitiveNeeds bool) ([]ReleaseSpec, error)

func (*HelmState) LintReleases

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

LintReleases wrapper for executing helm lint on the releases

func (*HelmState) LoadYAMLForEmbedding

func (st *HelmState) LoadYAMLForEmbedding(release *ReleaseSpec, entries []any, missingFileHandler *string, pathPrefix string) ([]any, error)

func (*HelmState) PlanReleases

func (st *HelmState) PlanReleases(opts PlanOptions) ([][]Release, error)

func (*HelmState) PrepareChartify

func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSpec, chart string, workerIndex int) (*Chartify, func(), error)

func (*HelmState) PrepareCharts

func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurrency int, helmfileCommand string, opts ChartPrepareOptions) (map[PrepareChartKey]string, []error)

PrepareCharts creates temporary directories of charts.

Each resulting "chart" can be one of the followings:

(1) local chart (2) temporary local chart generated from kustomization or manifests (3) remote chart

When running `helmfile template` on helm v2, or `helmfile lint` on both helm v2 and v3, PrepareCharts will download and untar charts for linting and templating.

Otheriwse, if a chart is not a helm chart, it will call "chartify" to turn it into a chart.

If exists, it will also patch resources by json patches, strategic-merge patches, and injectors.

func (*HelmState) ReleaseStatuses

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

func (*HelmState) RenderReleaseValuesFileToBytes

func (st *HelmState) RenderReleaseValuesFileToBytes(release *ReleaseSpec, 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) Reverse

func (st *HelmState) Reverse()

func (*HelmState) SelectReleases added in v0.148.1

func (st *HelmState) SelectReleases(includeTransitiveNeeds bool) ([]Release, error)

func (*HelmState) SyncReleases

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

SyncReleases wrapper for executing helm upgrade on the releases

func (*HelmState) SyncRepos

func (st *HelmState) SyncRepos(helm RepoUpdater, shouldSkip map[string]bool) ([]string, error)

func (*HelmState) TemplateReleases

func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string, additionalValues []string, args []string, workerLimit int,
	validate bool, opt ...TemplateOpt) []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, options ...TestOption) []error

TestReleases wrapper for executing helm test on the releases

func (*HelmState) ToYaml

func (st *HelmState) ToYaml() (string, error)

func (*HelmState) TriggerCleanupEvent

func (st *HelmState) TriggerCleanupEvent(r *ReleaseSpec, helmfileCommand string) (bool, error)

func (*HelmState) TriggerGlobalCleanupEvent

func (st *HelmState) TriggerGlobalCleanupEvent(helmfileCommand string) (bool, error)

func (*HelmState) TriggerGlobalPrepareEvent

func (st *HelmState) TriggerGlobalPrepareEvent(helmfileCommand string) (bool, error)

func (*HelmState) TriggerPreapplyEvent added in v0.146.0

func (st *HelmState) TriggerPreapplyEvent(r *ReleaseSpec, helmfileCommand string) (bool, error)

func (*HelmState) UnmarshalYAML added in v0.150.0

func (hs *HelmState) UnmarshalYAML(unmarshal func(any) error) error

func (*HelmState) UpdateDeps

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

UpdateDeps wrapper for updating dependencies on the releases

func (*HelmState) Values

func (st *HelmState) Values() map[string]any

func (*HelmState) WriteReleasesValues

func (st *HelmState) WriteReleasesValues(helm helmexec.Interface, additionalValues []string, opt ...WriteValuesOpt) []error

WriteReleasesValues writes values files for releases

type Inherit added in v0.150.0

type Inherit struct {
	Template string   `yaml:"template,omitempty"`
	Except   []string `yaml:"except,omitempty"`
}

type Inherits added in v0.151.0

type Inherits []Inherit

func (*Inherits) UnmarshalYAML added in v0.151.0

func (r *Inherits) UnmarshalYAML(unmarshal func(any) error) 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 LintOpt

type LintOpt interface{ Apply(*LintOpts) }

type LintOpts

type LintOpts struct {
	Set         []string
	SkipCleanup bool
}

func (*LintOpts) Apply

func (o *LintOpts) Apply(opts *LintOpts)

type MissingFileHandlerConfig added in v0.151.0

type MissingFileHandlerConfig struct {
	// IgnoreMissingGitBranch is set to true in order to let the missing file handler
	// treat missing git branch errors like `pathspec 'develop' did not match any file(s) known to git` safe
	// and ignored when the handler is set to Warn or Info.
	IgnoreMissingGitBranch bool `yaml:"ignoreMissingGitBranch,omitempty"`
}

type PlanOptions

type PlanOptions struct {
	Purpose                string
	Reverse                bool
	IncludeNeeds           bool
	IncludeTransitiveNeeds bool
	SkipNeeds              bool
	SelectedReleases       []ReleaseSpec
}

type PrepareChartKey

type PrepareChartKey struct {
	Namespace, Name, KubeContext string
}

type Release

type Release struct {
	ReleaseSpec

	Filtered bool
}

type ReleaseError

type ReleaseError struct {
	*ReleaseSpec

	Code int
	// contains filtered or unexported fields
}

func NewReleaseError

func NewReleaseError(release *ReleaseSpec, err error, code int) *ReleaseError

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 ReleaseSetSpec

type ReleaseSetSpec struct {
	DefaultHelmBinary      string `yaml:"helmBinary,omitempty"`
	DefaultKustomizeBinary string `yaml:"kustomizeBinary,omitempty"`

	// DefaultValues is the default values to be overrode by environment values and command-line overrides
	DefaultValues []any `yaml:"values,omitempty"`

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

	Bases        []string          `yaml:"bases,omitempty"`
	HelmDefaults HelmSpec          `yaml:"helmDefaults,omitempty"`
	Helmfiles    []SubHelmfileSpec `yaml:"helmfiles,omitempty"`

	// TODO: Remove this function once Helmfile v0.x
	DeprecatedContext  string        `yaml:"context,omitempty"`
	DeprecatedReleases []ReleaseSpec `yaml:"charts,omitempty"`

	OverrideKubeContext string            `yaml:"kubeContext,omitempty"`
	OverrideNamespace   string            `yaml:"namespace,omitempty"`
	OverrideChart       string            `yaml:"chart,omitempty"`
	Repositories        []RepositorySpec  `yaml:"repositories,omitempty"`
	CommonLabels        map[string]string `yaml:"commonLabels,omitempty"`
	Releases            []ReleaseSpec     `yaml:"releases,omitempty"`
	OrginReleases       []ReleaseSpec     `yaml:"-"`
	Selectors           []string          `yaml:"-"`

	// Capabilities.APIVersions
	ApiVersions []string `yaml:"apiVersions,omitempty"`

	// Capabilities.KubeVersion
	KubeVersion string `yaml:"kubeVersion,omitempty"`

	// 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,omitempty"`

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

	Env environment.Environment `yaml:"-"`

	// If set to "Error", return an error when a subhelmfile points to a
	// non-existent path. The default behavior is to print a warning. Note the
	// differing default compared to other MissingFileHandlers.
	MissingFileHandler string `yaml:"missingFileHandler,omitempty"`
	// MissingFileHandlerConfig is composed of various settings for the MissingFileHandler
	MissingFileHandlerConfig MissingFileHandlerConfig `yaml:"missingFileHandlerConfig,omitempty"`

	LockFile string `yaml:"lockFilePath,omitempty"`
}

ReleaseSetSpec is release set spec

type ReleaseSpec

type ReleaseSpec struct {
	// Chart is the name of the chart being installed to create this release
	Chart string `yaml:"chart,omitempty"`

	// ChartPath is the downloaded and modified version of the remote Chart specified by the Chart field.
	// This field is empty when the release is going to use the remote chart as-is, without any modifications(e.g. chartify).
	ChartPath string `yaml:"chartPath,omitempty"`

	// Directory is an alias to Chart which may be of more fit when you want to use a local/remote directory containing
	// K8s manifests or Kustomization as a chart
	Directory string `yaml:"directory,omitempty"`
	// Version is the semver version or version constraint for the chart
	Version string `yaml:"version,omitempty"`
	// Verify enables signature verification on fetched chart.
	// Beware some (or many?) chart repositories and charts don't seem to support it.
	Verify  *bool  `yaml:"verify,omitempty"`
	Keyring string `yaml:"keyring,omitempty"`
	// EnableDNS, when set to true, enable DNS lookups when rendering templates
	EnableDNS *bool `yaml:"enableDNS,omitempty"`
	// Devel, when set to true, use development versions, too. Equivalent to version '>0.0.0-0'
	Devel *bool `yaml:"devel,omitempty"`
	// 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,omitempty"`
	// WaitForJobs, if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout
	WaitForJobs *bool `yaml:"waitForJobs,omitempty"`
	// 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,omitempty"`
	// RecreatePods, when set to true, instruct helmfile to perform pods restart for the resource if applicable
	RecreatePods *bool `yaml:"recreatePods,omitempty"`
	// Force, when set to true, forces resource update through delete/recreate if needed
	Force *bool `yaml:"force,omitempty"`
	// Installed, when set to true, `delete --purge` the release
	Installed *bool `yaml:"installed,omitempty"`
	// Atomic, when set to true, restore previous state in case of a failed install/upgrade attempt
	Atomic *bool `yaml:"atomic,omitempty"`
	// CleanupOnFail, when set to true, the --cleanup-on-fail helm flag is passed to the upgrade command
	CleanupOnFail *bool `yaml:"cleanupOnFail,omitempty"`
	// HistoryMax, limit the maximum number of revisions saved per release. Use 0 for no limit (default 10)
	HistoryMax *int `yaml:"historyMax,omitempty"`
	// Condition, when set, evaluate the mapping specified in this string to a boolean which decides whether or not to process the release
	Condition string `yaml:"condition,omitempty"`
	// CreateNamespace, when set to true (default), --create-namespace is passed to helm3 on install (ignored for helm2)
	CreateNamespace *bool `yaml:"createNamespace,omitempty"`

	// DisableOpenAPIValidation is rarely used to bypass OpenAPI validations only that is used for e.g.
	// work-around against broken CRs
	// See also:
	// - https://github.com/helm/helm/pull/6819
	// - https://github.com/roboll/helmfile/issues/1167
	DisableOpenAPIValidation *bool `yaml:"disableOpenAPIValidation,omitempty"`

	// DisableValidation is rarely used to bypass the whole validation of manifests against the Kubernetes cluster
	// so that `helm diff` can be run containing a chart that installs both CRD and CRs on first install.
	// FYI, such diff without `--disable-validation` fails on first install because the K8s cluster doesn't have CRDs registered yet.
	DisableValidation *bool `yaml:"disableValidation,omitempty"`

	// DisableValidationOnInstall disables the K8s API validation while running helm-diff on the release being newly installed on helmfile-apply.
	// It is useful when any release contains custom resources for CRDs that is not yet installed onto the cluster.
	DisableValidationOnInstall *bool `yaml:"disableValidationOnInstall,omitempty"`

	// 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,omitempty"`
	// Needs is the [KUBECONTEXT/][NS/]NAME representations of releases that this release depends on.
	Needs []string `yaml:"needs,omitempty"`

	// 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,omitempty"`

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

	ValuesTemplate    []any      `yaml:"valuesTemplate,omitempty"`
	SetValuesTemplate []SetValue `yaml:"setTemplate,omitempty"`

	// Capabilities.APIVersions
	ApiVersions []string `yaml:"apiVersions,omitempty"`

	// Capabilities.KubeVersion
	KubeVersion string `yaml:"kubeVersion,omitempty"`

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

	ValuesPathPrefix string `yaml:"valuesPathPrefix,omitempty"`

	KubeContext string `yaml:"kubeContext,omitempty"`

	// InsecureSkipTLSVerify is true if the TLS verification should be skipped when fetching remote chart.
	InsecureSkipTLSVerify bool `yaml:"insecureSkipTLSVerify,omitempty"`

	// These values are used in templating
	VerifyTemplate    *string `yaml:"verifyTemplate,omitempty"`
	WaitTemplate      *string `yaml:"waitTemplate,omitempty"`
	InstalledTemplate *string `yaml:"installedTemplate,omitempty"`

	// These settings requires helm-x integration to work
	Dependencies          []Dependency `yaml:"dependencies,omitempty"`
	JSONPatches           []any        `yaml:"jsonPatches,omitempty"`
	StrategicMergePatches []any        `yaml:"strategicMergePatches,omitempty"`

	// Transformers is the list of Kustomize transformers
	//
	// Each item can be a path to a YAML or go template file, or an embedded transformer declaration as a YAML hash.
	// It's often used to add common labels and annotations to your resources.
	// See https://github.com/kubernetes-sigs/kustomize/blob/master/examples/configureBuiltinPlugin.md#configuring-the-builtin-plugins-instead for more information.
	Transformers []any    `yaml:"transformers,omitempty"`
	Adopt        []string `yaml:"adopt,omitempty"`

	// ForceGoGetter forces the use of go-getter for fetching remote directory as maniefsts/chart/kustomization
	// by parsing the url from `chart` field of the release.
	// This is handy when getting the go-getter url parsing error when it doesn't work as expected.
	// Without this, any error in url parsing result in silently falling-back to normal process of treating `chart:` as the regular
	// helm chart name.
	ForceGoGetter bool `yaml:"forceGoGetter,omitempty"`

	// ForceNamespace is an experimental feature to set metadata.namespace in every K8s resource rendered by the chart,
	// regardless of the template, even when it doesn't have `namespace: {{ .Namespace | quote }}`.
	// This is only needed when you can't FIX your chart to have `namespace: {{ .Namespace }}` AND you're using `helmfile template`.
	// In standard use-cases, `Namespace` should be sufficient.
	// Use this only when you know what you want to do!
	ForceNamespace string `yaml:"forceNamespace,omitempty"`

	// SkipDeps disables running `helm dependency up` and `helm dependency build` on this release's chart.
	// This is relevant only when your release uses a local chart or a directory containing K8s manifests or a Kustomization
	// as a Helm chart.
	SkipDeps *bool `yaml:"skipDeps,omitempty"`

	// Propagate '--post-renderer' to helmv3 template and helm install
	PostRenderer *string `yaml:"postRenderer,omitempty"`

	// Propagate '--post-renderer-args' to helmv3 template and helm install
	PostRendererArgs []string `yaml:"postRendererArgs,omitempty"`

	// Cascade '--cascade' to helmv3 delete, available values: background, foreground, or orphan, default: background
	Cascade *string `yaml:"cascade,omitempty"`

	// SuppressOutputLineRegex is a list of regexes to suppress output lines
	SuppressOutputLineRegex []string `yaml:"suppressOutputLineRegex,omitempty"`

	// Inherit is used to inherit a release template from a release or another release template
	Inherit Inherits `yaml:"inherit,omitempty"`

	// SuppressDiff skip the helm diff output. Useful for charts which produces large not helpful diff.
	SuppressDiff *bool `yaml:"suppressDiff,omitempty"`

	// --wait flag for destroy/delete, if set to true, will wait until all resources are deleted before mark delete command as successful
	DeleteWait *bool `yaml:"deleteWait,omitempty"`
	// Timeout is the time in seconds to wait for helmfile delete command (default 300)
	DeleteTimeout *int `yaml:"deleteTimeout,omitempty"`
	// contains filtered or unexported fields
}

ReleaseSpec defines the structure of a helm release

func (ReleaseSpec) ChartPathOrName

func (r ReleaseSpec) ChartPathOrName() string

ChartPathOrName returns ChartPath if it is non-empty, and returns Chart otherwise. This is useful to redirect helm commands like `helm template`, `helm dependency update`, `helm diff`, and `helm upgrade --install` to our modified version of the chart, in case the user configured Helmfile to do modify the chart before being passed to Helm.

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 {
	IsHelm3() bool
	AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials, skipTLSVerify bool) error
	UpdateRepo() error
	RegistryLogin(name, username, password, caFile, certFile, keyFile string, skipTLSVerify bool) error
}

type RepositorySpec

type RepositorySpec struct {
	Name            string `yaml:"name,omitempty"`
	URL             string `yaml:"url,omitempty"`
	CaFile          string `yaml:"caFile,omitempty"`
	CertFile        string `yaml:"certFile,omitempty"`
	KeyFile         string `yaml:"keyFile,omitempty"`
	Username        string `yaml:"username,omitempty"`
	Password        string `yaml:"password,omitempty"`
	Managed         string `yaml:"managed,omitempty"`
	OCI             bool   `yaml:"oci,omitempty"`
	Verify          bool   `yaml:"verify,omitempty"`
	Keyring         string `yaml:"keyring,omitempty"`
	PassCredentials bool   `yaml:"passCredentials,omitempty"`
	SkipTLSVerify   bool   `yaml:"skipTLSVerify,omitempty"`
}

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,omitempty"`
	Value  string   `yaml:"value,omitempty"`
	File   string   `yaml:"file,omitempty"`
	Values []string `yaml:"values,omitempty"`
}

SetValue are the key values to set on a helm release

type StateCreator

type StateCreator struct {
	Strict bool

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

func NewCreator

func NewCreator(logger *zap.SugaredLogger, fs *filesystem.FileSystem, valsRuntime vals.Evaluator, getHelm func(*HelmState) helmexec.Interface, overrideHelmBinary string, overrideKustomizeBinary string, remote *remote.Remote, enableLiveOutput bool, lockFile string) *StateCreator

func (*StateCreator) LoadEnvValues

func (c *StateCreator) LoadEnvValues(target *HelmState, env string, failOnMissingEnv bool, ctxEnv, overrode *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, failOnMissingEnv, evaluateBases bool, envValues, overrode *environment.Environment) (*HelmState, error)

Parses YAML into HelmState, while loading environment values files relative to the `baseDir` evaluateBases=true means that this is NOT a base helmfile

type StateLoadError

type StateLoadError struct {
	Msg   string
	Cause error
}

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, fs *filesystem.FileSystem) *Storage

func (*Storage) ExpandPaths

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

func (*Storage) JoinBase

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

JoinBase returns an absolute path in the form basePath/relative Helm's setFiles command does not support unescaped filepath separators (\) on Windows. Instead, it requires double backslashes (\\) as filepath separators. See https://github.com/helm/helm/issues/9537

type SubHelmfileSpec

type SubHelmfileSpec struct {
	//path or glob pattern for the sub helmfiles
	Path string `yaml:"path,omitempty"`
	//chosen selectors for the sub helmfiles
	Selectors []string `yaml:"selectors,omitempty"`
	//do the sub helmfiles inherits from parent selectors
	SelectorsInherited bool `yaml:"selectorsInherited,omitempty"`

	Environment SubhelmfileEnvironmentSpec
}

SubHelmfileSpec defines the subhelmfile path and options

func (SubHelmfileSpec) MarshalYAML

func (p SubHelmfileSpec) MarshalYAML() (any, error)

MarshalYAML will ensure we correctly marshal SubHelmfileSpec structure correctly so it can be unmarshalled at some future time

func (*SubHelmfileSpec) UnmarshalYAML

func (hf *SubHelmfileSpec) UnmarshalYAML(unmarshal func(any) error) error

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

type SubhelmfileEnvironmentSpec

type SubhelmfileEnvironmentSpec struct {
	OverrideValues []any `yaml:"values,omitempty"`
}

SubhelmfileEnvironmentSpec is the environment spec for a subhelmfile

type SyncOpt

type SyncOpt interface{ Apply(*SyncOpts) }

type SyncOpts

type SyncOpts struct {
	Set              []string
	SkipCleanup      bool
	SkipCRDs         bool
	Wait             bool
	WaitForJobs      bool
	ReuseValues      bool
	ResetValues      bool
	PostRenderer     string
	PostRendererArgs []string
	SyncArgs         string
}

func (*SyncOpts) Apply

func (o *SyncOpts) Apply(opts *SyncOpts)

type TemplateOpt

type TemplateOpt interface{ Apply(*TemplateOpts) }

type TemplateOpts

type TemplateOpts struct {
	Set               []string
	SkipCleanup       bool
	OutputDirTemplate string
	IncludeCRDs       bool
	SkipTests         bool
	PostRenderer      string
	PostRendererArgs  []string
	KubeVersion       string
}

func (*TemplateOpts) Apply

func (o *TemplateOpts) Apply(opts *TemplateOpts)

type TemplateSpec

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

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

type TestOption

type TestOption func(*TestOpts)

type TestOpts

type TestOpts struct {
	Logs bool
}

type UndefinedEnvError

type UndefinedEnvError struct {
	Env string
}

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

type WriteValuesOpt

type WriteValuesOpt interface{ Apply(*WriteValuesOpts) }

type WriteValuesOpts

type WriteValuesOpts struct {
	Set                []string
	OutputFileTemplate string
	SkipCleanup        bool
}

func (*WriteValuesOpts) Apply

func (o *WriteValuesOpts) Apply(opts *WriteValuesOpts)

Jump to

Keyboard shortcuts

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