action

package
Version: v3.0.0-beta.3+incompat... Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 45 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

ListAll is a convenience for enabling all list filters

Variables

View Source
var ErrInvalidFormatType = fmt.Errorf("invalid format type")

ErrInvalidFormatType is returned when an unsupported format type is used

View Source
var Timestamper = time.Now

Timestamper is a function capable of producing a timestamp.Timestamper.

By default, this is a time.Time function. 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 FormatList

func FormatList(rels []*release.Release) string

func GetVersionSet

GetVersionSet retrieves a set of available k8s API versions

func PrintRelease

func PrintRelease(out io.Writer, rel *release.Release)

PrintRelease prints info about a release

func TemplateName

func TemplateName(nameTemplate string) (string, error)

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

Types

type ChartExport

type ChartExport struct {
	Destination string
	// contains filtered or unexported fields
}

ChartExport performs a chart export operation.

func NewChartExport

func NewChartExport(cfg *Configuration) *ChartExport

NewChartExport creates a new ChartExport object with the given configuration.

func (*ChartExport) Run

func (a *ChartExport) Run(out io.Writer, ref string) error

Run executes the chart export operation

type ChartList

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

ChartList performs a chart list operation.

func NewChartList

func NewChartList(cfg *Configuration) *ChartList

NewChartList creates a new ChartList object with the given configuration.

func (*ChartList) Run

func (a *ChartList) Run(out io.Writer) error

Run executes the chart list operation

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 ChartPull

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

ChartPull performs a chart pull operation.

func NewChartPull

func NewChartPull(cfg *Configuration) *ChartPull

NewChartPull creates a new ChartPull object with the given configuration.

func (*ChartPull) Run

func (a *ChartPull) Run(out io.Writer, ref string) error

Run executes the chart pull operation

type ChartPush

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

ChartPush performs a chart push operation.

func NewChartPush

func NewChartPush(cfg *Configuration) *ChartPush

NewChartPush creates a new ChartPush object with the given configuration.

func (*ChartPush) Run

func (a *ChartPush) Run(out io.Writer, ref string) error

Run executes the chart push operation

type ChartRemove

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

ChartRemove performs a chart remove operation.

func NewChartRemove

func NewChartRemove(cfg *Configuration) *ChartRemove

NewChartRemove creates a new ChartRemove object with the given configuration.

func (*ChartRemove) Run

func (a *ChartRemove) Run(out io.Writer, ref string) error

Run executes the chart remove operation

type ChartSave

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

ChartSave performs a chart save operation.

func NewChartSave

func NewChartSave(cfg *Configuration) *ChartSave

NewChartSave creates a new ChartSave object with the given configuration.

func (*ChartSave) Run

func (a *ChartSave) Run(out io.Writer, ch *chart.Chart, ref string) error

Run executes the chart save operation

type Configuration

