kapply

package
v0.52.17 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package kapply provides a pure-Go equivalent of `kubectl apply -k <dir>`, building a Kustomize stack and applying it via Server-Side Apply (SSA).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDir

func ApplyDir(ctx context.Context, dir string, c Clients, opts ...Option) error

ApplyDir builds the Kustomize stack in dir and applies all objects via SSA.

Types

type Clients

type Clients struct {
	Dynamic   dynamic.Interface
	Discovery discovery.DiscoveryInterface
	Mapper    meta.RESTMapper
}

Clients bundles the cluster interfaces this package needs.

func NewClients

func NewClients(cfg *rest.Config) (Clients, error)

NewClients creates Clients from a *rest.Config (handy if you don’t already have the dynamic/discovery/mapper wired up).

type Option

type Option func(*Options)

Option is a functional option for ApplyDir.

func WithDefaultNamespace

func WithDefaultNamespace(ns string) Option

func WithDryRun

func WithDryRun() Option

func WithFieldManager

func WithFieldManager(m string) Option

func WithForceConflicts

func WithForceConflicts(b bool) Option

func WithPreapplyKinds

func WithPreapplyKinds(kinds ...string) Option

func WithWaitAfterCRDs

func WithWaitAfterCRDs(d time.Duration) Option

type Options

type Options struct {
	// FieldManager identifies your applier in managedFields (kubectl default is "kubectl").
	FieldManager string
	// ForceConflicts mirrors `--force-conflicts` (take ownership when needed).
	ForceConflicts bool
	// DefaultNamespace fills in a namespace for namespaced resources that
	// don’t have one set by Kustomize.
	DefaultNamespace string
	// PreapplyKinds are applied in a first pass to satisfy dependencies
	// (default: Namespace, CustomResourceDefinition).
	PreapplyKinds []string
	// DryRun prints/introspects without persisting (server-side dry-run).
	DryRun bool
	// WaitAfterCRDs pauses briefly and refreshes discovery after CRDs are applied.
	WaitAfterCRDs time.Duration
}

Options controls ApplyDir behavior.

Jump to

Keyboard shortcuts

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