helm

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 19 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// Version of the current Chartfile implementation
	Version = 1

	// Filename of the Chartfile
	Filename = "chartfile.yaml"

	// DefaultDir is the directory used for storing Charts if not specified
	// otherwise
	DefaultDir = "charts"
)
View Source
const DefaultNameFormat = `{{ print .kind "_" .metadata.name | snakecase }}`

DefaultNameFormat to use when no nameFormat is supplied

Variables

This section is empty.

Functions

func NativeFunc

func NativeFunc(h Helm) *jsonnet.NativeFunction

NativeFunc returns a jsonnet native function that provides the same functionality as `Helm.Template` of this package. Charts are required to be present on the local filesystem, at a relative location to the file that calls `helm.template()` / `std.native('helmTemplate')`. This guarantees hermeticity

Types

type ChartSearchVersion added in v0.27.0

type ChartSearchVersion struct {
	// Name of the chart in the form of repo/chartName
	Name string `json:"name,omitempty"`

	// Version of the Helm chart
	Version string `json:"version,omitempty"`

	// Version of the application being deployed by the Helm chart
	AppVersion string `json:"app_version,omitempty"`

	// Description of the Helm chart
	Description string `json:"description,omitempty"`
}

ChartSearchVersion represents a single chart version returned from the helm search repo command.

type ChartSearchVersions added in v0.27.0

type ChartSearchVersions []ChartSearchVersion

type Chartfile

type Chartfile struct {
	// Version of the Chartfile schema (for future use)
	Version uint `json:"version"`

	// Repositories to source from
	Repositories Repos `json:"repositories"`

	// Requires lists Charts expected to be present in the charts folder
	Requires Requirements `json:"requires"`

	// Folder to use for storing Charts. Defaults to 'charts'
	Directory string `json:"directory,omitempty"`
}

Chartfile is the schema used to declaratively define locally required Helm Charts

type Charts

type Charts struct {
	// Manifest are the chartfile.yaml contents. It holds data about the developers intentions
	Manifest Chartfile

	// Helm is the helm implementation underneath. ExecHelm is the default, but
	// any implementation of the Helm interface may be used
	Helm Helm
	// contains filtered or unexported fields
}

Charts exposes the central Chartfile management functions

func InitChartfile

func InitChartfile(path string) (*Charts, error)

func LoadChartfile

func LoadChartfile(projectRoot string) (*Charts, error)

LoadChartfile opens a Chartfile tree

func (*Charts) Add

func (c *Charts) Add(reqs []string, repoConfigPath string) error

Add adds every Chart in reqs to the Manifest after validation, and runs Vendor afterwards

func (*Charts) AddRepos added in v0.14.0

func (c *Charts) AddRepos(repos ...Repo) error

func (Charts) ChartDir

func (c Charts) ChartDir() string

ChartDir returns the directory pulled charts are saved in

func (Charts) ManifestFile

func (c Charts) ManifestFile() string

ManifestFile returns the full path to the chartfile.yaml

func (Charts) Vendor

func (c Charts) Vendor(prune bool, repoConfigPath string) error

Vendor pulls all Charts specified in the manifest into the local charts directory. It fetches the repository index before doing so.

func (*Charts) VersionCheck added in v0.27.0

func (c *Charts) VersionCheck(repoConfigPath string) (map[string]RequiresVersionInfo, error)

VersionCheck checks each of the charts in the requires section and returns information regarding related to version upgrades. This includes if the current version is latest as well as the latest matching versions of the major and minor version the chart is currently on.

type ConfigFile added in v0.27.0

type ConfigFile struct {
	// Version of the Helm repo config schema
	APIVersion string `json:"apiVersion"`

	// The datetime of when this repo config was generated
	Generated string `json:"generated"`

	// Repositories to source from
	Repositories Repos `json:"repositories"`
}

ConfigFile represents the default Helm config structure to be used in place of the chartfile Repositories if supplied.

func LoadHelmRepoConfig added in v0.27.0

func LoadHelmRepoConfig(repoConfigPath string) (*ConfigFile, error)

LoadHelmRepoConfig reads in a helm config file

type ExecHelm

type ExecHelm struct{}

ExecHelm is a Helm implementation powered by the `helm` command line utility

func (ExecHelm) ChartExists added in v0.25.0

func (e ExecHelm) ChartExists(chart string, opts *JsonnetOpts) (string, error)

func (ExecHelm) Pull

func (e ExecHelm) Pull(chart, version string, opts PullOpts) error

Pull implements Helm.Pull

func (ExecHelm) RepoUpdate

func (e ExecHelm) RepoUpdate(opts Opts) error

RepoUpdate implements Helm.RepoUpdate

func (ExecHelm) SearchRepo added in v0.27.0

func (e ExecHelm) SearchRepo(chart, currVersion string, opts Opts) (ChartSearchVersions, error)

