chart

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2016 License: Apache-2.0 Imports: 15 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

Constants

View Source
const (
	SchemeHTTP  = "http"
	SchemeHTTPS = "https"
	SchemeHelm  = "helm"
	SchemeFile  = "file"
)

Constants defining recognized URL schemes.

View Source
const ChartfileName string = "Chart.yaml"

ChartfileName is the default Chart file name.

View Source
const TarNameRegex = `([0-9A-Za-z\-_/]+)-(v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?` +
	`(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?` +
	`(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)(.tgz)?`

TarNameRegex parses the name component of a URI and breaks it into a name and version.

This borrows liberally from github.com/Masterminds/semver.

Variables

View Source
var ErrLocal = errors.New("cannot use local Locator as remote")

ErrLocal indicates that a local URL was used as a remote URL.

View Source
var ErrRemote = errors.New("cannot use remote Locator as local")

ErrRemote indicates that a remote URL was used as a local URL.

Functions

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 LoadData

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

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

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) Chartfile

func (c *Chart) Chartfile() *Chartfile

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

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) DocsDir

func (c *Chart) DocsDir() string

DocsDir returns the directory where the chart's documentation is stored.

func (*Chart) HooksDir

func (c *Chart) HooksDir() string

HooksDir returns the directory where the hooks are stored.

func (*Chart) Icon

func (c *Chart) Icon() (string, error)

Icon returns the path to the icon.svg file.

If an icon is not found in the chart, this will return an error.

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:"source,omitempty"`
	Home         string           `yaml:"home"`
	Dependencies []*Dependency    `yaml:"dependencies,omitempty"`
	Environment  []*EnvConstraint `yaml:"environment,omitempty"`
}

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 Dependency

type Dependency struct {
	Name     string `yaml:"name,omitempty"`
	Version  string `yaml:"version"`
	Location string `yaml:"location"`
}

Dependency describes a specific dependency.

func (*Dependency) VersionOK

func (d *Dependency) VersionOK(version string) bool

VersionOK returns true if the given version meets the constraints.

It returns false if the version string or constraint is unparsable or if the version does not meet the constraint.

type EnvConstraint

type EnvConstraint struct {
	Name       string   `yaml:"name"`
	Version    string   `yaml:"version"`
	Extensions []string `yaml:"extensions,omitempty"`
	APIGroups  []string `yaml:"apiGroups,omitempty"`
}

EnvConstraint specifies environmental constraints.

type Locator

type Locator struct {
	// The scheme of the URL. Typically one of http, https, helm, or file.
	Scheme string
	// The host information, if applicable.
	Host string
	// The bucket name
	Bucket string
	// The chart name
	Name string
	// The version or version range.
	Version string

	// If this is a local chart, the path to the chart.
	LocalRef string
	// contains filtered or unexported fields
}

Locator describes the location of a Chart.

func Parse

func Parse(path string) (*Locator, error)

Parse parses a URL into a Locator.

func (*Locator) IsLocal

func (u *Locator) IsLocal() bool

IsLocal returns true if this is a local path.

func (*Locator) Local

func (u *Locator) Local() (string, error)

Local returns a local version of the path.

This will return an error if the URL does not reference a local chart.

func (*Locator) Long

func (u *Locator) Long(secure bool) (string, error)

Long returns a long-form URL.

If secure is true, this will return an HTTPS URL, otherwise HTTP.

This will return an error if the URL references a local chart.

func (*Locator) Short

func (u *Locator) Short() (string, error)

Short returns a short form URL.

This will return an error if the URL references a local chart.

type Maintainer

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

Maintainer describes a chart maintainer.

Jump to

Keyboard shortcuts

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