release

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package release adapts nelmwave's plan to the nelm deploy engine. The Applier interface keeps the graph executor independent of nelm so it can be faked in tests; NelmApplier is the real implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applier

type Applier interface {
	Install(ctx context.Context, s Spec) error
	Uninstall(ctx context.Context, s Spec) error
	// Plan computes the changes an install would make, without applying them.
	Plan(ctx context.Context, s Spec, o PlanOptions) (changed bool, err error)
}

Applier installs, uninstalls and plans releases through a deploy engine.

type DiffOptions

type DiffOptions struct {
	// ShowVerbose prints the whole manifest of a resource that is created or
	// deleted outright, instead of a "<hidden verbose changes>" placeholder.
	// nelm's own CLI defaults this to true; DefaultDiffOptions matches it.
	ShowVerbose bool
	// ShowVerboseCRD does the same for CRDs, which are kept separate because
	// their manifests are large enough to drown the rest of the diff.
	ShowVerboseCRD bool
	// ShowInsignificant keeps helm.sh/werf.io annotations and managedFields in
	// the compared manifests. Without it a change confined to them shows up as
	// "<hidden insignificant changes>".
	ShowInsignificant bool
	// ShowSensitive prints the contents of Secrets and resources marked
	// werf.io/sensitive in the clear. Local debugging only — this lands in CI
	// logs otherwise.
	ShowSensitive bool
	// ContextLines is the unified-diff context size (0 leaves nelm's 3).
	ContextLines int
}

DiffOptions control how planned changes are rendered. They describe the view, not the release, so they come from the command line rather than the manifest.

func DefaultDiffOptions

func DefaultDiffOptions() DiffOptions

DefaultDiffOptions is the view nelm's CLI shows by default.

type KubeConnection

type KubeConnection struct {
	// ConfigPaths are kubeconfig files in precedence order; ConfigBase64 is a
	// whole kubeconfig passed by value instead. Empty means the usual client-go
	// default: $KUBECONFIG if set, ~/.kube/config otherwise (see
	// ConfigPathPrecedence).
	ConfigPaths  []string
	ConfigBase64 string
	// ContextCluster / ContextUser override the cluster and user of the selected
	// context.
	ContextCluster string
	ContextUser    string

	// APIServer and friends describe the cluster without a kubeconfig.
	APIServer     string
	TLSServerName string
	SkipTLSVerify bool
	CAPath        string
	CAData        string
	CertPath      string
	CertData      string
	KeyPath       string
	KeyData       string
	TokenData     string
	TokenPath     string
	BasicUsername string
	BasicPassword string
	ProxyURL      string

	// Impersonation: act as another user (kubectl --as).
	ImpersonateUser   string
	ImpersonateGroups []string
	ImpersonateUID    string

	// Client-side limits. Zero leaves nelm's defaults.
	QPSLimit       int
	BurstLimit     int
	RequestTimeout time.Duration
}

KubeConnection is how to reach the cluster: either a kubeconfig to read, or the connection details spelled out directly — which is what CI has, where the credentials arrive as a token and a CA in the environment rather than as a file.

The current context is not here; it comes from the release's uniqname (see Spec.KubeContext), so it varies per release while everything else does not.

func (KubeConnection) ConfigPathPrecedence

func (k KubeConnection) ConfigPathPrecedence() []string

ConfigPathPrecedence is the list of kubeconfig files to read, in precedence order. An explicit --kube-config wins, with ":"-separated entries split like kubectl splits them; with no flag, client-go's own rules apply — $KUBECONFIG if set, ~/.kube/config otherwise.

Resolving the fallback here rather than leaving the list empty is the point: nelm defaults an empty list to ~/.kube/config and never looks at $KUBECONFIG, so an empty list would silently deploy to whatever the home kubeconfig's current-context happens to be — a live cluster, while the environment pointed at a throwaway one. The paths also have to be the same ones nelm reads, or namespace metadata and releases would land in different clusters.

func (KubeConnection) ContextNames

func (k KubeConnection) ContextNames() []string

ContextNames lists the contexts of the resolved kubeconfig, sorted. It is for shell completion, so a broken or absent kubeconfig yields nothing rather than an error — nothing to complete is a fine answer there.

func (KubeConnection) RESTConfig

func (k KubeConnection) RESTConfig(currentContext string) (*rest.Config, error)

RESTConfig builds the client configuration nelmwave uses for its own cluster calls (namespace metadata).

type NelmApplier

type NelmApplier struct {
	// LogLevel is nelmwave's own log level (debug|info|warn|error), passed
	// through so that nelm's output follows --log-level too. Empty means info.
	LogLevel string
}

NelmApplier is the production Applier backed by github.com/werf/nelm.

func (NelmApplier) Install

func (a NelmApplier) Install(ctx context.Context, s Spec) error

Install deploys or upgrades a release via action.ReleaseInstall, first making sure the namespace carries any declared metadata.

