Documentation ¶
Index ¶
- func Parse(pathname string, recursive bool) ([]unstructured.Unstructured, error)
- func UpdateChanged(src, tgt map[string]interface{}) bool
- type Manifest
- func (f *Manifest) Apply(spec *unstructured.Unstructured) error
- func (f *Manifest) ApplyAll() error
- func (f *Manifest) Delete(spec *unstructured.Unstructured, opts ...client.DeleteOption) error
- func (f *Manifest) DeleteAll(opts ...client.DeleteOption) error
- func (f *Manifest) Get(spec *unstructured.Unstructured) (*unstructured.Unstructured, error)
- func (f *Manifest) Transform(fns ...Transformer) error
- type Manifestival
- type Owner
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(pathname string, recursive bool) ([]unstructured.Unstructured, error)
Parse parses YAML files into Unstructured objects.
It supports 5 cases today:
- pathname = path to a file --> parses that file.
- pathname = path to a directory, recursive = false --> parses all files in that directory.
- pathname = path to a directory, recursive = true --> parses all files in that directory and it's descendants
- pathname = url --> fetches the contents of that URL and parses them as YAML.
- pathname = combination of all previous cases, the string can contain multiple records (file, directory or url) separated by comma
func UpdateChanged ¶
UpdateChanged recursively merges JSON-style values in `src` into `tgt`.
We need to preserve the top-level target keys, specifically 'metadata.resourceVersion', 'spec.clusterIP', and any existing entries in a ConfigMap's 'data' field. So we only overwrite fields set in our src resource. TODO: Use Patch instead
Types ¶
type Manifest ¶
type Manifest struct { Resources []unstructured.Unstructured // contains filtered or unexported fields }
Manifest tracks a set of concrete resources which should be managed as a group using a Kubernetes client provided by `NewManifest`.
func FromResources ¶
func FromResources(resources []unstructured.Unstructured, client client.Client) (Manifest, error)
func NewManifest ¶
NewManifest creates a Manifest from a comma-separated set of yaml files or directories (and subdirectories if the `recursive` option is set). The Manifest will be evaluated using the supplied `client` against a particular Kubernetes apiserver.
func (*Manifest) Apply ¶
func (f *Manifest) Apply(spec *unstructured.Unstructured) error
Apply updates or creates a particular resource, which does not need to be part of `Resources`, and will not be tracked.
func (*Manifest) Delete ¶
func (f *Manifest) Delete(spec *unstructured.Unstructured, opts ...client.DeleteOption) error
Delete removes the specified objects, which do not need to be registered as `Resources` in the Manifest.
func (*Manifest) DeleteAll ¶
func (f *Manifest) DeleteAll(opts ...client.DeleteOption) error
DeleteAll removes all tracked `Resources` in the Manifest.
func (*Manifest) Get ¶
func (f *Manifest) Get(spec *unstructured.Unstructured) (*unstructured.Unstructured, error)
Get collects a full resource body (or `nil`) from a partial resource supplied in `spec`.
func (*Manifest) Transform ¶
func (f *Manifest) Transform(fns ...Transformer) error
Transform applies an ordered set of Transformer functions to the `Resources` in this Manifest. If an error occurs, no resources are transformed.
type Manifestival ¶
type Manifestival interface { // Either updates or creates all resources in the manifest ApplyAll() error // Updates or creates a particular resource Apply(*unstructured.Unstructured) error // Deletes all resources in the manifest DeleteAll(opts ...client.DeleteOption) error // Deletes a particular resource Delete(spec *unstructured.Unstructured, opts ...client.DeleteOption) error // Returns a copy of the resource from the api server, nil if not found Get(spec *unstructured.Unstructured) (*unstructured.Unstructured, error) // Transforms the resources within a Manifest Transform(fns ...Transformer) error }
Manifestival allows group application of a set of Kubernetes resources (typically, a set of YAML files, aka a manifest) against a Kubernetes apiserver.
type Owner ¶
type Owner interface { v1.Object schema.ObjectKind }
Owner is a partial Kubernetes metadata schema.
type Transformer ¶
type Transformer func(u *unstructured.Unstructured) error
Transformer transforms a resource from the manifest in place.
func InjectNamespace ¶
func InjectNamespace(ns string) Transformer
InjectNamespace creates a Transformer which adds a namespace to existing resources if appropriate. We assume all resources in the manifest live in the same namespace.
func InjectOwner ¶
func InjectOwner(owner Owner) Transformer
InjectOwner creates a Tranformer which adds an OwnerReference pointing to `owner` to namespace-scoped objects.