release

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2021 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Overview

Package release allows to manage Helm 3 releases.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Kubeconfig is content of kubeconfig file in YAML format, which will be used to authenticate
	// to the cluster and create a release.
	Kubeconfig string `json:"kubeconfig,omitempty"`

	// Namespace is a namespace, where helm release will be created and all it's resources.
	Namespace string `json:"namespace,omitempty"`

	// Name is a name of the release used to identify it.
	Name string `json:"name,omitempty"`

	// Chart is a location of the chart. It may be local path or remote chart in user repository.
	Chart string `json:"chart,omitempty"`

	// Values is a chart values in YAML format.
	Values string `json:"values,omitempty"`

	// Version is a requested version of the chart.
	Version string `json:"version,omitempty"`

	// CreateNamespace controls, if the namespace for the release should be created before installing
	// the release.
	CreateNamespace bool `json:"createNamespace,omitempty"`

	// Wait controls if client should wait until managed chart converges.
	Wait bool `json:"wait,omitempty"`
}

Config represents user-configured Helm release.

func (*Config) New

func (r *Config) New() (Release, error)

New validates release configuration and builds installable version of it.

Example

Creating helm release.

package main

import (
	"fmt"

	"github.com/flexkube/libflexkube/pkg/helm/release"
)

func main() {
	config := &release.Config{
		// Put content of your kubeconfig file here.
		Kubeconfig: "",

		// The namespace must be created upfront.
		Namespace: "kube-system",

		// Name of helm release.
		Name: "coredns",

		// Repositories must be added upfront as well.
		Chart: "stable/coredns",

		// Values passed to the release in YAML format.
		Values: `replicas: 1
labels:
  foo: bar
`,
		// Version of the chart to use.
		Version: "1.12.0",
	}

	r, err := config.New()
	if err != nil {
		fmt.Printf("creating release object failed: %v\n", err)

		return
	}

	if err := r.Install(); err != nil {
		fmt.Printf("installing release failed: %v\n", err)

		return
	}
}
Output:

func (*Config) Validate

func (r *Config) Validate() error

Validate validates Release configuration.

type Release

type Release interface {
	// ValidateChart validates configured chart.
	ValidateChart() error

	// Install installs configured release. If release already exists, error will be returned.
	Install() error

	// Upgrade upgrades configured release. If release does not exist, error will be returned.
	Upgrade() error

	// InstallOrUpgrade either installs or upgrades the release, depends whether it exists or not.
	InstallOrUpgrade() error

	// Exists checks, if release exists. If cluster is not reachable, error is returned.
	Exists() (bool, error)

	// Uninstall removes the release.
	Uninstall() error
}

Release is an interface representing helm release.

func FromYaml

func FromYaml(data []byte) (Release, error)

FromYaml allows to quickly create new release object from YAML format.

Jump to

Keyboard shortcuts

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