Documentation ¶
Index ¶
- type ChartSpec
- type Client
- type HelmClient
- func (c *HelmClient) GetChart(spec *ChartSpec) (*chart.Chart, string, error)
- func (c *HelmClient) GetChartSpecValues(spec *ChartSpec) (map[string]interface{}, error)
- func (c *HelmClient) GetRelease(name string) (*release.Release, error)
- func (c *HelmClient) GetReleaseValues(name string, allValues bool) (map[string]interface{}, error)
- func (c *HelmClient) InstallChart(ctx context.Context, spec *ChartSpec) (*release.Release, error)
- func (c *HelmClient) InstallOrUpgradeChart(ctx context.Context, spec *ChartSpec) (*release.Release, error)
- func (c *HelmClient) ListDeployedReleases() ([]*release.Release, error)
- func (c *HelmClient) ListReleasesByStateMask(states action.ListStates) ([]*release.Release, error)
- func (c *HelmClient) RollbackRelease(spec *ChartSpec) error
- func (c *HelmClient) UninstallRelease(spec *ChartSpec) error
- func (c *HelmClient) UninstallReleaseByName(name string) error
- func (c *HelmClient) UpgradeChart(ctx context.Context, spec *ChartSpec) (*release.Release, error)
- type HelmTemplateOptions
- type KubeConfClientOptions
- type Options
- type RESTClientGetter
- type RESTClientOption
- type RestConfClientOptions
- type RollBack
- type TagResolver
Examples ¶
- HelmClient.GetRelease
- HelmClient.GetReleaseValues
- HelmClient.InstallOrUpgradeChart
- HelmClient.InstallOrUpgradeChart (UseChartDirectory)
- HelmClient.InstallOrUpgradeChart (UseLocalChartArchive)
- HelmClient.InstallOrUpgradeChart (UseURL)
- HelmClient.ListDeployedReleases
- HelmClient.RollbackRelease
- HelmClient.UninstallRelease
- HelmClient.UninstallReleaseByName
- NewClientFromRestConf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChartSpec ¶
type ChartSpec struct { ReleaseName string `json:"release"` ChartName string `json:"chart"` // Namespace where the chart release is deployed. // Note that client.Options.Namespace should ideally match the namespace configured here. Namespace string `json:"namespace"` // ValuesYaml is the values.yaml content. // use string instead of map[string]interface{} // https://github.com/kubernetes-sigs/kubebuilder/issues/528#issuecomment-466449483 // and https://github.com/kubernetes-sigs/controller-tools/pull/317 // +optional ValuesYaml string `json:"valuesYaml,omitempty"` // Specify values similar to the cli // +optional ValuesOptions values.Options `json:"valuesOptions,omitempty"` // Version of the chart release. // +optional Version string `json:"version,omitempty"` // CreateNamespace indicates whether to create the namespace if it does not exist. // +optional CreateNamespace bool `json:"createNamespace,omitempty"` // Timeout configures the time to wait for any individual Kubernetes operation (like Jobs for hooks). // +optional Timeout time.Duration `json:"timeout,omitempty"` // Atomic indicates whether to install resources atomically. // 'Wait' will automatically be set to true when using Atomic. // +optional Atomic bool `json:"atomic,omitempty"` // ResetValues indicates whether to reset the values.yaml file during installation. // +optional ResetValues bool `json:"resetValues,omitempty"` // ReuseValues indicates whether to reuse the values.yaml file during installation. // +optional ReuseValues bool `json:"reuseValues,omitempty"` // CleanupOnFail indicates whether to cleanup the release on failure. // +optional CleanupOnFail bool `json:"cleanupOnFail,omitempty"` // PostRenderer can be used to apply transformations to kubernetes resources // on installation and upgrade after rendering the templates // +optional PostRenderer postrender.PostRenderer }
ChartSpec defines the values of a helm chart
type Client ¶
type Client interface { InstallOrUpgradeChart(ctx context.Context, spec *ChartSpec) (*release.Release, error) InstallChart(ctx context.Context, spec *ChartSpec) (*release.Release, error) UpgradeChart(ctx context.Context, spec *ChartSpec) (*release.Release, error) ListDeployedReleases() ([]*release.Release, error) ListReleasesByStateMask(action.ListStates) ([]*release.Release, error) GetRelease(name string) (*release.Release, error) // RollBack is an interface to abstract a rollback action. RollBack GetReleaseValues(name string, allValues bool) (map[string]interface{}, error) GetChartSpecValues(spec *ChartSpec) (map[string]interface{}, error) UninstallRelease(spec *ChartSpec) error UninstallReleaseByName(name string) error GetChart(spec *ChartSpec) (*chart.Chart, string, error) TagResolver }
Client holds the method signatures for a Helm client. NOTE: This is an interface to allow for mocking in tests.
func NewClientFromRestConf ¶
func NewClientFromRestConf(options *RestConfClientOptions) (Client, error)
NewClientFromRestConf returns a new Helm client constructed with the provided REST config options.
Example ¶
opt := &RestConfClientOptions{ Options: &Options{ Namespace: "default", // Change this to the namespace you wish the client to operate in. RepositoryCache: "/tmp/.helmcache", RepositoryConfig: "/tmp/.helmrepo", Debug: true, DebugLog: func(format string, v ...interface{}) { // Change this to your own logger. Default is 'log.Printf(format, v...)'. }, }, RestConfig: &rest.Config{}, } helmClient, err := NewClientFromRestConf(opt) if err != nil { panic(err) } _ = helmClient
Output:
type HelmClient ¶
type HelmClient struct { TagResolver // Settings defines the environment settings of a client. Settings *cli.EnvSettings DebugLog action.DebugLog // contains filtered or unexported fields }
HelmClient Client defines the values of a helm client.
func (*HelmClient) GetChart ¶
GetChart returns a chart matching the provided chart name and options.
func (*HelmClient) GetChartSpecValues ¶ added in v0.6.0
func (c *HelmClient) GetChartSpecValues(spec *ChartSpec) (map[string]interface{}, error)
GetChartSpecValues returns the additional values for the specified ChartSpec.
func (*HelmClient) GetRelease ¶
func (c *HelmClient) GetRelease(name string) (*release.Release, error)
GetRelease returns a release specified by name.
Example ¶
// Get specific details of a deployed release. if _, err := helmClient.GetRelease("etcd-operator"); err != nil { panic(err) }
Output:
func (*HelmClient) GetReleaseValues ¶
func (c *HelmClient) GetReleaseValues(name string, allValues bool) (map[string]interface{}, error)
GetReleaseValues returns the (optionally, all computed) values for the specified release.
Example ¶
// Get the values of a deployed release. if _, err := helmClient.GetReleaseValues("etcd-operator", true); err != nil { panic(err) }
Output:
func (*HelmClient) InstallChart ¶
InstallChart installs the provided chart and returns the corresponding release. Namespace and other context is provided via the client.Options struct when instantiating a client.
func (*HelmClient) InstallOrUpgradeChart ¶
func (c *HelmClient) InstallOrUpgradeChart(ctx context.Context, spec *ChartSpec) (*release.Release, error)
InstallOrUpgradeChart installs or upgrades the provided chart and returns the corresponding release. Namespace and other context is provided via the client.Options struct when instantiating a client.
Example ¶
// Define the chart to be installed chartSpec := ChartSpec{ ReleaseName: "etcd-operator", ChartName: "stable/etcd-operator", Namespace: "default", } // Install a chart release. // Note that helmclient.Options.Namespace should ideally match the namespace in chartSpec.Namespace. if _, err := helmClient.InstallOrUpgradeChart(context.Background(), &chartSpec); err != nil { panic(err) }
Output:
Example (UseChartDirectory) ¶
// Use an unpacked chart directory. chartSpec := ChartSpec{ ReleaseName: "etcd-operator", ChartName: "/path/to/stable/etcd-operator", Namespace: "default", } if _, err := helmClient.InstallOrUpgradeChart(context.Background(), &chartSpec); err != nil { panic(err) }
Output:
Example (UseLocalChartArchive) ¶
// Use an archived chart directory. chartSpec := ChartSpec{ ReleaseName: "etcd-operator", ChartName: "/path/to/stable/etcd-operator.tar.gz", Namespace: "default", } if _, err := helmClient.InstallOrUpgradeChart(context.Background(), &chartSpec); err != nil { panic(err) }
Output:
Example (UseURL) ¶
// Use an archived chart directory via URL. chartSpec := ChartSpec{ ReleaseName: "etcd-operator", ChartName: "http://helm.whatever.com/repo/etcd-operator.tar.gz", Namespace: "default", } if _, err := helmClient.InstallOrUpgradeChart(context.Background(), &chartSpec); err != nil { panic(err) }
Output:
func (*HelmClient) ListDeployedReleases ¶
func (c *HelmClient) ListDeployedReleases() ([]*release.Release, error)
ListDeployedReleases lists all deployed releases. Namespace and other context is provided via the client.Options struct when instantiating a client.
Example ¶
// List all deployed releases. if _, err := helmClient.ListDeployedReleases(); err != nil { panic(err) }
Output:
func (*HelmClient) ListReleasesByStateMask ¶
func (c *HelmClient) ListReleasesByStateMask(states action.ListStates) ([]*release.Release, error)
ListReleasesByStateMask lists all releases filtered by stateMask. Namespace and other context is provided via the client.Options struct when instantiating a client.
func (*HelmClient) RollbackRelease ¶
func (c *HelmClient) RollbackRelease(spec *ChartSpec) error
RollbackRelease implicitly rolls back a release to the last revision.
Example ¶
// Define the released chart to be installed chartSpec := ChartSpec{ ReleaseName: "etcd-operator", ChartName: "stable/etcd-operator", Namespace: "default", } // Rollback to the previous version of the release. if err := helmClient.RollbackRelease(&chartSpec); err != nil { return }
Output:
func (*HelmClient) UninstallRelease ¶
func (c *HelmClient) UninstallRelease(spec *ChartSpec) error
UninstallRelease uninstalls the provided release
Example ¶
// Define the released chart to be installed. chartSpec := ChartSpec{ ReleaseName: "etcd-operator", ChartName: "stable/etcd-operator", Namespace: "default", } // Uninstall the chart release. // Note that helmclient.Options.Namespace should ideally match the namespace in chartSpec.Namespace. if err := helmClient.UninstallRelease(&chartSpec); err != nil { panic(err) }
Output:
func (*HelmClient) UninstallReleaseByName ¶
func (c *HelmClient) UninstallReleaseByName(name string) error
UninstallReleaseByName uninstalls a release identified by the provided 'name'.
Example ¶
// Uninstall a release by name. if err := helmClient.UninstallReleaseByName("etcd-operator"); err != nil { panic(err) }
Output:
func (*HelmClient) UpgradeChart ¶
UpgradeChart upgrades the provided chart and returns the corresponding release. Namespace and other context is provided via the client.Options struct when instantiating a client.
type HelmTemplateOptions ¶
type HelmTemplateOptions struct { KubeVersion *chartutil.KubeVersion // APIVersions defined here will be appended to the default list helm provides APIVersions chartutil.VersionSet }
type KubeConfClientOptions ¶
KubeConfClientOptions defines the options used for constructing a client via kubeconfig.
type Options ¶
type Options struct { Namespace string RepositoryConfig string RepositoryCache string Debug bool DebugLog action.DebugLog RegistryConfig string Output io.Writer // PlainHttp forces the registry client to establish plain http connections. This option will override by InsecureTls by using HTTP traffic. PlainHttp bool // InsecureTls allows invalid or selfsigned certificates to be used. This option may be overridden by PlainHttp which forces HTTP traffic. InsecureTls bool }
Options defines the options of a client. If Output is not set, os.Stdout will be used.
type RESTClientGetter ¶
type RESTClientGetter struct {
// contains filtered or unexported fields
}
RESTClientGetter defines the values of a helm REST client.
func NewRESTClientGetter ¶
func NewRESTClientGetter(namespace string, kubeConfig []byte, restConfig *rest.Config, opts ...RESTClientOption) *RESTClientGetter
NewRESTClientGetter returns a RESTClientGetter using the provided 'namespace', 'kubeConfig' and 'restConfig'.
source: https://github.com/helm/helm/issues/6910#issuecomment-601277026
func (*RESTClientGetter) ToDiscoveryClient ¶
func (c *RESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
ToDiscoveryClient returns a CachedDiscoveryInterface that can be used as a discovery client.
func (*RESTClientGetter) ToRESTConfig ¶
func (c *RESTClientGetter) ToRESTConfig() (*rest.Config, error)
ToRESTConfig returns a REST config build from a given kubeconfig
func (*RESTClientGetter) ToRESTMapper ¶
func (c *RESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)
func (*RESTClientGetter) ToRawKubeConfigLoader ¶
func (c *RESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig
type RESTClientOption ¶
RESTClientOption is a function that can be used to set the RESTClientOptions of a HelmClient.
type RestConfClientOptions ¶
RestConfClientOptions defines the options used for constructing a client via REST config.