helm

package
v0.0.0-...-6a1c4ee Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package helm implements a wrapper over a native Helm client. The wrapper exposes a simple installation API and the configuration.

The code in the package uses the user-provided function for logging.

Index

Constants

View Source
const (
	KymaLabelPrefix = "kyma-project.io/install." //label prefix used to distinguish Kyma labels from Helm labels in the Helm secrets
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client implements the ClientInterface.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a new Client instance. If you need different configurations for installation and uninstallation, just create two different Client instances with different configurations.

func (*Client) DeployRelease

func (c *Client) DeployRelease(ctx context.Context, chartDir, namespace, name string, overridesValues map[string]interface{}, profile string) error

func (*Client) Template

func (c *Client) Template(chartDir, namespace, name string, overridesValues map[string]interface{}, profile string) (string, error)

func (*Client) UninstallRelease

func (c *Client) UninstallRelease(ctx context.Context, namespace, name string) error

type ClientInterface

type ClientInterface interface {
	//DeployRelease deploys a named chart from a local filesystem directory with specific overrides.
	//The function retries on errors according to Config provided to the Client.
	//
	//ctx is used for the operation cancellation.
	//Cancellation of the successful operation is not possible
	//because the underlying Helm operations are blocking and do not support Context-based cancellation.
	//Cancellation is possible when errors occur and the operation is re-tried.
	//When the operation is re-tried, it is not guaranteed that the cancellation is handled immediately due to the blocking nature of Helm client calls.
	//However, once the underlying Helm operation ends, the "cancel" condition is detected and the operation's result is returned without further retries.
	DeployRelease(ctx context.Context, chartDir, namespace, name string, overrides map[string]interface{}, profile string) error
	//UninstallRelease uninstalls a named chart from the cluster.
	//The function retries on errors according to Config provided to the Client.
	//
	//ctx is used for the operation cancellation.
	//Cancellation of the successful operation is not possible
	//because the underlying Helm operations are blocking and do not support the Context-based cancellation.
	//Cancellation is possible when errors occur and the operation is re-tried.
	//When the operation is re-tried, it is not guaranteed that the cancellation is handled immediately due to the blocking nature of Helm client calls.
	//However, once the underlying Helm operation ends, the cancel condition is detected and the operation's result is returned without further retries.
	UninstallRelease(ctx context.Context, namespace, name string) error

	//Returns the rendered Helm template
	Template(chartDir, namespace, name string, overrides map[string]interface{}, profile string) (string, error)
}

ClientInterface defines the contract for the Helm-related installation processes.

type Config

type Config struct {
	HelmTimeoutSeconds            int              //Underlying native Helm client processing timeout
	BackoffInitialIntervalSeconds int              //Initial interval for the exponential backoff retry algorithm
	BackoffMaxElapsedTimeSeconds  int              //Maximum time for the exponential backoff retry algorithm
	MaxHistory                    int              //Maximum number of revisions saved per release
	Log                           logger.Interface //Used for logging
	Atomic                        bool
	KymaComponentMetadataTemplate *KymaComponentMetadataTemplate
	KubeconfigSource              config.KubeconfigSource
	ReuseValues                   bool //Reuse values for component upgrade
}

Config provides configuration for the Client.

type KymaComponentMetadata

type KymaComponentMetadata struct {
	Profile      string
	Version      string
	Component    bool //indicator flag to which is always set to 'true' (used in lookups)
	OperationID  string
	CreationTime int64
	Name         string
	Namespace    string
	Priority     int64
	Prerequisite bool
}

KymaComponentMetadata stores metadata of a component. These metadata fields are persisted as labels of a Kyma component Helm secret.

func (*KymaComponentMetadata) String

func (km *KymaComponentMetadata) String() string

type KymaComponentMetadataTemplate

type KymaComponentMetadataTemplate struct {
	Profile      string
	Version      string
	Prerequisite bool   //flag to mark prerequisite components
	Component    bool   //indicator flag to which is always set to 'true' (used in lookups)
	OperationID  string //unique ID used to distinguish versions with the same name
	CreationTime int64  //timestamp when the version was installed
	// contains filtered or unexported fields
}

KymaComponentMetadataTemplate is used as template (factory) to create KymaComponentMetadata instances

func NewKymaComponentMetadataTemplate

func NewKymaComponentMetadataTemplate(version, profile string) *KymaComponentMetadataTemplate

NewKymaComponentMetadataTemplate creates a new KymaComponentMetadataTemplate

func (*KymaComponentMetadataTemplate) Build

func (kmt *KymaComponentMetadataTemplate) Build(namespace, name string) (*KymaComponentMetadata, error)

Build creates a KymaComponentMetadata

func (*KymaComponentMetadataTemplate) ForComponents

ForComponents creates a copy of the template instance which has to be used for components (non-prerequisites)

func (*KymaComponentMetadataTemplate) ForPrerequisites

ForPrerequisites creates a copy of the template instance which has to be used for prerequisite components

type KymaMetadataProvider

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

KymaMetadataProvider enables access to Kyma component metadata and version information

func GetKymaMetadataProvider

func GetKymaMetadataProvider(kubeClient kubernetes.Interface) *KymaMetadataProvider

GetKymaMetadataProvider creates a new KymaMetadataProvider

func NewKymaMetadataProvider

func NewKymaMetadataProvider(kubeconfigSource config.KubeconfigSource) (*KymaMetadataProvider, error)

NewKymaMetadataProvider creates a new KymaMetadataProvider

func (*KymaMetadataProvider) Get

Get returns Kyma metadata of an installed component

func (*KymaMetadataProvider) Namespaces

func (mp *KymaMetadataProvider) Namespaces() ([]string, error)

Namespaces returns the set of installed Kyma namespaces

func (*KymaMetadataProvider) Set

Set adds Kyma metadata labels to a Helm secret

func (*KymaMetadataProvider) Versions

func (mp *KymaMetadataProvider) Versions() (*KymaVersionSet, error)

Versions returns the set of installed Kyma versions

type KymaVersion

type KymaVersion struct {
	Version      string
	Profile      string
	OperationID  string
	CreationTime int64
	Components   []*KymaComponentMetadata
}

KymaVersion stores metadata of an installed Kyma version

func (*KymaVersion) ComponentNames

func (v *KymaVersion) ComponentNames() []string

ComponentNames returns the names of the installed components

func (*KymaVersion) InstalledComponents

func (v *KymaVersion) InstalledComponents() []*KymaComponentMetadata

InstalledComponents returns a list of all components in the version sorted by their installation order

func (*KymaVersion) String

func (v *KymaVersion) String() string

type KymaVersionSet

type KymaVersionSet struct {
	Versions []*KymaVersion
}

KymaVersionSet bundles multiple Kyma versions

func (*KymaVersionSet) Count

func (kvs *KymaVersionSet) Count() int

Count counts the different Kyma versions

func (*KymaVersionSet) Empty

func (kvs *KymaVersionSet) Empty() bool

Empty verifies whether a Kyma version was found

func (*KymaVersionSet) InstalledComponents

func (kvs *KymaVersionSet) InstalledComponents() []*KymaComponentMetadata

InstalledComponents returns a list of all components sorted by their installation sequence

func (*KymaVersionSet) Latest

func (kvs *KymaVersionSet) Latest() *KymaVersion

Latest returns the latest installed Kyma version

func (*KymaVersionSet) Names

func (kvs *KymaVersionSet) Names() []string

Names returns the name of all Kyma versions

func (KymaVersionSet) String

func (kvs KymaVersionSet) String() string

Jump to

Keyboard shortcuts

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