kube

package
v0.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package kube contains shared kubectl-oriented helpers for CLI commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyManifestContent

func ApplyManifestContent[T Command](commandArgs func([]string) (T, error), manifest string) error

ApplyManifestContent applies manifest YAML from a string via kubectl stdin.

func ApplyManifestContentWithNamespace

func ApplyManifestContentWithNamespace[T Command](commandArgs func([]string) (T, error), manifest, namespace string) error

ApplyManifestContentWithNamespace applies manifest YAML from stdin, optionally scoped to a namespace.

func ApplyManifestFromFile

func ApplyManifestFromFile[T Command](commandArgs func([]string) (T, error), file string, stdout, stderr io.Writer) error

ApplyManifestFromFile applies a manifest file using kubectl.

func EnsureNamespace

func EnsureNamespace[T Command](commandArgs func([]string) (T, error), name string) error

EnsureNamespace applies/creates a namespace idempotently.

func EnsureNamespaceWithLabels

func EnsureNamespaceWithLabels[T Command](commandArgs func([]string) (T, error), name string, labels map[string]string) error

EnsureNamespaceWithLabels applies/creates a namespace idempotently and sets labels via kubectl apply. Labels already present on an existing namespace are preserved unless the same key is also supplied here (kubectl apply will set them to the new value). Pass nil/empty labels for a label-less namespace.

func NormalizePatchDocument

func NormalizePatchDocument(raw string) (string, error)

NormalizePatchDocument parses YAML or JSON patch content and returns a JSON string suitable for kubectl patch --type=json (or merge) style inputs.

func NormalizePatchFile

func NormalizePatchFile(file string) (string, error)

NormalizePatchFile reads a patch file from disk and returns normalized JSON like NormalizePatchDocument.

func ReadFileAtPath

func ReadFileAtPath(path string) ([]byte, error)

ReadFileAtPath reads a regular file without following symlink escapes outside its parent directory.

func ResolveRegularFilePath

func ResolveRegularFilePath(file string) (string, error)

ResolveRegularFilePath resolves a path and rejects directories.

func WriteOutputFile

func WriteOutputFile(file string, data []byte) error

WriteOutputFile writes data to a path under a resolved parent directory with 0600 file permissions and 0750 (or tighter) directory permissions.

Types

type Command

type Command interface {
	SetStdin(io.Reader)
	SetStdout(io.Writer)
	SetStderr(io.Writer)
	Run() error
}

Command is the minimal command shape needed for stdin-based kubectl apply.

Jump to

Keyboard shortcuts

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