manifestival

package
v0.0.0-...-dbd2aec Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

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:

  1. pathname = path to a file --> parses that file.
  2. pathname = path to a directory, recursive = false --> parses all files in that directory.
  3. pathname = path to a directory, recursive = true --> parses all files in that directory and it's descendants
  4. pathname = url --> fetches the contents of that URL and parses them as YAML.
  5. pathname = combination of all previous cases, the string can contain multiple records (file, directory or url) separated by comma

func UpdateChanged

func UpdateChanged(src, tgt map[string]interface{}) bool

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.

Types

type FilterFn

type FilterFn func(u *unstructured.Unstructured) bool

func ByNamespace

func ByNamespace(ns string) FilterFn

We assume all resources in the manifest live in the same namespace

func ByOwner

func ByOwner(owner Owner) FilterFn

type Manifest

type Manifest 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() error
	// Deletes a particular resource
	Delete(spec *unstructured.Unstructured) error
	// Retains every resource for which all FilterFn's return true
	Filter(fns ...FilterFn) Manifest
	// Returns a deep copy of the matching resource read from the file
	Find(apiVersion string, kind string, name string) *unstructured.Unstructured
	// Returns the resource fetched from the api server, nil if not found
	Get(spec *unstructured.Unstructured) (*unstructured.Unstructured, error)
	// Returns a deep copy of all resources in the manifest
	DeepCopyResources() []unstructured.Unstructured
	// Convenient list of all the resource names in the manifest
	ResourceNames() []string
}

func NewYamlManifest

func NewYamlManifest(pathname string, recursive bool, client dynamic.Interface) (Manifest, error)

type Owner

type Owner interface {
	v1.Object
	schema.ObjectKind
}

type YamlManifest

type YamlManifest struct {
	// contains filtered or unexported fields
}

func (*YamlManifest) Apply

func (f *YamlManifest) Apply(spec *unstructured.Unstructured) error

func (*YamlManifest) ApplyAll

func (f *YamlManifest) ApplyAll() error

func (*YamlManifest) DeepCopyResources

func (f *YamlManifest) DeepCopyResources() []unstructured.Unstructured

func (*YamlManifest) Delete

func (f *YamlManifest) Delete(spec *unstructured.Unstructured) error

func (*YamlManifest) DeleteAll

func (f *YamlManifest) DeleteAll() error

func (*YamlManifest) Filter

func (f *YamlManifest) Filter(fns ...FilterFn) Manifest

func (*YamlManifest) Find

func (f *YamlManifest) Find(apiVersion string, kind string, name string) *unstructured.Unstructured

func (*YamlManifest) Get

func (*YamlManifest) ResourceNames

func (f *YamlManifest) ResourceNames() []string

Jump to

Keyboard shortcuts

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