Documentation
¶
Index ¶
- type ChartSpec
- type Client
- type HelmClient
- func (c *HelmClient) AddOrUpdateChartRepo(entry repo.Entry) error
- func (c *HelmClient) DeleteChartFromCache(spec *ChartSpec) error
- func (c *HelmClient) InstallOrUpgradeChart(spec *ChartSpec) error
- func (c *HelmClient) UninstallRelease(spec *ChartSpec) error
- func (c *HelmClient) UpdateChartRepos() error
- type KubeConfClientOptions
- type Options
- type RESTClientGetter
- type RestConfClientOptions
Examples ¶
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 string `json:"namespace"`
// 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"`
// +optional
Version string `json:"version,omitempty"`
// +optional
DisableHooks bool `json:"disableHooks,omitempty"`
// +optional
Replace bool `json:"replace,omitempty"`
// +optional
Wait bool `json:"wait,omitempty"`
// +optional
DependencyUpdate bool `json:"dependencyUpdate,omitempty"`
// +optional
Timeout time.Duration `json:"timeout,omitempty"`
// +optional
GenerateName bool `json:"generateName,omitempty"`
// +optional
NameTemplate string `json:"NameTemplate,omitempty"`
// +optional
Atomic bool `json:"atomic,omitempty"`
// +optional
SkipCRDs bool `json:"skipCRDs,omitempty"`
// +optional
UpgradeCRDs bool `json:"upgradeCRDs,omitempty"`
// +optional
SubNotes bool `json:"subNotes,omitempty"`
// +optional
Force bool `json:"force,omitempty"`
// +optional
ResetValues bool `json:"resetValues,omitempty"`
// +optional
ReuseValues bool `json:"reuseValues,omitempty"`
// +optional
Recreate bool `json:"recreate,omitempty"`
// +optional
MaxHistory int `json:"maxHistory,omitempty"`
// +optional
CleanupOnFail bool `json:"cleanupOnFail,omitempty"`
}
ChartSpec defines the values of a helm chart
func (*ChartSpec) GetValuesMap ¶
GetValuesMap returns the mapped out values of a chart
type Client ¶
type Client interface {
AddOrUpdateChartRepo(entry repo.Entry) error
UpdateChartRepos() error
InstallOrUpgradeChart(spec *ChartSpec) error
DeleteChartFromCache(spec *ChartSpec) error
UninstallRelease(spec *ChartSpec) error
}
func New ¶
New returns a new Helm client with the provided options
Example ¶
opt := &Options{
RepositoryCache: "/tmp/.helmcache",
RepositoryConfig: "/tmp/.helmrepo",
Debug: true,
Linting: true,
}
helmClient, err := New(opt)
if err != nil {
panic(err)
}
_ = helmClient
func NewClientFromKubeConf ¶
func NewClientFromKubeConf(options *KubeConfClientOptions) (Client, error)
NewClientFromKubeConf returns a new Helm client constructed with the provided kubeconfig options
Example ¶
opt := &KubeConfClientOptions{
Options: &Options{
RepositoryCache: "/tmp/.helmcache",
RepositoryConfig: "/tmp/.helmrepo",
Debug: true,
Linting: true,
},
KubeContext: "",
KubeConfig: []byte{},
}
helmClient, err := NewClientFromKubeConf(opt)
if err != nil {
panic(err)
}
_ = helmClient
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{
RepositoryCache: "/tmp/.helmcache",
RepositoryConfig: "/tmp/.helmrepo",
Debug: true,
Linting: true,
},
RestConfig: &rest.Config{},
}
helmClient, err := NewClientFromRestConf(opt)
if err != nil {
panic(err)
}
_ = helmClient
type HelmClient ¶ added in v0.1.1
type HelmClient struct {
Settings *cli.EnvSettings
Providers getter.Providers
ActionConfig *action.Configuration
// contains filtered or unexported fields
}
Client defines the values of a helm client
func (*HelmClient) AddOrUpdateChartRepo ¶ added in v0.1.1
func (c *HelmClient) AddOrUpdateChartRepo(entry repo.Entry) error
AddOrUpdateChartRepo adds or updates the provided helm chart repository
Example (Private) ¶
// Define a private chart repository
chartRepo := repo.Entry{
Name: "stable",
URL: "https://private-chartrepo.somedomain.com",
Username: "foo",
Password: "bar",
}
// Add a chart-repository to the client
if err := helmClient.AddOrUpdateChartRepo(chartRepo); err != nil {
panic(err)
}
Example (Public) ¶
// Define a public chart repository
chartRepo := repo.Entry{
Name: "stable",
URL: "https://kubernetes-charts.storage.googleapis.com",
}
// Add a chart-repository to the client
if err := helmClient.AddOrUpdateChartRepo(chartRepo); err != nil {
panic(err)
}
func (*HelmClient) DeleteChartFromCache ¶ added in v0.1.1
func (c *HelmClient) DeleteChartFromCache(spec *ChartSpec) error
DeleteChartFromCache deletes the provided chart from the client's cache
Example ¶
// Define the chart to be deleted from the client's cache
chartSpec := ChartSpec{
ReleaseName: "etcd-operator",
ChartName: "stable/etcd-operator",
Namespace: "default",
UpgradeCRDs: true,
Wait: true,
}
if err := helmClient.DeleteChartFromCache(&chartSpec); err != nil {
panic(err)
}
func (*HelmClient) InstallOrUpgradeChart ¶ added in v0.1.1
func (c *HelmClient) InstallOrUpgradeChart(spec *ChartSpec) error
InstallOrUpgradeChart triggers the installation of the provided chart. If the chart is already installed, trigger an upgrade instead
Example ¶
// Define the chart to be installed
chartSpec := ChartSpec{
ReleaseName: "etcd-operator",
ChartName: "stable/etcd-operator",
Namespace: "default",
UpgradeCRDs: true,
Wait: true,
}
if err := helmClient.InstallOrUpgradeChart(&chartSpec); err != nil {
panic(err)
}
func (*HelmClient) UninstallRelease ¶ added in v0.1.1
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",
UpgradeCRDs: true,
Wait: true,
}
if err := helmClient.UninstallRelease(&chartSpec); err != nil {
panic(err)
}
func (*HelmClient) UpdateChartRepos ¶ added in v0.1.1
func (c *HelmClient) UpdateChartRepos() error
UpdateChartRepos updates the list of chart repositories stored in the client's cache
Example ¶
if err := helmClient.UpdateChartRepos(); err != nil {
panic(err)
}
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
Linting bool
}
Options defines the options of a client
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) *RESTClientGetter
NewRESTClientGetter
source: https://github.com/helm/helm/issues/6910#issuecomment-601277026
func (*RESTClientGetter) ToDiscoveryClient ¶
func (c *RESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
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 RestConfClientOptions ¶
RestConfClientOptions defines the options used for constructing a client via REST config