chart

package
v1.0.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChartReference     = BuildErrorReason{Reason: "InvalidChartReference", Summary: "invalid chart reference"}
	ErrChartPull          = BuildErrorReason{Reason: "ChartPullError", Summary: "chart pull error"}
	ErrChartMetadataPatch = BuildErrorReason{Reason: "MetadataPatchError", Summary: "chart metadata patch error"}
	ErrValuesFilesMerge   = BuildErrorReason{Reason: "ValuesFilesError", Summary: "values files merge error"}
	ErrDependencyBuild    = BuildErrorReason{Reason: "DependencyBuildError", Summary: "dependency build error"}
	ErrChartPackage       = BuildErrorReason{Reason: "ChartPackageError", Summary: "chart package error"}
	ErrChartVerification  = BuildErrorReason{Reason: "ChartVerificationError", Summary: "chart verification error"}
	ErrUnknown            = BuildErrorReason{Reason: "Unknown", Summary: "unknown build error"}
)

Functions

func IsPersistentBuildErrorReason added in v0.22.0

func IsPersistentBuildErrorReason(err error) bool

func LoadChartMetadata

func LoadChartMetadata(chartPath string) (meta *helmchart.Metadata, err error)

LoadChartMetadata attempts to load the chart.Metadata from the "Chart.yaml" file in the directory or archive at the given chartPath. It takes "requirements.yaml" files into account, and is therefore compatible with the chart.APIVersionV1 format.

func LoadChartMetadataFromArchive

func LoadChartMetadataFromArchive(archive string) (*helmchart.Metadata, error)

LoadChartMetadataFromArchive loads the chart.Metadata from the "Chart.yaml" file in the archive at the given path. It takes "requirements.yaml" files into account, and is therefore compatible with the chart.APIVersionV1 format.

func LoadChartMetadataFromDir

func LoadChartMetadataFromDir(dir string) (*helmchart.Metadata, error)

LoadChartMetadataFromDir loads the chart.Metadata from the "Chart.yaml" file in the directory at the given path. It takes "requirements.yaml" files into account, and is therefore compatible with the chart.APIVersionV1 format.

func OverwriteChartDefaultValues

func OverwriteChartDefaultValues(chart *helmchart.Chart, vals chartutil.Values) (bool, error)

OverwriteChartDefaultValues overwrites the chart default values file with the given data.

Types

type Build

type Build struct {
	// Name of the chart.
	Name string
	// Version of the chart.
	Version string
	// Path is the absolute path to the packaged chart.
	// Can be empty, in which case a failure should be assumed.
	Path string
	// ValuesFiles is the list of files used to compose the chart's
	// default "values.yaml".
	ValuesFiles []string
	// ResolvedDependencies is the number of local and remote dependencies
	// collected by the DependencyManager before building the chart.
	ResolvedDependencies int
	// Packaged indicates if the Builder has packaged the chart.
	// This can for example be false if ValuesFiles is empty and the chart
	// source was already packaged.
	Packaged bool
}

Build contains the (partial) Builder.Build result, including specific information about the built chart like ResolvedDependencies.

func (*Build) Complete added in v0.22.0

func (b *Build) Complete() bool

Complete returns if the Build completed successfully.

func (*Build) HasMetadata added in v0.22.0

func (b *Build) HasMetadata() bool

HasMetadata returns if the Build contains chart metadata.

NOTE: This may return True while the build did not Complete successfully. Which means it was able to successfully collect the metadata from the chart, but failed further into the process.

func (*Build) String

func (b *Build) String() string

String returns the Path of the Build.

func (*Build) Summary

func (b *Build) Summary() string

Summary returns a human-readable summary of the Build.

type BuildError

type BuildError struct {
	Reason BuildErrorReason
	Err    error
}

BuildError contains a wrapped Err and a Reason indicating why it occurred.

func (*BuildError) Error

func (e *BuildError) Error() string

Error returns Err as a string, prefixed with the Reason to provide context.

func (*BuildError) Is

func (e *BuildError) Is(target error) bool

Is returns true if the Reason or Err equals target. It can be used to programmatically place an arbitrary Err in the context of the Builder:

err := &BuildError{Reason: ErrChartPull, Err: errors.New("arbitrary transport error")}
errors.Is(err, ErrChartPull)

func (*BuildError) Unwrap

func (e *BuildError) Unwrap() error

Unwrap returns the underlying Err.

type BuildErrorReason

type BuildErrorReason struct {
	// Reason is the programmatic build error reason in CamelCase.
	Reason string

	// Summary is the human build error reason, used to provide
	// the Error string, and further context to the BuildError.
	Summary string
}

