chart

package
v2.0.0-alpha.1+incompa... Latest Latest
Warning

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

Go to latest
Published: May 25, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package chart implements the Chart format.

This package provides tools for working with the Chart format, including the Chartfile (chart.yaml) and compressed chart archives.

Index

Examples

Constants

View Source
const ChartfileName string = "Chart.yaml"

ChartfileName is the default Chart file name.

Variables

View Source
var ErrNoTable = errors.New("no table")

ErrNoTable indicates that a chart does not have a matching table.

Functions

func Expand

func Expand(dir string, r io.Reader) error

Expand uncompresses and extracts a chart into the specified directory.

func Save

func Save(c *Chart, outDir string) (string, error)

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.

Types

type Chart

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

Chart represents a complete chart.

A chart consists of the following parts:

  • Chart.yaml: In code, we refer to this as the Chartfile
  • templates/*: The template directory
  • README.md: Optional README file
  • LICENSE: Optional license file
  • hooks/: Optional hooks registry
  • docs/: Optional docs directory

Packed charts are stored in gzipped tar archives (.tgz). Unpackaged charts are directories where the directory name is the Chartfile.Name.

Optionally, a chart might also locate a provenance (.prov) file that it can use for cryptographic signing.

func Create

func Create(chartfile *Chartfile, dir string) (*Chart, error)

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 *Chart will point to the newly created directory.

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 Load

func Load(archive string) (*Chart, error)

Load loads a chart from a chart archive.

A chart archive is a gzipped tar archive that follows the Chart format specification.

func LoadChart

func LoadChart(chfi string) (*Chart, error)

LoadChart loads an entire chart archive.

The following are valid values for 'chfi':

  • relative path to the chart archive
  • absolute path to the chart archive
  • name of the chart directory

func LoadData

func LoadData(data []byte) (*Chart, error)

LoadData loads a chart from data, where data is a []byte containing a gzipped tar file.

func LoadDataFromReader

func LoadDataFromReader(r io.Reader) (*Chart, error)

LoadDataFromReader loads a chart from a reader

func LoadDir

func LoadDir(chart string) (*Chart, error)

LoadDir loads an entire chart from a directory.

This includes the Chart.yaml (*Chartfile) and all of the manifests.

If you are just reading the Chart.yaml file, it is substantially more performant to use LoadChartfile.

func (*Chart) ChartDepNames

func (c *Chart) ChartDepNames() ([]string, error)

ChartDepNames returns the list of chart names found in ChartsDir.

func (*Chart) Chartfile

func (c *Chart) Chartfile() *Chartfile

Chartfile gets the Chartfile (Chart.yaml) for this chart.

func (*Chart) ChartsDir

func (c *Chart) ChartsDir() string

ChartsDir returns the directory where dependency charts are stored.

func (*Chart) Close

func (c *Chart) Close() error

Close the chart.

Charts should always be closed when no longer needed.

func (*Chart) Dir

func (c *Chart) Dir() string

Dir returns the directory where the charts are located.

func (*Chart) LoadContent

func (c *Chart) LoadContent() (*Content, error)

LoadContent loads contents of a chart directory into Content

func (*Chart) LoadMember

func (c *Chart) LoadMember(path string) (*Member, error)

LoadMember loads a chart member from a given path where path is the root of the chart.

func (*Chart) LoadTemplates

func (c *Chart) LoadTemplates() ([]*Member, error)

LoadTemplates loads the members of TemplatesDir().

func (*Chart) LoadValues

func (c *Chart) LoadValues() (Values, error)

LoadValues loads the contents of values.toml into a map

func (*Chart) TemplatesDir

func (c *Chart) TemplatesDir() string

TemplatesDir returns the directory where the templates are stored.

type Chartfile

type Chartfile struct {
	Name        string        `yaml:"name"`
	Description string        `yaml:"description"`
	Version     string        `yaml:"version"`
	Keywords    []string      `yaml:"keywords,omitempty"`
	Maintainers []*Maintainer `yaml:"maintainers,omitempty"`
	Source      []string      `yaml:"sources,omitempty"`
	Home        string        `yaml:"home"`
}

Chartfile describes a Helm Chart (e.g. Chart.yaml)

func LoadChartfile

func LoadChartfile(filename string) (*Chartfile, error)

LoadChartfile loads a Chart.yaml file into a *Chart.

func (*Chartfile) Marshal

func (c *Chartfile) Marshal() ([]byte, error)

Marshal encodes the chart file into YAML.

func (*Chartfile) Save

func (c *Chartfile) Save(filename string) error

Save saves a Chart.yaml file

type Content

type Content struct {
	Chartfile *Chartfile `json:"chartfile"`
	Members   []*Member  `json:"members"`
}

Content is abstraction for the contents of a chart.

type Maintainer

type Maintainer struct {
	Name  string `yaml:"name"`
	Email string `yaml:"email,omitempty"`
}

Maintainer describes a chart maintainer.

type Member

type Member struct {
	Path    string `json:"path"`    // Path from the root of the chart.
	Content []byte `json:"content"` // Base64 encoded content.
}

Member is a file in a chart.

type Values

type Values map[string]interface{}

Values represents a collection of chart values.

Example
doc := `title="Moby Dick"
[chapter.one]
title = "Loomings"

[chapter.two]
title = "The Carpet-Bag"

[chapter.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 ReadValues

func ReadValues(data []byte) (Values, error)

ReadValues will parse TOML byte data into a Values.

func ReadValuesFile

func ReadValuesFile(filename string) (Values, error)

ReadValuesFile will parse a TOML file into a Values.

func (Values) Encode

func (v Values) Encode(w io.Writer) error

Encode writes serialized Values information to the given io.Writer.

func (Values) Table

func (v Values) Table(name string) (Values, error)

Table gets a table (TOML subsection) from a Values object.

The table is returned as a Values.

Compound table names may be specified with dots:

foo.bar

The above will be evaluated as "The table bar inside the table foo".

An ErrNoTable is returned if the table does not exist.

Jump to

Keyboard shortcuts

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