resources

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package resources contains functions for decoding Kubernetes resource objects from a number of different sources, in a number of different file formats. Specifically, these formats are supported: - A single resource in yaml/json format.

  • Produced by running "kubectl get" for a single resource.

- A v1.List containing multiple resources in yaml/json format.

  • Produced by running "kubectl get" for a list of resources.

- A stream of yaml/json documents.

  • Produced by running "kustomize build".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(source any, handler ResourceFunc) error

Decode decodes Kubernetes resources from the given generic source. The ResourceFunc callback is executed with each decoded resource.

Behavior notes: - If the string "" or "-" is given, resources are read from os.Stdin.

func Directory

func Directory(directory string, handler ResourceFunc) error

Directory decodes Kubernetes resources from files discovered while walking the given directory. The ResourceFunc callback is executed with each decoded resource.

Behavior notes: - Any directories named ".git" or "node_modules" are skipped. - Any files not ending with ".yaml" are skipped. - Any decoding errors are ignored.

func File

func File(filename string, handler ResourceFunc) error

File decodes Kubernetes resources from the given filename. The ResourceFunc callback is executed with each decoded resource.

func Reader

func Reader(reader io.Reader, handler ResourceFunc) error

Reader decodes Kubernetes resources from the given io.Reader. The ResourceFunc callback is executed with each decoded resource.

Types

type Resource

type Resource struct {
	// Unstructured is the decoded resource object.
	unstructured.Unstructured
	// contains filtered or unexported fields
}

Resource represents a single Kubernetes resource. It holds the original unstructured object contents, as well as (optionally) the file filename where that object was originally decoded from.

func (Resource) GetFilename

func (i Resource) GetFilename() string

GetFilename returns the filename from which this resource was originally decoded. Exists to align with the other unstructured.Unstructured helper functions.

type ResourceFunc

type ResourceFunc func(Resource)

ResourceFunc is a callback function that is passed each resource encountered while decoding.

Jump to

Keyboard shortcuts

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