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.
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 ¶
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.