Documentation
¶
Overview ¶
Package kube contains shared kubectl-oriented helpers for CLI commands.
Index ¶
- func ApplyManifestContent[T Command](commandArgs func([]string) (T, error), manifest string) error
- func ApplyManifestContentWithNamespace[T Command](commandArgs func([]string) (T, error), manifest, namespace string) error
- func ApplyManifestFromFile[T Command](commandArgs func([]string) (T, error), file string, stdout, stderr io.Writer) error
- func EnsureNamespace[T Command](commandArgs func([]string) (T, error), name string) error
- func EnsureNamespaceWithLabels[T Command](commandArgs func([]string) (T, error), name string, labels map[string]string) error
- func NormalizePatchDocument(raw string) (string, error)
- func NormalizePatchFile(file string) (string, error)
- func ReadFileAtPath(path string) ([]byte, error)
- func ResolveRegularFilePath(file string) (string, error)
- func WriteOutputFile(file string, data []byte) error
- type Command
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyManifestContent ¶
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 ¶
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 ¶
NormalizePatchDocument parses YAML or JSON patch content and returns a JSON string suitable for kubectl patch --type=json (or merge) style inputs.
func NormalizePatchFile ¶
NormalizePatchFile reads a patch file from disk and returns normalized JSON like NormalizePatchDocument.
func ReadFileAtPath ¶
ReadFileAtPath reads a regular file without following symlink escapes outside its parent directory.
func ResolveRegularFilePath ¶
ResolveRegularFilePath resolves a path and rejects directories.
func WriteOutputFile ¶
WriteOutputFile writes data to a path under a resolved parent directory with 0600 file permissions and 0750 (or tighter) directory permissions.