Searches the helm repositories for the latest, the latest matching major, and the latest matching minor versions for the given chart.

func (ExecHelm) Template

func (e ExecHelm) Template(name, chart string, opts TemplateOpts) (manifest.List, error)

Template expands a Helm Chart into a regular manifest.List using the `helm template` command

type Helm

type Helm interface {
	// Pull downloads a Helm Chart from a remote
	Pull(chart, version string, opts PullOpts) error

	// RepoUpdate fetches the latest remote index
	RepoUpdate(opts Opts) error

	// Template returns the individual resources of a Helm Chart
	Template(name, chart string, opts TemplateOpts) (manifest.List, error)

	// ChartExists checks if a chart exists in the provided calledFromPath
	ChartExists(chart string, opts *JsonnetOpts) (string, error)

	// SearchRepo searches the repository for an updated chart version
	SearchRepo(chart, currVersion string, opts Opts) (ChartSearchVersions, error)
}

Helm provides high level access to some Helm operations

type JsonnetOpts

type JsonnetOpts struct {
	TemplateOpts

	// CalledFrom is the file that calls helmTemplate. This is used to find the
	// vendored chart relative to this file
	CalledFrom string `json:"calledFrom"`
	// NameTemplate is used to create the keys in the resulting map
	NameFormat string `json:"nameFormat"`
}

JsonnetOpts are additional properties the consumer of the native func might pass.

type Opts

type Opts struct {
	Repositories []Repo
}

Opts are additional, non-required options that all Helm operations accept

type PullOpts

type PullOpts struct {
	Opts

	// Directory to put the resulting .tgz into
	Destination string

	// Where to extract the chart to, defaults to the name of the chart
	ExtractDirectory string
}

PullOpts are additional, non-required options for Helm.Pull

type Repo

type Repo struct {
	Name     string `json:"name,omitempty"`
	URL      string `json:"url,omitempty"`
	CAFile   string `json:"caFile,omitempty"`
	CertFile string `json:"certFile,omitempty"`
	KeyFile  string `json:"keyFile,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

Repo describes a single Helm repository

type Repos added in v0.14.0

type Repos []Repo

func (Repos) Has added in v0.14.0

func (r Repos) Has(repo Repo) bool

Has reports whether 'repo' is already part of the repositories

func (Repos) HasName added in v0.22.0

func (r Repos) HasName(repoName string) bool

Has reports whether one of the repos has the given name

type Requirement

type Requirement struct {
	Chart     string `json:"chart"`
	Version   string `json:"version"`
	Directory string `json:"directory,omitempty"`
}

Requirement describes a single required Helm Chart. Both, Chart and Version are required

func (Requirement) String added in v0.22.0

func (r Requirement) String() string

type Requirements

type Requirements []Requirement

Requirements is an aggregate of all required Charts

func (Requirements) Has

func (r Requirements) Has(req Requirement) bool

Has reports whether 'req' is already part of the requirements

func (Requirements) Validate added in v0.22.1

func (r Requirements) Validate() error

type RequiresVersionInfo added in v0.27.0

type RequiresVersionInfo struct {
	// Name of the required chart in the form of repo/chartName
	Name string `json:"name,omitempty"`

	// Directory information for the chart.
	Directory string `json:"directory,omitempty"`

	// The current version information of the required helm chart.
	CurrentVersion string `json:"current_version,omitempty"`

	// Boolean representing if the required chart is already up to date.
	UsingLatestVersion bool `json:"using_latest_version"`

	// The most up-to-date version information of the required helm chart.
	LatestVersion ChartSearchVersion `json:"latest_version,omitempty"`

	// The latest version information of the required helm chart that matches the current major version.
	LatestMatchingMajorVersion ChartSearchVersion `json:"latest_matching_major_version,omitempty"`

	// The latest version information of the required helm chart that matches the current minor version.
	LatestMatchingMinorVersion ChartSearchVersion `json:"latest_matching_minor_version,omitempty"`
}

RequiresVersionInfo represents a specific required chart and the information around the current version and any upgrade information.

type TemplateOpts

type TemplateOpts struct {
	// Values to pass to Helm using --values
	Values map[string]interface{}

	// Kubernetes api versions used for Capabilities.APIVersions
	APIVersions []string
	// IncludeCRDs specifies whether CustomResourceDefinitions are included in
	// the template output
	IncludeCRDs bool
	// skip tests from templated output
	SkipTests bool
	// Kubernetes version used for Capabilities.KubeVersion
	KubeVersion string
	// Namespace scope for this request
	Namespace string
	// NoHooks specifies whether hooks should be excluded from the template output
	NoHooks bool
}

TemplateOpts are additional, non-required options for Helm.Template

func (TemplateOpts) Flags

func (t TemplateOpts) Flags() []string

Flags returns all options apart from Values as their respective `helm template` flag equivalent

Jump to

Keyboard shortcuts

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