BuildErrorReason is the descriptive reason for a BuildError.

func (BuildErrorReason) Error

func (e BuildErrorReason) Error() string

Error returns the string representation of BuildErrorReason.

type BuildOptions

type BuildOptions struct {
	// VersionMetadata can be set to SemVer build metadata as defined in
	// the spec, and is included during packaging.
	// Ref: https://semver.org/#spec-item-10
	VersionMetadata string
	// ValuesFiles can be set to a list of relative paths, used to compose
	// and overwrite an alternative default "values.yaml" for the chart.
	ValuesFiles []string
	// CachedChart can be set to the absolute path of a chart stored on
	// the local filesystem, and is used for simple validation by metadata
	// comparisons.
	CachedChart string
	// Force can be set to force the build of the chart, for example
	// because the list of ValuesFiles has changed.
	Force bool
	// Verifier can be set to the verification of the chart.
	Verify bool
}

BuildOptions provides a list of options for Builder.Build.

func (BuildOptions) GetValuesFiles

func (o BuildOptions) GetValuesFiles() []string

GetValuesFiles returns BuildOptions.ValuesFiles, except if it equals "values.yaml", which returns nil.

type Builder

type Builder interface {
	// Build pulls and (optionally) packages a Helm chart with the given
	// Reference and BuildOptions, and writes it to p.
	// It returns the Build result, or an error.
	// It may return an error for unsupported Reference implementations.
	Build(ctx context.Context, ref Reference, p string, opts BuildOptions) (*Build, error)
}

Builder is capable of building a (specific) chart Reference.

func NewLocalBuilder

func NewLocalBuilder(dm *DependencyManager) Builder

NewLocalBuilder returns a Builder capable of building a Helm chart with a LocalReference. For chart references pointing to a directory, the DependencyManager is used to resolve missing local and remote dependencies.

func NewRemoteBuilder

func NewRemoteBuilder(repository repository.Downloader) Builder

NewRemoteBuilder returns a Builder capable of building a Helm chart with a RemoteReference in the given repository.Downloader.

type DependencyManager

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

DependencyManager manages dependencies for a Helm chart.

func NewDependencyManager

func NewDependencyManager(opts ...DependencyManagerOption) *DependencyManager

NewDependencyManager returns a new DependencyManager configured with the given DependencyManagerOption list.

func (*DependencyManager) Build

func (dm *DependencyManager) Build(ctx context.Context, ref Reference, chart *helmchart.Chart) (int, error)

Build compiles a set of missing dependencies from chart.Chart, and attempts to resolve and build them using the information from Reference. It returns the number of resolved local and remote dependencies, or an error.

func (*DependencyManager) Clear

func (dm *DependencyManager) Clear() error

Clear iterates over the downloaders, calling Clear on all items. It returns an aggregate error of all Clear errors.

type DependencyManagerOption

type DependencyManagerOption interface {
	// contains filtered or unexported methods
}

DependencyManagerOption configures an option on a DependencyManager.

type GetChartDownloaderCallback added in v0.26.0

type GetChartDownloaderCallback func(url string) (repository.Downloader, error)

GetChartDownloaderCallback must return a Downloader for the URL or an error describing why it could not be returned.

type LocalReference

type LocalReference struct {
	// WorkDir used as chroot during build operations.
	// File references are not allowed to traverse outside it.
	WorkDir string
	// Path of the chart on the local filesystem relative to WorkDir.
	Path string
}

LocalReference contains sufficient information to locate a chart on the local filesystem.

func (LocalReference) Validate

func (r LocalReference) Validate() error

Validate returns an error if the LocalReference does not have a Path set.

type Reference

type Reference interface {
	// Validate returns an error if the Reference is not valid according
	// to the spec of the interface implementation.
	Validate() error
}

Reference holds information to locate a chart.

type RemoteReference

type RemoteReference struct {
	// Name of the chart.
	Name string
	// Version of the chart.
	// Can be a Semver range, or empty for latest.
	Version string
}

RemoteReference contains sufficient information to look up a chart in a ChartRepository.

func (RemoteReference) Validate

func (r RemoteReference) Validate() error

Validate returns an error if the RemoteReference does not have a Name set.

type WithConcurrent

type WithConcurrent int64

type WithDownloaderCallback added in v0.26.0

type WithDownloaderCallback GetChartDownloaderCallback

type WithRepositories

type WithRepositories map[string]repository.Downloader

Directories

Path Synopsis
ignore
Package ignore provides tools for writing ignore files (a la .gitignore).
Package ignore provides tools for writing ignore files (a la .gitignore).

Jump to

Keyboard shortcuts

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