type Configuration struct {
	// RESTClientGetter is an interface that loads Kuberbetes 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) KubernetesClientSet

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

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 Dependency

type Dependency struct {
	Verify      bool
	Keyring     string
	SkipRefresh bool
}

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.

func (*Dependency) List

func (d *Dependency) List(chartpath string, out io.Writer) error

List executes 'helm dependency list'.

type Get

type Get struct {
	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.

func (*Get) Run

func (g *Get) Run(name string) (*release.Release, error)

Run executes 'helm get' against the given release.

type GetValues

type GetValues struct {
	Version   int
	AllValues bool
	// contains filtered or unexported fields
}

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.

func (*GetValues) Run

func (g *GetValues) Run(name string) (string, error)

Run executes 'helm get values' against the given release.

type History

type History struct {
	Max          int
	OutputFormat string
	// contains filtered or unexported fields
}

History is the action for checking the release's ledger.

It provides the implementation of 'helm history'.

func NewHistory

func NewHistory(cfg *Configuration) *History

NewHistory creates a new History object with the given configuration.

func (*History) Run

func (h *History) Run(name string) ([]*release.Release, error)

Run executes 'helm history' against the given release.

type Install

type Install struct {
	ChartPathOptions

	ClientOnly       bool
	DryRun           bool
	DisableHooks     bool
	Replace          bool
	Wait             bool
	Devel            bool
	DependencyUpdate bool
	Timeout          time.Duration
	Namespace        string
	ReleaseName      string
	GenerateName     bool
	NameTemplate     string
	OutputDir        string
	Atomic           bool
	SkipCRDs         bool
	// 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) NameAndChart

func (i *Install) 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 (*Install) Run

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

Run executes the installation

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

type Lint

type Lint struct {
	Strict    bool
	Namespace string
}

Lint is the action for checking that the semantics of a chart are well-formed.

It provides the implementation of 'helm lint'.

func NewLint

func NewLint() *Lint

NewLint creates a new Lint object with the given configuration.

func (*Lint) Run

func (l *Lint) Run(paths []string, vals map[string]interface{}) *LintResult

Run executes 'helm Lint' against the given chart.

type LintResult

type LintResult struct {
	TotalChartsLinted int
	Messages          []support.Message
	Errors            []error
}

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
	Uninstalled  bool
	Superseded   bool
	Uninstalling bool
	Deployed     bool
	Failed       bool
	Pending      bool
	// contains filtered or unexported fields
}

List is the action for listing releases.

It provides, for example, the implementation of 'helm list'.

func NewList

func NewList(cfg *Configuration) *List

NewList constructs a new *List

func (*List) Run

func (l *List) Run() ([]*release.Release, error)

Run executes the list command, returning a set of matches.

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 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 progres)
	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 OutputFormat

type OutputFormat string

OutputFormat is a type for capturing supported output formats

const (
	Table OutputFormat = "table"
	JSON  OutputFormat = "json"
	YAML  OutputFormat = "yaml"
)

func ParseOutputFormat

func ParseOutputFormat(s string) (out OutputFormat, err error)

ParseOutputFormat takes a raw string and returns the matching OutputFormat. If the format does not exists, ErrInvalidFormatType is returned

func (OutputFormat) Marshal

func (o OutputFormat) Marshal(data interface{}) (byt []byte, err error)

Marshal uses the specified output format to marshal out the given data. It does not support tabular output. For tabular output, use MarshalTable

func (OutputFormat) MarshalTable

func (o OutputFormat) MarshalTable(f TableFunc) ([]byte, error)

MarshalTable returns a formatted table using the given headers. Rows can be added to the table using the given TableFunc

func (OutputFormat) String

func (o OutputFormat) String() string

String returns the string reprsentation of the OutputFormat

type Package

type Package struct {
	Sign             bool
	Key              string
	Keyring          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.

func (*Package) Clearsign

func (p *Package) Clearsign(filename string) error

func (*Package) Run

func (p *Package) Run(path string, vals map[string]interface{}) (string, error)

Run executes 'helm package' against the given chart and returns the path to the packaged chart.

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
}

Pull is the action for checking a given release's information.

It provides the implementation of 'helm pull'.

func NewPull

func NewPull() *Pull

NewPull creates a new Pull object with the given configuration.

func (*Pull) Run

func (p *Pull) Run(chartRef string) (string, error)

Run executes 'helm pull' against the given release.

type RESTClientGetter

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

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(out io.Writer, hostname string, username string, password string, insecure bool) error

Run executes the registry login operation

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.

func (*RegistryLogout) Run

func (a *RegistryLogout) Run(out io.Writer, hostname string) error

Run executes the registry logout operation

type ReleaseTesting

type ReleaseTesting struct {
	Timeout time.Duration
	Cleanup 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) Run

func (r *ReleaseTesting) Run(name string) error

Run executes 'helm test' against the given release.

type Rollback

type Rollback struct {
	Version      int
	Timeout      time.Duration
	Wait         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
	// 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.

func (*Rollback) Run

func (r *Rollback) Run(name string) error

Run executes 'helm rollback' against the given release.

type Show

type Show struct {
	OutputFormat ShowOutputFormat
	ChartPathOptions
}

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.

func (*Show) Run

func (s *Show) Run(chartpath string) (string, error)

Run executes 'helm show' against the given release.

type ShowOutputFormat

type ShowOutputFormat string
const (
	ShowAll    ShowOutputFormat = "all"
	ShowChart  ShowOutputFormat = "chart"
	ShowValues ShowOutputFormat = "values"
	ShowReadme ShowOutputFormat = "readme"
)

func (ShowOutputFormat) String

func (o ShowOutputFormat) String() string

type Sorter

type Sorter uint

Sorter is a top-level sort

const (
	// ByNameDesc sorts by descending lexicographic order
	ByNameDesc Sorter = iota + 1
	// ByDateAsc sorts by ascending dates (oldest updated release first)
	ByDateAsc
	// ByDateDesc sorts by descending dates (latest updated release first)
	ByDateDesc
)

type Status

type Status struct {
	Version      int
	OutputFormat string
	// 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.

func (*Status) Run

func (s *Status) Run(name string) (*release.Release, error)

Run executes 'helm status' against the given release.

type TableFunc

type TableFunc func(tbl *uitable.Table)

TableFunc is a function that can be used to add rows to a table

type Uninstall

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

type Upgrade

type Upgrade struct {
	ChartPathOptions

	Install      bool
	Devel        bool
	Namespace    string
	Timeout      time.Duration
	Wait         bool
	DisableHooks bool
	DryRun       bool
	Force        bool
	ResetValues  bool
	ReuseValues  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     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.

type Verify

type Verify struct {
	Keyring string
}

Verify is the action for building a given chart's Verify tree.

It provides the implementation of 'helm verify'.

func NewVerify

func NewVerify() *Verify

NewVerify creates a new Verify object with the given configuration.

func (*Verify) Run

func (v *Verify) Run(chartfile string) error

Run executes 'helm verify'.

Jump to

Keyboard shortcuts

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