Documentation ¶
Index ¶
- func ApplyWithManifestDir(ctx context.Context, r *resources.Resources, dirPath, pattern string, ...) error
- func Decode(manifest io.Reader, obj k8s.Object, options ...DecodeOption) error
- func DecodeAll(ctx context.Context, manifest io.Reader, options ...DecodeOption) ([]k8s.Object, error)
- func DecodeAllFiles(ctx context.Context, fsys fs.FS, pattern string, options ...DecodeOption) ([]k8s.Object, error)
- func DecodeAny(manifest io.Reader, options ...DecodeOption) (k8s.Object, error)
- func DecodeEach(ctx context.Context, manifest io.Reader, handlerFn HandlerFunc, ...) error
- func DecodeEachFile(ctx context.Context, fsys fs.FS, pattern string, handlerFn HandlerFunc, ...) error
- func DecodeFile(fsys fs.FS, manifestPath string, obj k8s.Object, options ...DecodeOption) error
- func DecodeString(rawManifest string, obj k8s.Object, options ...DecodeOption) error
- func DeleteWithManifestDir(ctx context.Context, r *resources.Resources, dirPath, pattern string, ...) error
- type DecodeOption
- func DefaultGVK(defaults *schema.GroupVersionKind) DecodeOption
- func MutateAnnotations(overrides map[string]string) DecodeOption
- func MutateLabels(overrides map[string]string) DecodeOption
- func MutateNamespace(namespace string) DecodeOption
- func MutateOption(m MutateFunc) DecodeOption
- func MutateOwnerAnnotations(owner k8s.Object) DecodeOption
- type HandlerFunc
- func CreateHandler(r *resources.Resources, opts ...resources.CreateOption) HandlerFunc
- func CreateIgnoreAlreadyExists(r *resources.Resources, opts ...resources.CreateOption) HandlerFunc
- func DeleteHandler(r *resources.Resources, opts ...resources.DeleteOption) HandlerFunc
- func DeleteIgnoreNotFound(r *resources.Resources, opts ...resources.DeleteOption) HandlerFunc
- func IgnoreErrorHandler(handler HandlerFunc, errorMatcher func(err error) bool) HandlerFunc
- func NoopHandler(_ *resources.Resources, _ ...resources.DeleteOption) HandlerFunc
- func ReadHandler(r *resources.Resources, handler HandlerFunc) HandlerFunc
- func UpdateHandler(r *resources.Resources, opts ...resources.UpdateOption) HandlerFunc
- type MutateFunc
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyWithManifestDir ¶ added in v0.0.7
func ApplyWithManifestDir(ctx context.Context, r *resources.Resources, dirPath, pattern string, createOptions []resources.CreateOption, options ...DecodeOption) error
ApplyWithManifestDir resolves all the files in the Directory dirPath against the globbing pattern and creates a kubernetes resource for each of the resources found under the manifest directory.
func Decode ¶
Decode a single-document YAML or JSON file into the provided object. Patches are applied after decoding to the object to update the loaded resource.
func DecodeAll ¶
func DecodeAll(ctx context.Context, manifest io.Reader, options ...DecodeOption) ([]k8s.Object, error)
DecodeAll is a stream of documents of any Kind using either the innate typing of the scheme. Falls back to the unstructured.Unstructured type if a matching type cannot be found for the Kind. Options may be provided to configure the behavior of the decoder.
func DecodeAllFiles ¶
func DecodeAllFiles(ctx context.Context, fsys fs.FS, pattern string, options ...DecodeOption) ([]k8s.Object, error)
DecodeAllFiles resolves files at the filesystem matching the pattern, decoding JSON or YAML files. Supports multi-document files. Falls back to the unstructured.Unstructured type if a matching type cannot be found for the Kind. Options may be provided to configure the behavior of the decoder.
func DecodeAny ¶
DecodeAny decodes any single-document YAML or JSON input using either the innate typing of the scheme. Falls back to the unstructured.Unstructured type if a matching type cannot be found for the Kind. Options may be provided to configure the behavior of the decoder.
func DecodeEach ¶
func DecodeEach(ctx context.Context, manifest io.Reader, handlerFn HandlerFunc, options ...DecodeOption) error
DecodeEach a stream of documents of any Kind using either the innate typing of the scheme. Falls back to the unstructured.Unstructured type if a matching type cannot be found for the Kind.
If handlerFn returns an error, decoding is halted. Options may be provided to configure the behavior of the decoder.
func DecodeEachFile ¶
func DecodeEachFile(ctx context.Context, fsys fs.FS, pattern string, handlerFn HandlerFunc, options ...DecodeOption) error
DecodeEachFile resolves files at the filesystem matching the pattern, decoding JSON or YAML files. Supports multi-document files.
If handlerFn returns an error, decoding is halted. Options may be provided to configure the behavior of the decoder.
func DecodeFile ¶
DecodeFile decodes a single-document YAML or JSON file into the provided object. Patches are applied after decoding to the object to update the loaded resource.
func DecodeString ¶
func DecodeString(rawManifest string, obj k8s.Object, options ...DecodeOption) error
DecodeString decodes a single-document YAML or JSON string into the provided object. Patches are applied after decoding to the object to update the loaded resource.
func DeleteWithManifestDir ¶ added in v0.0.7
func DeleteWithManifestDir(ctx context.Context, r *resources.Resources, dirPath, pattern string, deleteOptions []resources.DeleteOption, options ...DecodeOption) error
DeleteWithManifestDir does the reverse of ApplyUsingManifestDir does. This will resolve all files in the dirPath against the pattern and then delete those kubernetes resources found under the manifest directory.
Types ¶
type DecodeOption ¶
type DecodeOption func(*Options)
DecodeOption is a function that alters the configuration Options used to decode and optionally mutate objects via MutateFuncs
func DefaultGVK ¶
func DefaultGVK(defaults *schema.GroupVersionKind) DecodeOption
DefaultGVK instructs the decoder to use the given type to look up the appropriate Go type to decode into instead of its default behavior of deciding this by decoding the Group, Version, and Kind fields.
func MutateAnnotations ¶
func MutateAnnotations(overrides map[string]string) DecodeOption
MutateAnnotations is an optional parameter to decoding functions that will patch an objects metadata.annotations
func MutateLabels ¶
func MutateLabels(overrides map[string]string) DecodeOption
MutateLabels is an optional parameter to decoding functions that will patch an objects metadata.labels
func MutateNamespace ¶
func MutateNamespace(namespace string) DecodeOption
MutateNamespace is an optional parameter to decoding functions that will patch objects with the given namespace name
func MutateOption ¶
func MutateOption(m MutateFunc) DecodeOption
MutateOption can be used to add a custom MutateFunc to the DecodeOption used to configure the decoding of objects
func MutateOwnerAnnotations ¶
func MutateOwnerAnnotations(owner k8s.Object) DecodeOption
MutateOwnerAnnotations is an optional parameter to decoding functions that will patch objects using the given owner object
type HandlerFunc ¶
HandlerFunc is a function executed after an object has been decoded and patched. If an error is returned, further decoding is halted.
func CreateHandler ¶
func CreateHandler(r *resources.Resources, opts ...resources.CreateOption) HandlerFunc
CreateHandler returns a HandlerFunc that will create objects
func CreateIgnoreAlreadyExists ¶
func CreateIgnoreAlreadyExists(r *resources.Resources, opts ...resources.CreateOption) HandlerFunc
CreateIgnoreAlreadyExists returns a HandlerFunc that will create objects if they do not already exist
func DeleteHandler ¶
func DeleteHandler(r *resources.Resources, opts ...resources.DeleteOption) HandlerFunc
DeleteHandler returns a HandlerFunc that will delete objects
func DeleteIgnoreNotFound ¶
func DeleteIgnoreNotFound(r *resources.Resources, opts ...resources.DeleteOption) HandlerFunc
DeleteIgnoreNotFound returns a HandlerFunc that will delete objects if they do not already exist
func IgnoreErrorHandler ¶
func IgnoreErrorHandler(handler HandlerFunc, errorMatcher func(err error) bool) HandlerFunc
IgnoreErrorHandler returns a HandlerFunc that will ignore the provided error if the errorMatcher returns true
func NoopHandler ¶
func NoopHandler(_ *resources.Resources, _ ...resources.DeleteOption) HandlerFunc
NoopHandler returns a Handler func that only returns nil
func ReadHandler ¶
func ReadHandler(r *resources.Resources, handler HandlerFunc) HandlerFunc
ReadHandler returns a HandlerFunc that will use the provided object's Kind / Namespace / Name to retrieve the current state of the object using the provided Resource client. This helper makes it easy to use a stale reference to an object to retrieve its current version.
func UpdateHandler ¶
func UpdateHandler(r *resources.Resources, opts ...resources.UpdateOption) HandlerFunc
UpdateHandler returns a HandlerFunc that will update objects
type MutateFunc ¶
MutateFunc is a function executed after an object is decoded to alter its state in a pre-defined way, and can be used to apply defaults. Returning an error halts decoding of any further objects.
type Options ¶
type Options struct { DefaultGVK *schema.GroupVersionKind MutateFuncs []MutateFunc }
Options are a set of configurations used to instruct the decoding process and otherwise alter the output of decoding operations.