Documentation ¶
Overview ¶
Package action contains the logic for each action that Helm can perform.
This is a library for calling top-level Helm actions like 'install', 'upgrade', or 'list'. Actions approximately match the command line invocations that the Helm client uses.
Index ¶
- Constants
- Variables
- func CheckDependencies(ch *chart.Chart, reqs []*chart.Dependency) error
- func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.VersionSet, error)
- func HasWarningsOrErrors(result *LintResult) bool
- func TemplateName(nameTemplate string) (string, error)
- type ChartPathOptions
- type Configuration
- type DebugLog
- type Dependency
- type Get
- type GetMetadata
- type GetValues
- type History
- type Install
- func (i *Install) GetRegistryClient() *registry.Client
- func (i *Install) NameAndChart(args []string) (string, string, error)
- func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.Release, error)
- func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals map[string]interface{}) (*release.Release, error)
- func (i *Install) SetRegistryClient(registryClient *registry.Client)
- type Lint
- type LintResult
- type List
- type ListStates
- type Metadata
- type Package
- type Pull
- type PullOpt
- type Push
- type PushOpt
- type RESTClientGetter
- type RegistryLogin
- type RegistryLoginOpt
- type RegistryLogout
- type ReleaseTesting
- type Rollback
- type Show
- type ShowOutputFormat
- type Sorter
- type Status
- type Uninstall
- type Upgrade
- type Verify
Constants ¶
const ( ExcludeNameFilter = "!name" IncludeNameFilter = "name" )
const ListAll = ListDeployed | ListUninstalled | ListUninstalling | ListPendingInstall | ListPendingRollback | ListPendingUpgrade | ListSuperseded | ListFailed
ListAll is a convenience for enabling all list filters
Variables ¶
var Timestamper = time.Now
Timestamper is a function capable of producing a timestamp.Timestamper.
By default, this is a time.Time function from the Helm time package. This can be overridden for testing though, so that timestamps are predictable.
var ValidName = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`)
ValidName is a regular expression for resource names.
DEPRECATED: This will be removed in Helm 4, and is no longer used here. See pkg/lint/rules.validateMetadataNameFunc for the replacement.
According to the Kubernetes help text, the regular expression it uses is:
[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*
This follows the above regular expression (but requires a full string match, not partial).
The Kubernetes documentation is here, though it is not entirely correct: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
Functions ¶
func CheckDependencies ¶
func CheckDependencies(ch *chart.Chart, reqs []*chart.Dependency) error
CheckDependencies checks the dependencies for a chart.
func GetVersionSet ¶
func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.VersionSet, error)
GetVersionSet retrieves a set of available k8s API versions
func HasWarningsOrErrors ¶ added in v3.9.0
func HasWarningsOrErrors(result *LintResult) bool
HasWarningsOrErrors checks is LintResult has any warnings or errors
func TemplateName ¶
TemplateName renders a name template, returning the name or an error.
Types ¶
type ChartPathOptions ¶
type ChartPathOptions struct { CaFile string // --ca-file CertFile string // --cert-file KeyFile string // --key-file InsecureSkipTLSverify bool // --insecure-skip-verify PlainHTTP bool // --plain-http Keyring string // --keyring Password string // --password PassCredentialsAll bool // --pass-credentials RepoURL string // --repo Username string // --username Verify bool // --verify Version string // --version // contains filtered or unexported fields }
ChartPathOptions captures common options used for controlling chart paths
func (*ChartPathOptions) LocateChart ¶
func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) (string, error)
LocateChart looks for a chart directory in known places, and returns either the full path or an error.
This does not ensure that the chart is well-formed; only that the requested filename exists.
Order of resolution: - relative to current working directory - if path is absolute or begins with '.', error out here - URL
If 'verify' was set on ChartPathOptions, this will attempt to also verify the chart.
type Configuration ¶
type Configuration struct { // RESTClientGetter is an interface that loads Kubernetes clients. RESTClientGetter RESTClientGetter // Releases stores records of releases. Releases *storage.Storage // KubeClient is a Kubernetes API client. KubeClient kube.Interface // RegistryClient is a client for working with registries RegistryClient *registry.Client // Capabilities describes the capabilities of the Kubernetes cluster. Capabilities *chartutil.Capabilities Log func(string, ...interface{}) }
Configuration injects the dependencies that all actions share.
func (*Configuration) Init ¶
func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error
Init initializes the action configuration
func (*Configuration) KubernetesClientSet ¶
func (cfg *Configuration) KubernetesClientSet() (kubernetes.Interface, error)
KubernetesClientSet creates a new kubernetes ClientSet based on the configuration
func (*Configuration) Now ¶
func (cfg *Configuration) Now() time.Time
Now generates a timestamp
If the configuration has a Timestamper on it, that will be used. Otherwise, this will use time.Now().
type DebugLog ¶
type DebugLog func(format string, v ...interface{})
DebugLog sets the logger that writes debug strings
type Dependency ¶
Dependency is the action for building a given chart's dependency tree.
It provides the implementation of 'helm dependency' and its respective subcommands.
func NewDependency ¶
func NewDependency() *Dependency
NewDependency creates a new Dependency object with the given configuration.
type Get ¶
type Get struct { // Initializing Version to 0 will get the latest revision of the release. Version int // contains filtered or unexported fields }
Get is the action for checking a given release's information.
It provides the implementation of 'helm get' and its respective subcommands (except `helm get values`).
func NewGet ¶
func NewGet(cfg *Configuration) *Get
NewGet creates a new Get object with the given configuration.
type GetMetadata ¶ added in v3.13.0
type GetMetadata struct { Version int // contains filtered or unexported fields }
GetMetadata is the action for checking a given release's metadata.
It provides the implementation of 'helm get metadata'.
func NewGetMetadata ¶ added in v3.13.0
func NewGetMetadata(cfg *Configuration) *GetMetadata
NewGetMetadata creates a new GetMetadata object with the given configuration.
type GetValues ¶
GetValues is the action for checking a given release's values.
It provides the implementation of 'helm get values'.
func NewGetValues ¶
func NewGetValues(cfg *Configuration) *GetValues
NewGetValues creates a new GetValues object with the given configuration.
type History ¶
History is the action for checking the release's ledger.
It provides the implementation of 'helm history'. It returns all the revisions for a specific release. To list up to one revision of every release in one specific, or in all, namespaces, see the List action.
func NewHistory ¶
func NewHistory(cfg *Configuration) *History
NewHistory creates a new History object with the given configuration.
type Install ¶
type Install struct { ChartPathOptions ClientOnly bool Force bool CreateNamespace bool DryRun bool DryRunOption string // HideSecret can be set to true when DryRun is enabled in order to hide // Kubernetes Secrets in the output. It cannot be used outside of DryRun. HideSecret bool DisableHooks bool Replace bool Wait bool WaitForJobs bool Devel bool DependencyUpdate bool Timeout time.Duration Namespace string ReleaseName string GenerateName bool NameTemplate string Description string OutputDir string Atomic bool SkipCRDs bool SubNotes bool HideNotes bool SkipSchemaValidation bool DisableOpenAPIValidation bool IncludeCRDs bool Labels map[string]string // KubeVersion allows specifying a custom kubernetes version to use and // APIVersions allows a manual set of supported API Versions to be passed // (for things like templating). These are ignored if ClientOnly is false KubeVersion *chartutil.KubeVersion APIVersions chartutil.VersionSet // Used by helm template to render charts with .Release.IsUpgrade. Ignored if Dry-Run is false IsUpgrade bool // Enable DNS lookups when rendering templates EnableDNS bool // Used by helm template to add the release as part of OutputDir path // OutputDir/<ReleaseName> UseReleaseName bool // TakeOwnership will ignore the check for helm annotations and take ownership of the resources. TakeOwnership bool PostRenderer postrender.PostRenderer // Lock to control raceconditions when the process receives a SIGTERM Lock sync.Mutex // contains filtered or unexported fields }
Install performs an installation operation.
func NewInstall ¶
func NewInstall(cfg *Configuration) *Install
NewInstall creates a new Install object with the given configuration.
func (*Install) GetRegistryClient ¶ added in v3.12.2
GetRegistryClient get the registry client.
func (*Install) NameAndChart ¶
NameAndChart returns the name and chart that should be used.
This will read the flags and handle name generation if necessary.
func (*Install) RunWithContext ¶ added in v3.7.0
func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals map[string]interface{}) (*release.Release, error)
Run executes the installation with Context
When the task is cancelled through ctx, the function returns and the install proceeds in the background.
func (*Install) SetRegistryClient ¶ added in v3.12.0
SetRegistryClient sets the registry client for the install action
type Lint ¶
type Lint struct { Strict bool Namespace string WithSubcharts bool Quiet bool SkipSchemaValidation bool KubeVersion *chartutil.KubeVersion }
Lint is the action for checking that the semantics of a chart are well-formed.
It provides the implementation of 'helm lint'.
type LintResult ¶
LintResult is the result of Lint
type List ¶
type List struct { // All ignores the limit/offset All bool // AllNamespaces searches across namespaces AllNamespaces bool // Sort indicates the sort to use // // see pkg/releaseutil for several useful sorters Sort Sorter // Overrides the default lexicographic sorting ByDate bool SortReverse bool // StateMask accepts a bitmask of states for items to show. // The default is ListDeployed StateMask ListStates // Limit is the number of items to return per Run() Limit int // Offset is the starting index for the Run() call Offset int // Filter is a filter that is applied to the results Filter string Short bool NoHeaders bool TimeFormat string Uninstalled bool Superseded bool Uninstalling bool Deployed bool Failed bool Pending bool Selector string // contains filtered or unexported fields }
List is the action for listing releases.
It provides, for example, the implementation of 'helm list'. It returns no more than one revision of every release in one specific, or in all, namespaces. To list all the revisions of a specific release, see the History action.
func (*List) SetStateMask ¶
func (l *List) SetStateMask()
SetStateMask calculates the state mask based on parameters.
type ListStates ¶
type ListStates uint
ListStates represents zero or more status codes that a list item may have set
Because this is used as a bitmask filter, more than one bit can be flipped in the ListStates.
const ( // ListDeployed filters on status "deployed" ListDeployed ListStates = 1 << iota // ListUninstalled filters on status "uninstalled" ListUninstalled // ListUninstalling filters on status "uninstalling" (uninstall in progress) ListUninstalling // ListPendingInstall filters on status "pending" (deployment in progress) ListPendingInstall // ListPendingUpgrade filters on status "pending_upgrade" (upgrade in progress) ListPendingUpgrade // ListPendingRollback filters on status "pending_rollback" (rollback in progress) ListPendingRollback // ListSuperseded filters on status "superseded" (historical release version that is no longer deployed) ListSuperseded // ListFailed filters on status "failed" (release version not deployed because of error) ListFailed // ListUnknown filters on an unknown status ListUnknown )
func (ListStates) FromName ¶
func (s ListStates) FromName(str string) ListStates
FromName takes a state name and returns a ListStates representation.
Currently, there are only names for individual flipped bits, so the returned ListStates will only match one of the constants. However, it is possible that this behavior could change in the future.
type Metadata ¶ added in v3.13.0
type Metadata struct { Name string `json:"name" yaml:"name"` Chart string `json:"chart" yaml:"chart"` Version string `json:"version" yaml:"version"` AppVersion string `json:"appVersion" yaml:"appVersion"` Namespace string `json:"namespace" yaml:"namespace"` Revision int `json:"revision" yaml:"revision"` Status string `json:"status" yaml:"status"` DeployedAt string `json:"deployedAt" yaml:"deployedAt"` }
type Package ¶
type Package struct { Sign bool Key string Keyring string PassphraseFile string Version string AppVersion string Destination string DependencyUpdate bool RepositoryConfig string RepositoryCache string }
Package is the action for packaging a chart.
It provides the implementation of 'helm package'.
func NewPackage ¶
func NewPackage() *Package
NewPackage creates a new Package object with the given configuration.
type Pull ¶
type Pull struct { ChartPathOptions Settings *cli.EnvSettings // TODO: refactor this out of pkg/action Devel bool Untar bool VerifyLater bool UntarDir string DestDir string // contains filtered or unexported fields }
Pull is the action for checking a given release's information.
It provides the implementation of 'helm pull'.
func NewPullWithOpts ¶ added in v3.5.0
NewPullWithOpts creates a new pull, with configuration options.
func (*Pull) SetRegistryClient ¶ added in v3.12.0
SetRegistryClient sets the registry client on the pull configuration object.
type PullOpt ¶ added in v3.5.0
type PullOpt func(*Pull)
func WithConfig ¶ added in v3.5.0
func WithConfig(cfg *Configuration) PullOpt
type Push ¶ added in v3.8.0
type Push struct { Settings *cli.EnvSettings // contains filtered or unexported fields }
Push is the action for uploading a chart.
It provides the implementation of 'helm push'.
func NewPushWithOpts ¶ added in v3.8.0
NewPushWithOpts creates a new push, with configuration options.
type PushOpt ¶ added in v3.8.0
type PushOpt func(*Push)
PushOpt is a type of function that sets options for a push action.
func WithInsecureSkipTLSVerify ¶ added in v3.12.0
WithInsecureSkipTLSVerify determines if a TLS Certificate will be checked
func WithPlainHTTP ¶ added in v3.13.0
WithPlainHTTP configures the use of plain HTTP connections.
func WithPushConfig ¶ added in v3.8.0
func WithPushConfig(cfg *Configuration) PushOpt
WithPushConfig sets the cfg field on the push configuration object.
func WithPushOptWriter ¶ added in v3.12.0
WithOptWriter sets the registryOut field on the push configuration object.
func WithTLSClientConfig ¶ added in v3.12.0
WithTLSClientConfig sets the certFile, keyFile, and caFile fields on the push configuration object.
type RESTClientGetter ¶
type RESTClientGetter interface { ToRESTConfig() (*rest.Config, error) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) ToRESTMapper() (meta.RESTMapper, error) }
RESTClientGetter gets the rest client
type RegistryLogin ¶
type RegistryLogin struct {
// contains filtered or unexported fields
}
RegistryLogin performs a registry login operation.
func NewRegistryLogin ¶
func NewRegistryLogin(cfg *Configuration) *RegistryLogin
NewRegistryLogin creates a new RegistryLogin object with the given configuration.
func (*RegistryLogin) Run ¶
func (a *RegistryLogin) Run(_ io.Writer, hostname string, username string, password string, opts ...RegistryLoginOpt) error
Run executes the registry login operation
type RegistryLoginOpt ¶ added in v3.12.0
type RegistryLoginOpt func(*RegistryLogin) error
func WithCAFile ¶ added in v3.12.0
func WithCAFile(caFile string) RegistryLoginOpt
WithCAFile specifies the path to the CA file to use for TLS.
func WithCertFile ¶ added in v3.12.0
func WithCertFile(certFile string) RegistryLoginOpt
WithCertFile specifies the path to the certificate file to use for TLS.
func WithInsecure ¶ added in v3.12.0
func WithInsecure(insecure bool) RegistryLoginOpt
WithKeyFile specifies whether to very certificates when communicating.
func WithKeyFile ¶ added in v3.12.0
func WithKeyFile(keyFile string) RegistryLoginOpt
WithKeyFile specifies the path to the key file to use for TLS.
type RegistryLogout ¶
type RegistryLogout struct {
// contains filtered or unexported fields
}
RegistryLogout performs a registry login operation.
func NewRegistryLogout ¶
func NewRegistryLogout(cfg *Configuration) *RegistryLogout
NewRegistryLogout creates a new RegistryLogout object with the given configuration.
type ReleaseTesting ¶
type ReleaseTesting struct { Timeout time.Duration // Used for fetching logs from test pods Namespace string Filters map[string][]string HideNotes bool // contains filtered or unexported fields }
ReleaseTesting is the action for testing a release.
It provides the implementation of 'helm test'.
func NewReleaseTesting ¶
func NewReleaseTesting(cfg *Configuration) *ReleaseTesting
NewReleaseTesting creates a new ReleaseTesting object with the given configuration.
func (*ReleaseTesting) GetPodLogs ¶
GetPodLogs will write the logs for all test pods in the given release into the given writer. These can be immediately output to the user or captured for other uses
type Rollback ¶
type Rollback struct { Version int Timeout time.Duration Wait bool WaitForJobs bool DisableHooks bool DryRun bool Recreate bool // will (if true) recreate pods after a rollback. Force bool // will (if true) force resource upgrade through uninstall/recreate if needed CleanupOnFail bool MaxHistory int // MaxHistory limits the maximum number of revisions saved per release // contains filtered or unexported fields }
Rollback is the action for rolling back to a given release.
It provides the implementation of 'helm rollback'.
func NewRollback ¶
func NewRollback(cfg *Configuration) *Rollback
NewRollback creates a new Rollback object with the given configuration.
type Show ¶
type Show struct { ChartPathOptions Devel bool OutputFormat ShowOutputFormat JSONPathTemplate string // contains filtered or unexported fields }
Show is the action for checking a given release's information.
It provides the implementation of 'helm show' and its respective subcommands.
func NewShow ¶
func NewShow(output ShowOutputFormat) *Show
NewShow creates a new Show object with the given configuration. Deprecated: Use NewShowWithConfig TODO Helm 4: Fold NewShowWithConfig back into NewShow
func NewShowWithConfig ¶ added in v3.8.0
func NewShowWithConfig(output ShowOutputFormat, cfg *Configuration) *Show
NewShowWithConfig creates a new Show object with the given configuration.
func (*Show) SetRegistryClient ¶ added in v3.12.0
SetRegistryClient sets the registry client to use when pulling a chart from a registry.
type ShowOutputFormat ¶
type ShowOutputFormat string
ShowOutputFormat is the format of the output of `helm show`
const ( // ShowAll is the format which shows all the information of a chart ShowAll ShowOutputFormat = "all" // ShowChart is the format which only shows the chart's definition ShowChart ShowOutputFormat = "chart" // ShowValues is the format which only shows the chart's values ShowValues ShowOutputFormat = "values" // ShowReadme is the format which only shows the chart's README ShowReadme ShowOutputFormat = "readme" // ShowCRDs is the format which only shows the chart's CRDs ShowCRDs ShowOutputFormat = "crds" )
func (ShowOutputFormat) String ¶
func (o ShowOutputFormat) String() string
type Status ¶
type Status struct { Version int // If true, display description to output format, // only affect print type table. // TODO Helm 4: Remove this flag and output the description by default. ShowDescription bool // ShowResources sets if the resources should be retrieved with the status. // TODO Helm 4: Remove this flag and output the resources by default. ShowResources bool // ShowResourcesTable is used with ShowResources. When true this will cause // the resulting objects to be retrieved as a kind=table. ShowResourcesTable bool // contains filtered or unexported fields }
Status is the action for checking the deployment status of releases.
It provides the implementation of 'helm status'.
func NewStatus ¶
func NewStatus(cfg *Configuration) *Status
NewStatus creates a new Status object with the given configuration.
type Uninstall ¶
type Uninstall struct { DisableHooks bool DryRun bool IgnoreNotFound bool KeepHistory bool Wait bool DeletionPropagation string Timeout time.Duration Description string // contains filtered or unexported fields }
Uninstall is the action for uninstalling releases.
It provides the implementation of 'helm uninstall'.
func NewUninstall ¶
func NewUninstall(cfg *Configuration) *Uninstall
NewUninstall creates a new Uninstall object with the given configuration.
type Upgrade ¶
type Upgrade struct { ChartPathOptions // Install is a purely informative flag that indicates whether this upgrade was done in "install" mode. // // Applications may use this to determine whether this Upgrade operation was done as part of a // pure upgrade (Upgrade.Install == false) or as part of an install-or-upgrade operation // (Upgrade.Install == true). // // Setting this to `true` will NOT cause `Upgrade` to perform an install if the release does not exist. // That process must be handled by creating an Install action directly. See cmd/upgrade.go for an // example of how this flag is used. Install bool // Devel indicates that the operation is done in devel mode. Devel bool // Namespace is the namespace in which this operation should be performed. Namespace string // SkipCRDs skips installing CRDs when install flag is enabled during upgrade SkipCRDs bool // Timeout is the timeout for this operation Timeout time.Duration // Wait determines whether the wait operation should be performed after the upgrade is requested. Wait bool // WaitForJobs determines whether the wait operation for the Jobs should be performed after the upgrade is requested. WaitForJobs bool // DisableHooks disables hook processing if set to true. DisableHooks bool // DryRun controls whether the operation is prepared, but not executed. DryRun bool // DryRunOption controls whether the operation is prepared, but not executed with options on whether or not to interact with the remote cluster. DryRunOption string // HideSecret can be set to true when DryRun is enabled in order to hide // Kubernetes Secrets in the output. It cannot be used outside of DryRun. HideSecret bool // Force will, if set to `true`, ignore certain warnings and perform the upgrade anyway. // // This should be used with caution. Force bool // ResetValues will reset the values to the chart's built-ins rather than merging with existing. ResetValues bool // ReuseValues will re-use the user's last supplied values. ReuseValues bool // ResetThenReuseValues will reset the values to the chart's built-ins then merge with user's last supplied values. ResetThenReuseValues bool // Recreate will (if true) recreate pods after a rollback. Recreate bool // MaxHistory limits the maximum number of revisions saved per release MaxHistory int // Atomic, if true, will roll back on failure. Atomic bool // CleanupOnFail will, if true, cause the upgrade to delete newly-created resources on a failed update. CleanupOnFail bool // SubNotes determines whether sub-notes are rendered in the chart. SubNotes bool // HideNotes determines whether notes are output during upgrade HideNotes bool // SkipSchemaValidation determines if JSON schema validation is disabled. SkipSchemaValidation bool // Description is the description of this operation Description string Labels map[string]string // PostRender is an optional post-renderer // // If this is non-nil, then after templates are rendered, they will be sent to the // post renderer before sending to the Kubernetes API server. PostRenderer postrender.PostRenderer // DisableOpenAPIValidation controls whether OpenAPI validation is enforced. DisableOpenAPIValidation bool // Get missing dependencies DependencyUpdate bool // Lock to control raceconditions when the process receives a SIGTERM Lock sync.Mutex // Enable DNS lookups when rendering templates EnableDNS bool // TakeOwnership will skip the check for helm annotations and adopt all existing resources. TakeOwnership bool // contains filtered or unexported fields }
Upgrade is the action for upgrading releases.
It provides the implementation of 'helm upgrade'.
func NewUpgrade ¶
func NewUpgrade(cfg *Configuration) *Upgrade
NewUpgrade creates a new Upgrade object with the given configuration.
func (*Upgrade) Run ¶
func (u *Upgrade) Run(name string, chart *chart.Chart, vals map[string]interface{}) (*release.Release, error)
Run executes the upgrade on the given release.
func (*Upgrade) RunWithContext ¶ added in v3.7.0
func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart.Chart, vals map[string]interface{}) (*release.Release, error)
RunWithContext executes the upgrade on the given release with context.
func (*Upgrade) SetRegistryClient ¶ added in v3.12.0
SetRegistryClient sets the registry client to use when fetching charts.
Source Files ¶
- action.go
- dependency.go
- doc.go
- get.go
- get_metadata.go
- get_values.go
- history.go
- hooks.go
- install.go
- lazyclient.go
- lint.go
- list.go
- package.go
- pull.go
- push.go
- registry_login.go
- registry_logout.go
- release_testing.go
- resource_policy.go
- rollback.go
- show.go
- status.go
- uninstall.go
- upgrade.go
- validate.go
- verify.go