helm

package
v0.0.0-...-a5a3bde Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ChartNameTemplate is the template for generated chart names
	ChartNameTemplate = "%s-%s"

	// ReleaseNameTemplate is the template for Helm release names
	ReleaseNameTemplate = "%s-%s"

	// TempChartPrefix is the prefix for temporary chart directories
	TempChartPrefix = "deployah-chart-"

	// ChartYamlTemplate is the template file name for Chart.yaml
	ChartYamlTemplate = "Chart.yaml.gotmpl"

	// ValuesYamlFile is the name of the values file
	ValuesYamlFile = "values.yaml"
)

Chart and Template Constants

Variables

View Source
var ChartTemplateFS embed.FS

Embed the embedded chart directory. We renamed underscore-prefixed templates so they are included by directory embedding without explicit listing.

Functions

func CleanupExpiredCharts

func CleanupExpiredCharts()

CleanupExpiredCharts removes expired chart cache entries

func ClearChartCache

func ClearChartCache() error

ClearChartCache clears all cached charts and removes their directories

func CreateChartCopy

func CreateChartCopy(sourcePath string) (string, error)

CreateChartCopy creates a copy of a cached chart directory to avoid conflicts

func GenerateCacheKey

func GenerateCacheKey(manifest *manifest.Manifest) (string, error)

GenerateCacheKey creates a comprehensive cache key that includes both manifest and chart template hashes

func GenerateReleaseName

func GenerateReleaseName(projectName, environmentName string) string

GenerateReleaseName returns the Helm release name derived from project and environment. Format: PROJECT_NAME-ENVIRONMENT_NAME

func GetCachedChart

func GetCachedChart(cacheKey string) (string, bool)

GetCachedChart retrieves a cached chart if it exists and is valid

func GetChartCacheStats

func GetChartCacheStats() (count int, totalSize int64)

GetChartCacheStats returns statistics about the chart cache

func MapManifestToChartValues

func MapManifestToChartValues(m *manifest.Manifest, desiredEnvironment string) (map[string]any, error)

func PrepareChart

func PrepareChart(ctx context.Context, manifest *manifest.Manifest, desiredEnvironment string) (string, error)

PrepareChart expands the embedded chart into a temporary directory, rendering any files with the .gotmpl suffix using Go templates and Sprig functions. It returns the root directory path of the prepared chart. Uses caching to avoid regenerating identical charts.

func SetCachedChart

func SetCachedChart(cacheKey, chartPath string)

SetCachedChart stores a chart path in the cache

Types

type ChartCache

type ChartCache struct {
	Path      string
	CreatedAt time.Time
}

ChartCache represents a cached chart entry

type ChartCacheInfo

type ChartCacheInfo struct {
	Count     int      `json:"count"`
	TotalSize int64    `json:"totalSize"`
	ChartHash string   `json:"chartHash"`
	TTL       string   `json:"ttl"`
	CacheKeys []string `json:"cacheKeys,omitempty"`
}

ChartCacheInfo provides detailed information about the chart cache

func GetChartCacheInfo

func GetChartCacheInfo() (*ChartCacheInfo, error)

GetChartCacheInfo returns detailed information about the chart cache

type ChartData

type ChartData struct {
	Chart struct {
		Name        string
		Description string
		Version     string
		AppVersion  string
	}
	Values   map[string]any     // For values.yaml templating
	Manifest *manifest.Manifest // Added for dynamic sub-charts
}

ChartData holds the values to substitute in the templates, including arbitrary values for values.yaml .Values can be used in values.yaml.gotmpl for flexible templating You can add more fields for project, component, etc.

type Client

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

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient initializes Helm action configuration with functional options. Default storage driver is "secret" if not specified. Default timeout is 5 minutes if not specified.

func (*Client) DeleteRelease

func (c *Client) DeleteRelease(ctx context.Context, project, environment string) error

DeleteRelease uninstalls the given release.

func (*Client) GetRelease

func (c *Client) GetRelease(ctx context.Context, project, environment string) (*v1.Release, error)

func (*Client) GetReleaseHistory

func (c *Client) GetReleaseHistory(ctx context.Context, project, environment string) ([]*v1.Release, error)

GetReleaseHistory returns the history of a specific release.

func (*Client) InstallApp

func (c *Client) InstallApp(ctx context.Context, manifest *manifest.Manifest, environment string, dryRun bool) error

InstallApp installs or upgrades the app using the embedded chart.

func (*Client) ListReleases

func (c *Client) ListReleases(ctx context.Context, selector labels.Selector) ([]*v1.Release, error)

ListReleases returns detailed information about releases in the current namespace.

func (*Client) RollbackRelease

func (c *Client) RollbackRelease(ctx context.Context, releaseName string, revision int, timeout time.Duration) error

RollbackRelease rolls back a release to a previous revision.

type Option

type Option func(*Client)

Option is a functional option for configuring the Helm client

func WithDebug

func WithDebug(keep bool) Option

WithDebug controls whether to keep temporary chart directories.

func WithKubeconfig

func WithKubeconfig(kubeconfig string) Option

WithKubeconfig sets the path to the kubeconfig file

func WithNamespace

func WithNamespace(namespace string) Option

WithNamespace sets the Kubernetes namespace for Helm operations

func WithStorageDriver

func WithStorageDriver(driver string) Option

WithStorageDriver sets the Helm storage driver (secret, configmap, or memory)

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the default timeout for Helm operations

Jump to

Keyboard shortcuts

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