Help us shape the future of Go! Take the 2026 Go Developer Survey

cluster

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(ctx context.Context, cfg ClusterConfig, out io.Writer) error

Create sets up a local kind development cluster with the configured components. This is the Go equivalent of hack/cluster.sh + hack/binaries.sh + hack/registry.sh.

func Delete

func Delete(ctx context.Context, cfg ClusterConfig, out io.Writer) error

Delete removes a func-managed dev cluster. The in-cluster registry is destroyed automatically with the Kind cluster. Host-side trust config (insecure-registries) is only reverted when this is the last func cluster, since other surviving clusters share the same host entry.

Delete is safe when nothing is tracked (empty List / no kubeconfig): it still runs empty-list host-trust teardown and returns nil (idempotent, rm -f style). kind-delete failures are only warned when a kubeconfig was present — otherwise every empty-system delete would print a scary "failed to delete cluster" for a cluster that never existed.

func List

func List() []string

List returns the names of func-managed clusters on this host — those with a kubeconfig under <config.Dir()>/clusters/<name>.local/. Kind clusters created outside func (e.g. via `kind create cluster` directly) are not included; this is intentional so that `func cluster delete foo` can't accidentally remove an unrelated kind cluster, and so the list reflects only what this tool manages.

No error return: a missing/unreadable clusters directory means "none", which is the correct answer for a fresh system.

Types

type ClusterConfig

type ClusterConfig struct {
	// Cluster identity
	Name   string // Cluster name (default: "func")
	Domain string // DNS domain for services (default: "localtest.me")

	// Component toggles
	Serving  bool // Install Knative Serving (default: true)
	Eventing bool // Install Knative Eventing (default: true)
	Tekton   bool // Install Tekton + PAC (default: false)
	Keda     bool // Install KEDA + HTTP add-on (default: false)

	// Operational
	Retries   int    // Max allocation attempts (default: 1)
	Namespace string // K8s namespace for RBAC bindings (default: "default")

	// ContainerEngineOverride, when non-empty, is returned verbatim by
	// ContainerEngine(). Empty means "auto-detect".
	// The CLI wires --container-engine into this field.
	ContainerEngineOverride string

	// PAC
	PacHost string // PAC controller hostname (default: "pac-ctr.localtest.me")

	// Skip flags
	SkipBinaries       bool // Skip binary downloads
	SkipRegistryConfig bool // Skip host registry configuration
	NoCleanup          bool // Don't delete cluster on failure

	// Optional tool path overrides. When non-empty, the kubectl/kind/act
	// accessors return the override verbatim; otherwise they resolve via
	// BinDir then PATH. The CLI samples FUNC_TEST_<TOOL> env vars into
	// these fields; the library itself never reads the environment.
	KubectlOverride string
	KindOverride    string
	ActOverride     string

	// CI detection
	GitHubActions bool // Auto-detected from GITHUB_ACTIONS env
}

ClusterConfig holds all configuration for cluster create/delete operations.

func (ClusterConfig) Act added in v0.51.0

func (c ClusterConfig) Act() string

Act returns the resolved path to the act binary (nektos/act). Prefer managed BinDir (func cluster create install), then PATH. Exported so callers outside this package (e.g. e2e) share resolution.

func (ClusterConfig) BinDir

func (c ClusterConfig) BinDir() string

BinDir returns the directory where managed tool binaries live: <config.Dir()>/bin. Derived on-demand so callers that mutate Name don't need to remember to refresh anything.

func (ClusterConfig) ContainerEngine

func (c ClusterConfig) ContainerEngine() string

ContainerEngine returns the container engine to use: the override if set, otherwise auto-detected. Called once per engine invocation rather than memoized because the auto-detect cost is trivial compared to the kind/kubectl work each call precedes.

Auto-detection mirrors hack/common.sh:

  1. If docker is on PATH, use it — but detect the podman-docker wrapper (`/usr/bin/docker` shimmed to exec podman) by inspecting `docker --version`; if it reports podman, switch to podman so downstream podman-specific workarounds fire.
  2. Otherwise, use podman if present.
  3. Otherwise, fall back to "docker" (callers will surface a clearer error when they try to exec it).

func (ClusterConfig) Kubeconfig

func (c ClusterConfig) Kubeconfig() string

Kubeconfig returns the kubeconfig path for this cluster: <config.Dir()>/clusters/<Name>.local/kubeconfig.yaml.

Jump to

Keyboard shortcuts

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