deploy

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package deploy is the Go port of the domain artifact deployment (.lok8s/libs/deploy: deploy::apply / deploy::apply_filtered / deploy::_apply / deploy::wait_crds — bash wins on any divergence; the `lo destroy` half of that file stays with the provision port).

Applies the single clusters/<domain>/artifacts.yaml produced by `lo build`: CRDs first (server-side apply + wait Established), then the rest (server-side apply + scoped wait-ready). ApplyFiltered deploys only the subset carrying one label. Workload-plane ordering is intentionally not a framework primitive: kubectl handles in-manifest order, Tilt handles runtime deps at the resource level, cluster-infra ordering lives in cluster.spec.bootstrap.

Every kubectl runs through the kapply.Applier (the ported kapply::apply / kapply::wait_ready) against the AMBIENT KUBECONFIG — the caller resolves it (build.ResolveKubeconfigForDomain: a deploy domain follows its clusterRef); no --kubeconfig flag is threaded, exactly like the bash.

Index

Constants

This section is empty.

Variables

View Source
var ErrHandled = ui.ErrHandled // one sentinel for every package; see internal/ui

ErrHandled marks a failure whose [error] line was already printed.

Functions

func HasObjects

func HasObjects(stream string) bool

HasObjects reports whether a YAML stream contains at least one kubernetes object (bash: deploy::_has_objects). Empty streams (zero docs, comments only, whitespace, or only `---` separators) report false — used to skip `kubectl apply` gracefully, which fails with "error: no objects passed to apply" on an empty stream (a label-filtered subset that excludes everything is a legitimate workflow).

func ParseLabel

func ParseLabel(stderr io.Writer, label string) (key, value string, err error)

ParseLabel splits the -l/--label value into key and value (bash: main::deploy's ${label%%=*} / ${label#*=} guard). Prints the [error] line and returns ErrHandled on a missing '=', an empty key or an empty value.

Types

type Deployer

type Deployer struct {
	Paths   *config.Paths
	Applier *kapply.Applier
	// Stderr receives the [error]/[warn]/[debug] lines (default os.Stderr).
	Stderr io.Writer
}

Deployer runs the apply phases. Applier carries the runner + writers.

func (*Deployer) Apply

func (d *Deployer) Apply(ctx context.Context, domain string) error

Apply applies the domain's single artifact (bash: deploy::apply). Bash's errexit is ACTIVE on this path: the first failing kubectl apply exits the whole `lo` with kubectl's status — returned here as *ExitError.

func (*Deployer) ApplyFiltered

func (d *Deployer) ApplyFiltered(ctx context.Context, domain, labelKey, labelValue string) error

ApplyFiltered applies only the resources in the domain artifact carrying <labelKey>=<labelValue> (bash: deploy::apply_filtered). The key is used verbatim: a bare key (app) or a namespaced one (lok8s.dev/name). Selective deploy is user opt-in — it requires kustomize `labels:` (or metadata.labels) on the targets to address.

Bash runs the subset apply as `deploy::_apply … || rc=$?`, which SUSPENDS errexit inside it: a failing kubectl apply there is logged and the phase sequence continues, and the function's status is the scoped wait's (always 0). Reproduced as-is — bash wins — see the package README note in the port report.

type ExitError

type ExitError struct{ Code int }

ExitError carries a kubectl apply's exit status out of the unfiltered apply — bash's `set -e` exited the whole `lo` with that status.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) ExitCode

func (e *ExitError) ExitCode() int

ExitCode is the process exit status the error maps to.

Jump to

Keyboard shortcuts

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