func (NelmApplier) Plan

func (a NelmApplier) Plan(ctx context.Context, s Spec, o PlanOptions) (bool, error)

Plan computes an install diff via action.ReleasePlanInstall without applying. With errorIfChanges, nelm returns a changes-planned sentinel when a diff exists; Plan translates that into changed=true, err=nil.

func (NelmApplier) Uninstall

func (a NelmApplier) Uninstall(ctx context.Context, s Spec) error

Uninstall removes a release via action.ReleaseUninstall.

type PlanOptions

type PlanOptions struct {
	// ErrorIfChanges makes Plan report planned changes through its changed
	// return value instead of letting nelm turn them into an error.
	ErrorIfChanges bool
	// Diff controls how the changes are rendered.
	Diff DiffOptions
}

PlanOptions are the per-invocation knobs of Plan.

type Spec

type Spec struct {
	// Name / Namespace / KubeContext identify the release (from its uniqname).
	Name        string
	Namespace   string
	KubeContext string
	// Kube is how to reach the cluster — a kubeconfig, or the connection spelled
	// out directly. Shared by every release of a run; only KubeContext varies.
	Kube KubeConnection

	// Chart is the resolved chart reference (chart name for a helm repo, oci://
	// URL for OCI, or a local path), ChartVersion its version.
	Chart        string
	ChartVersion string
	// ValuesFiles are absolute paths to values files, in merge order.
	ValuesFiles []string
	// SetJSON are inline overrides in nelm's "key=json" form (type-preserving),
	// applied on top of ValuesFiles.
	SetJSON []string

	// Chart-repository connection (helm repos). RepoURL empty means the chart is
	// OCI or local and needs no repo lookup.
	RepoURL       string
	RepoUsername  string
	RepoPassword  string
	RepoSkipTLS   bool
	RepoPassCreds bool
	RepoCAFile    string
	// RepoCertFile / RepoKeyFile are the client certificate for mTLS to the
	// repository; RepoOCIPlainHTTP drops TLS altogether (http:// registries).
	RepoCertFile     string
	RepoKeyFile      string
	RepoOCIPlainHTTP bool
	// RepoSkipUpdate stops the chart's declared dependencies from being
	// refreshed before they are pulled.
	RepoSkipUpdate bool
	// RepoRequestTimeout bounds a single request to the repository (0 = none).
	RepoRequestTimeout time.Duration
	// RegistryConfigPath is a Docker config.json with OCI registry credentials
	// (empty falls back to nelm's default, ~/.docker/config.json).
	RegistryConfigPath string
	// ProvenanceStrategy / ProvenanceKeyring control verification of the chart's
	// PGP signature. Empty strategy leaves nelm's default ("never").
	ProvenanceStrategy string
	ProvenanceKeyring  string

	// Timeout bounds the operation (0 = no timeout).
	Timeout time.Duration
	// CreateNamespace creates the namespace if missing (install only).
	CreateNamespace bool
	// DeleteNamespace deletes the namespace after the release is removed
	// (uninstall only), along with anything else that happens to live in it.
	DeleteNamespace bool
	// NamespaceAnnotations / NamespaceLabels are merged onto the namespace object
	// before the release is applied, so policy labels (pod-security,
	// istio-injection) are in place by the time workloads land. Metadata not
	// listed here is left alone.
	NamespaceAnnotations map[string]string
	NamespaceLabels      map[string]string
	// AutoRollback rolls back to the last deployed revision on failure (install only).
	AutoRollback bool

	// Labels are the release's manifest labels. Besides selection they are put
	// on the release storage object (Secret/ConfigMap), so a release can be
	// found in the cluster by the same labels it is selected by. Helm's own
	// name/owner/status/version are applied after these and win on collision.
	Labels map[string]string
	// Annotations are stored inside each revision of the release (nelm's
	// ReleaseInfoAnnotations), not on any Kubernetes object, so they cannot be
	// selected on — they are read back with `nelm release get`.
	Annotations map[string]string

	// ForceAdoption takes over resources claimed by another Helm release.
	ForceAdoption bool
	// RemoveManualChanges reclaims manually added fields (nelm's
	// NoRemoveManualChanges = !RemoveManualChanges).
	RemoveManualChanges bool
	// InstallCRDs installs the chart's crds/ directory (nelm's
	// NoInstallStandaloneCRDs = !InstallCRDs).
	InstallCRDs bool
	// DeletePropagation is the default deletion strategy (empty = nelm's
	// Foreground).
	DeletePropagation string
	// HistoryLimit caps stored revisions (0 = nelm's default of 10).
	HistoryLimit int
	// StorageDriver / StorageSQLConnection say where the release's state lives,
	// resolved from the manifest's driverURL. Empty driver = nelm's default.
	StorageDriver        string
	StorageSQLConnection string
}

Spec is the resolved, engine-agnostic description of one release operation.

Jump to

Keyboard shortcuts

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