action

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: Apache-2.0 Imports: 51 Imported by: 0

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

This section is empty.

Variables

View Source
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.

View Source
var ValidName = regexp.MustCompile("^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])+$")

ValidName is a regular expression for names.

According to the Kubernetes help text, the regular expression it uses is:

(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?

We modified that. First, we added start and end delimiters. Second, we changed the final ? to + to require that the pattern match at least once. This modification prevents an empty string from matching.

Functions

func CheckDependencies

func CheckDependencies(ch *chart.Chart, reqs []*chart.Dependency) error

CheckDependencies checks the dependencies for a chart.

func GetVersionSet

GetVersionSet retrieves a set of available k8s API versions

func TemplateName

func TemplateName(nameTemplate string) (string, error)

TemplateName renders a name template, returning the name or an error.

Types

type Apply

type Apply struct {
	ApplyOptions *apply.ApplyOptions

	ChartPathOptions

	ClientOnly               bool
	CreateNamespace          bool
	DryRun                   bool
	DisableHooks             bool
	Replace                  bool
	Wait                     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
	DisableOpenAPIValidation bool
	IncludeCRDs              bool
	// APIVersions allows a manual set of supported API Versions to be passed
	// (for things like templating). These are ignored if ClientOnly is false
	APIVersions chartutil.VersionSet
	// Used by helm template to render charts with .Release.IsUpgrade. Ignored if Dry-Run is false
	IsUpgrade bool
	// Used by helm template to add the release as part of OutputDir path
	// OutputDir/<ReleaseName>
	UseReleaseName bool
	PostRenderer   postrender.PostRenderer

	// If true, then don't coalesce values, instead use inout values for rendering directly
	OverwriteValues bool
	// contains filtered or unexported fields
}

Apply performs an applyation operation.

func NewApply

func NewApply(cfg *Configuration) *Apply

NewApply creates a new Apply object with the given configuration.

func (*Apply) NameAndChart

func (i *Apply) NameAndChart(args []string) (string, string, error)

NameAndChart returns the name and chart that should be used.

This will read the flags and handle name generation if necessary.

func (*Apply) Run

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

Run executes the applyation

If DryRun is set to true, this will prepare the release, but not apply it

func (*Apply) Update

func (i *Apply) Update(original, target kube.ResourceList, force bool) (*kube.Result, error)

type ChartPathOptions

type ChartPathOptions struct {
	CaFile   string // --ca-file
	CertFile string // --cert-file
	KeyFile  string // --key-file
	Keyring  string // --keyring
	Password string // --password
	RepoURL  string // --repo
	Username string // --username
	Verify   bool   // --verify
	Version  string // --version
}

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

	// 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) GetCapabilities

func (c *Configuration) GetCapabilities() (*chartutil.Capabilities, error)

capabilities builds a Capabilities from discovery information.

func (*Configuration) Init

func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace, helmDriver string, log DebugLog) error

Init initializes the action configuration

func (*Configuration) KubernetesClientSet

func (c *Configuration) KubernetesClientSet() (kubernetes.Interface, error)

KubernetesClientSet creates a new kubernetes ClientSet based on the configuration

func (*Configuration) Now

func (c *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 RESTClientGetter

type RESTClientGetter interface {
	ToRESTConfig() (*rest.Config, error)
	ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
	ToRESTMapper() (meta.RESTMapper, error)
}

RESTClientGetter gets the rest client

type Uninstall

type Uninstall struct {
	DisableHooks bool
	DryRun       bool
	KeepHistory  bool
	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.

func (*Uninstall) Run

Run uninstalls the given release.

Jump to

Keyboard shortcuts

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