helm

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package helm provides functionality for interacting with Helm charts.

This package implements operations such as chart templating, chart pulling, and dependency resolution. It abstracts away the complexities of working with Helm charts and provides a simplified interface for consumers to template, extract, and process charts.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChartPull          = errors.New("error pulling chart")
	ErrChartTemplate      = errors.New("error templating chart")
	ErrChartLoad          = errors.New("error loading chart")
	ErrChartTemplateParse = errors.New("error parsing chart template output")
)
View Source
var (
	ErrNoMatcher    = errors.New("no matcher provided")
	ErrChartExtract = errors.New("error extracting chart")
)
View Source
var (
	ErrFailedFileRead  = errors.New("failed to read file")
	ErrFailedFileWrite = errors.New("failed to write file")
	ErrFailedFileClose = errors.New("failed to close file")
	ErrIteratingTar    = errors.New("error iterating on tar reader")
)
View Source
var (
	ErrChartDependency   = errors.New("error in chart dependency")
	ErrChartWorkerFailed = errors.New("chart worker failed")
)
View Source
var (
	DefaultClient = MustNewClient(
		paths.NewStaticTempPaths(filepath.Join(os.TempDir(), "charts"), paths.NewBase64PathEncoder()),
		os.Getenv("ARGOCD_APP_PROJECT_NAME"),
	)
)

Functions

func NewNopCloser

func NewNopCloser() io.Closer

Types

type CRDGenerator

type CRDGenerator interface {
	FromPaths(paths ...string) ([]*unstructured.Unstructured, error)
}

type Chart

type Chart struct {
	Client       ChartClient
	Repos        helmrepo.Getter
	TemplateOpts *TemplateOpts
}

func NewChart

func NewChart(client ChartClient, repos helmrepo.Getter, opts *TemplateOpts) (*Chart, error)

NewChart creates a new Chart.

func (*Chart) Template

func (c *Chart) Template(ctx context.Context) ([]*unstructured.Unstructured, error)

Template templates the Helm Chart. The chart.Chart and its dependencies are pulled as needed. The rendered output is then split into individual Kubernetes objects and returned as a slice of unstructured.Unstructured.

type ChartClient

type ChartClient interface {
	Pull(ctx context.Context, chartName, repoURL, targetRevision string, repos helmrepo.Getter) (*PulledChart, error)
}

type ChartFiles

type ChartFiles struct {
	Client ChartClient

	TemplateOpts *TemplateOpts
	// contains filtered or unexported fields
}

func NewChartFiles

func NewChartFiles(
	client ChartClient,
	repos helmrepo.Getter,
	maxSize *resource.Quantity,
	opts *TemplateOpts,
) (*ChartFiles, error)

func (*ChartFiles) Dispose

func (c *ChartFiles) Dispose()

func (*ChartFiles) GetCRDFiles

func (c *ChartFiles) GetCRDFiles(gen CRDGenerator, match func(string) bool) ([]*unstructured.Unstructured, error)

func (*ChartFiles) GetCRDOutput

func (c *ChartFiles) GetCRDOutput() ([]*unstructured.Unstructured, error)

func (*ChartFiles) GetValuesJSONSchema

func (c *ChartFiles) GetValuesJSONSchema(gen JSONSchemaGenerator, match func(string) bool) ([]byte, error)

GetValuesJSONSchema pulls a Helm chart using the provided TemplateOpts, and then uses the JSONSchemaGenerator to generate a JSON Schema using one or more files from the chart. The [match] function can be used to match a subset of the pulled files in the chart directory for JSON Schema generation.

type Client

type Client struct {
	Paths          PathCacher
	RepoLock       KeyLocker
	MaxExtractSize resource.Quantity

	Project string
	Proxy   string
	NoProxy string
	// contains filtered or unexported fields
}

func MustNewClient

func MustNewClient(pc PathCacher, project string) *Client

MustNewClient runs NewClient and panics on any errors.

func NewClient

func NewClient(pc PathCacher, project string) (*Client, error)

func (*Client) CleanChartCache

func (c *Client) CleanChartCache(chart, repo, version string) error

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, chart, repo, version string, repos helmrepo.Getter) (*PulledChart, error)

Pull pulls the Helm chart and returns the path to the chart directory or .tar.gz file. Pulled charts will be stored in the injected PathCacher, and subsequent requests will try to use PathCacher rather than re-pulling the chart.

type InlineCloser

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

func (*InlineCloser) Close

func (c *InlineCloser) Close() error

type JSONSchemaGenerator

type JSONSchemaGenerator interface {
	FromPaths(paths ...string) ([]byte, error)
}

type KeyLocker

type KeyLocker interface {
	Lock(key string)
	Unlock(key string)
	RLock(key string)
	RUnlock(key string)
}

type LimitReaderUnexpectedEOFError

type LimitReaderUnexpectedEOFError struct {
	MaxSize int64
}

func (LimitReaderUnexpectedEOFError) Error

type NopCloser

type NopCloser struct{}

func (NopCloser) Close

func (NopCloser) Close() error

type PathCacher

type PathCacher interface {
	Add(key, value string)
	GetPath(key string) (string, error)
	GetPathIfExists(key string) string
	GetPaths() map[string]string
}

type PulledChart

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

PulledChart represents a Helm chart.tar.gz, or the root directory of a Helm chart. It is typically created via Client.Pull.

func (*PulledChart) Extract

func (c *PulledChart) Extract(maxSize *resource.Quantity) (string, io.Closer, error)

Extract will extract the chart (if it is a .tar.gz file), and return the path to the extracted chart. An io.Closer is also returned, calling Close() will clean up the extracted chart. If PulledChart references a directory, the the path to the directory and a NopCloser is returned.

func (*PulledChart) Load

func (c *PulledChart) Load(ctx context.Context, skipSchemaValidation bool) (*chart.Chart, error)

Load will load the Helm chart into a chart.Chart. If PulledChart references a .tar.gz, it will be loaded directly into memory without extracting the files to disk. If PulledChart references a directory, the contents of the chart will be loaded from the filesystem. No closer is returned by this method, since no temporary files are created.

type TemplateOpts

type TemplateOpts struct {
	ValuesObject         map[string]any
	Proxy                string
	TargetRevision       string
	RepoURL              string
	ReleaseName          string
	Namespace            string
	ChartName            string
	KubeVersion          string
	NoProxy              string
	APIVersions          []string
	Timeout              time.Duration
	SkipCRDs             bool
	PassCredentials      bool
	SkipSchemaValidation bool
	SkipHooks            bool
}

Jump to

Keyboard shortcuts

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