Documentation ¶
Overview ¶
Package chartutil contains tools for working with charts.
Charts are described in the protocol buffer definition (pkg/proto/charts). This packe provides utilities for serializing and deserializing charts.
A chart can be represented on the file system in one of two ways:
- As a directory that contains a Chart.yaml file and other chart things.
- As a tarred gzipped file containing a directory that then contains a Chart.yaml file.
This package provides utilitites for working with those file formats.
The preferred way of loading a chart is using 'loader.Load`:
chart, err := loader.Load(filename)
This will attempt to discover whether the file at 'filename' is a directory or a chart archive. It will then load accordingly.
For accepting raw compressed tar file data from an io.Reader, the 'loader.LoadArchive()' will read in the data, uncompress it, and unpack it into a Chart.
When creating charts in memory, use the 'helm.sh/helm/pkg/proto/chart' package directly.
Index ¶
- Constants
- Variables
- func CoalesceTables(dst, src map[string]interface{}) map[string]interface{}
- func Create(name, dir string) (string, error)
- func CreateFrom(chartfile *chart.Metadata, dest, src string) error
- func Expand(dir string, r io.Reader) error
- func ExpandFile(dest, src string) error
- func IsChartDir(dirName string) (bool, error)
- func LoadChartfile(filename string) (*chart.Metadata, error)
- func ProcessDependencies(c *chart.Chart, v Values) error
- func Save(c *chart.Chart, outDir string) (string, error)
- func SaveChartfile(filename string, cf *chart.Metadata) error
- func SaveDir(c *chart.Chart, dest string) error
- func ValidateAgainstSchema(chrt *chart.Chart, values map[string]interface{}) error
- func ValidateAgainstSingleSchema(values Values, schemaJSON []byte) error
- type Capabilities
- type ErrNoTable
- type ErrNoValue
- type KubeVersion
- type ReleaseOptions
- type Values
- func CoalesceValues(chrt *chart.Chart, vals map[string]interface{}) (Values, error)
- func ReadValues(data []byte) (vals Values, err error)
- func ReadValuesFile(filename string) (Values, error)
- func ToRenderValues(chrt *chart.Chart, chrtVals map[string]interface{}, options ReleaseOptions, ...) (Values, error)
- type VersionSet
Examples ¶
Constants ¶
const ( // ChartfileName is the default Chart file name. ChartfileName = "Chart.yaml" // ValuesfileName is the default values file name. ValuesfileName = "values.yaml" // TemplatesDir is the relative directory name for templates. TemplatesDir = "templates" // ChartsDir is the relative directory name for charts dependencies. ChartsDir = "charts" // IgnorefileName is the name of the Helm ignore file. IgnorefileName = ".helmignore" // IngressFileName is the name of the example ingress file. IngressFileName = "ingress.yaml" // DeploymentName is the name of the example deployment file. DeploymentName = "deployment.yaml" // ServiceName is the name of the example service file. ServiceName = "service.yaml" // NotesName is the name of the example NOTES.txt file. NotesName = "NOTES.txt" // HelpersName is the name of the example NOTES.txt file. HelpersName = "_helpers.tpl" )
const GlobalKey = "global"
GlobalKey is the name of the Values key that is used for storing global vars.
Variables ¶
var ( // DefaultVersionSet is the default version set, which includes only Core V1 ("v1"). DefaultVersionSet = allKnownVersions() // DefaultCapabilities is the default set of capabilities. DefaultCapabilities = &Capabilities{ KubeVersion: KubeVersion{ Version: "v1.14.0", Major: "1", Minor: "14", }, APIVersions: DefaultVersionSet, } )
Functions ¶
func CoalesceTables ¶
CoalesceTables merges a source map into a destination map.
dest is considered authoritative.
func Create ¶
Create creates a new chart in a directory.
Inside of dir, this will create a directory based on the name of chartfile.Name. It will then write the Chart.yaml into this directory and create the (empty) appropriate directories.
The returned string will point to the newly created directory. It will be an absolute path, even if the provided base directory was relative.
If dir does not exist, this will return an error. If Chart.yaml or any directories cannot be created, this will return an error. In such a case, this will attempt to clean up by removing the new chart directory.
func CreateFrom ¶
CreateFrom creates a new chart, but scaffolds it from the src chart.
func ExpandFile ¶
ExpandFile expands the src file into the dest directory.
func LoadChartfile ¶
LoadChartfile loads a Chart.yaml file into a *chart.Metadata.
func ProcessDependencies ¶
ProcessDependencies checks through this chart's dependencies, processing accordingly.
func Save ¶
Save creates an archived chart to the given directory.
This takes an existing chart and a destination directory.
If the directory is /foo, and the chart is named bar, with version 1.0.0, this will generate /foo/bar-1.0.0.tgz.
This returns the absolute path to the chart archive file.
func SaveChartfile ¶
SaveChartfile saves the given metadata as a Chart.yaml file at the given path.
'filename' should be the complete path and filename ('foo/Chart.yaml')
func ValidateAgainstSchema ¶
ValidateAgainstSchema checks that values does not violate the structure laid out in schema
func ValidateAgainstSingleSchema ¶
ValidateAgainstSingleSchema checks that values does not violate the structure laid out in this schema
Types ¶
type Capabilities ¶
type Capabilities struct { // KubeVersion is the Kubernetes version. KubeVersion KubeVersion // APIversions are supported Kubernetes API versions. APIVersions VersionSet }
Capabilities describes the capabilities of the Kubernetes cluster.
type ErrNoTable ¶
type ErrNoTable string
ErrNoTable indicates that a chart does not have a matching table.
func (ErrNoTable) Error ¶
func (e ErrNoTable) Error() string
type ErrNoValue ¶
type ErrNoValue string
ErrNoValue indicates that Values does not contain a key with a value
func (ErrNoValue) Error ¶
func (e ErrNoValue) Error() string
type KubeVersion ¶
type KubeVersion struct { Version string // Kubernetes version Major string // Kubernetes major version Minor string // Kubernetes minor version }
KubeVersion is the Kubernetes version.
func (*KubeVersion) GitVersion
deprecated
func (kv *KubeVersion) GitVersion() string
GitVersion returns the Kubernetes version string.
Deprecated: use KubeVersion.Version.
type ReleaseOptions ¶
ReleaseOptions represents the additional release options needed for the composition of the final values struct
type Values ¶
type Values map[string]interface{}
Values represents a collection of chart values.
Example ¶
doc := ` title: "Moby Dick" chapter: one: title: "Loomings" two: title: "The Carpet-Bag" three: title: "The Spouter Inn" ` d, err := ReadValues([]byte(doc)) if err != nil { panic(err) } ch1, err := d.Table("chapter.one") if err != nil { panic("could not find chapter one") } fmt.Print(ch1["title"])
Output: Loomings
func CoalesceValues ¶
CoalesceValues coalesces all of the values in a chart (and its subcharts).
Values are coalesced together using the following rules:
- Values in a higher level chart always override values in a lower-level dependency chart
- Scalar values and arrays are replaced, maps are merged
- A chart has access to all of the variables for it, as well as all of the values destined for its dependencies.
func ReadValues ¶
ReadValues will parse YAML byte data into a Values.
func ReadValuesFile ¶
ReadValuesFile will parse a YAML file into a map of values.
func ToRenderValues ¶
func ToRenderValues(chrt *chart.Chart, chrtVals map[string]interface{}, options ReleaseOptions, caps *Capabilities) (Values, error)
ToRenderValues composes the struct from the data coming from the Releases, Charts and Values files
This takes both ReleaseOptions and Capabilities to merge into the render values.
func (Values) AsMap ¶
AsMap is a utility function for converting Values to a map[string]interface{}.
It protects against nil map panics.
func (Values) PathValue ¶
PathValue takes a path that traverses a YAML structure and returns the value at the end of that path. The path starts at the root of the YAML structure and is comprised of YAML keys separated by periods. Given the following YAML data the value at path "chapter.one.title" is "Loomings".
chapter: one: title: "Loomings"
type VersionSet ¶
type VersionSet []string
VersionSet is a set of Kubernetes API versions.
func (VersionSet) Has ¶
func (v VersionSet) Has(apiVersion string) bool
Has returns true if the version string is in the set.
vs.Has("apps/v1")