Documentation
¶
Index ¶
- Variables
- type ApplyOption
- type ApplyOptions
- type Client
- type DeleteOption
- type DeleteOptions
- type FieldManager
- type GracePeriodSeconds
- type IgnoreNotFound
- type LessFunc
- type Manifest
- func (m Manifest) Append(mfs ...Manifest) Manifest
- func (m Manifest) Apply(ctx context.Context, opts ...ApplyOption) error
- func (m Manifest) Delete(ctx context.Context, opts ...DeleteOption) error
- func (m Manifest) DryRun(ctx context.Context) ([]MergePatch, error)
- func (m Manifest) Filter(preds ...Predicate) Manifest
- func (m Manifest) Resources() []unstructured.Unstructured
- func (m Manifest) Sort(lessFunc LessFunc) Manifest
- func (m Manifest) Transform(fns ...Transformer) (Manifest, error)
- type Manifestival
- type MergePatch
- type Option
- type Overwrite
- type Owner
- type Path
- type Preconditions
- type Predicate
- func All(preds ...Predicate) Predicate
- func Any(preds ...Predicate) Predicate
- func ByAnnotation(annotation, value string) Predicate
- func ByGVK(gvk schema.GroupVersionKind) Predicate
- func ByKind(kind string) Predicate
- func ByLabel(label, value string) Predicate
- func ByLabels(labels map[string]string) Predicate
- func ByName(name string) Predicate
- func In(manifest Manifest) Predicate
- func Not(pred Predicate) Predicate
- type PropagationPolicy
- type Recursive
- type Slice
- type Source
- type Transformer
Constants ¶
This section is empty.
Variables ¶
var ( Everything = All() Nothing = Any() )
var CRDs = ByKind("CustomResourceDefinition")
CRDs returns only CustomResourceDefinitions
var DryRunAll = dryRunAll{}
Indicates that changes should not be persisted
var NoCRDs = Not(CRDs)
NoCRDs returns no CustomResourceDefinitions
Functions ¶
This section is empty.
Types ¶
type ApplyOption ¶
type ApplyOption interface {
ApplyWith(*ApplyOptions)
}
Functional options pattern
type ApplyOptions ¶
type ApplyOptions struct {
ForCreate *metav1.CreateOptions
ForUpdate *metav1.UpdateOptions
Overwrite bool
}
func ApplyWith ¶
func ApplyWith(options []ApplyOption) *ApplyOptions
type Client ¶
type Client interface {
Create(ctx context.Context, obj *unstructured.Unstructured, options ...ApplyOption) error
Update(ctx context.Context, obj *unstructured.Unstructured, options ...ApplyOption) error
Delete(ctx context.Context, obj *unstructured.Unstructured, options ...DeleteOption) error
Get(ctx context.Context, obj *unstructured.Unstructured) (*unstructured.Unstructured, error)
}
Client includes the operations required by the Manifestival interface
type DeleteOption ¶
type DeleteOption interface {
DeleteWith(*DeleteOptions)
}
type DeleteOptions ¶
type DeleteOptions struct {
ForDelete *metav1.DeleteOptions
IgnoreNotFound bool // default to true in DeleteWith()
}
func DeleteWith ¶
func DeleteWith(options []DeleteOption) *DeleteOptions
type FieldManager ¶
type FieldManager string
FieldManager is the name of the actor applying changes
func (FieldManager) ApplyWith ¶
func (f FieldManager) ApplyWith(opts *ApplyOptions)
type GracePeriodSeconds ¶
type GracePeriodSeconds int64
The duration in seconds before the object should be deleted
func (GracePeriodSeconds) DeleteWith ¶
func (g GracePeriodSeconds) DeleteWith(opts *DeleteOptions)
type IgnoreNotFound ¶
type IgnoreNotFound bool
Whether to error when deleting a non-existent resource [true]
func (IgnoreNotFound) DeleteWith ¶
func (i IgnoreNotFound) DeleteWith(opts *DeleteOptions)
type LessFunc ¶
type LessFunc func(a, b unstructured.Unstructured) bool
LessFunc is a comparison function that returns true if resource a should be ordered before resource b. It follows the same convention as Go's sort package comparison functions.
func ByKindPriority ¶
func ByKindPriority() LessFunc
type Manifest ¶
type Manifest struct {
Client Client
// contains filtered or unexported fields
}
Manifest tracks a set of concrete resources which should be managed as a group using a Kubernetes client
func ManifestFrom ¶
ManifestFrom creates a Manifest from any Source implementation
func NewManifest ¶
NewManifest creates a Manifest from a comma-separated set of YAML files, directories, or URLs. It's equivalent to `ManifestFrom(Path(pathname))`
func (Manifest) Append ¶
Append creates a new Manifest by appending the resources from other Manifests onto this one. No equality checking is done, so for any resources sharing the same GVK+name, the last one will "win".
func (Manifest) Apply ¶
func (m Manifest) Apply(ctx context.Context, opts ...ApplyOption) error
Apply updates or creates all resources in the manifest.
func (Manifest) Delete ¶
func (m Manifest) Delete(ctx context.Context, opts ...DeleteOption) error
Delete removes all resources in the Manifest
func (Manifest) DryRun ¶
func (m Manifest) DryRun(ctx context.Context) ([]MergePatch, error)
DryRun returns a list of merge patches, either strategic or RFC-7386 for unregistered types, that show the effects of applying the manifest.
func (Manifest) Filter ¶
Filter returns a Manifest containing only those resources for which *no* Predicate returns false. Any changes callers make to the resources passed to their Predicate[s] will only be reflected in the returned Manifest.
func (Manifest) Resources ¶
func (m Manifest) Resources() []unstructured.Unstructured
Resources returns a deep copy of the Manifest resources
type Manifestival ¶
type Manifestival interface {
// Either updates or creates all resources in the manifest
Apply(ctx context.Context, opts ...ApplyOption) error
// Deletes all resources in the manifest
Delete(ctx context.Context, opts ...DeleteOption) error
// Transforms the resources within a Manifest
Transform(fns ...Transformer) (Manifest, error)
// Filters resources in a Manifest; Predicates are AND'd
Filter(fns ...Predicate) Manifest
// Append the resources from other Manifests to create a new one
Append(mfs ...Manifest) Manifest
// Sort the resources in a Manifest
Sort(lessFunc LessFunc) Manifest
// Show how applying the manifest would change the cluster
DryRun(ctx context.Context) ([]MergePatch, error)
}
Manifestival defines the operations allowed on a set of Kubernetes resources (typically, a set of YAML files, aka a manifest)
type MergePatch ¶
type MergePatch map[string]interface{}
type Option ¶
type Option func(*Manifest)
Option follows the "functional object" idiom
func UseLastAppliedConfigAnnotation ¶
UseLastAppliedConfigAnnotation sets an alternate name for the annotation used to track the last applied configuration (defaults to kubectl.kubernetes.io/last-applied-configuration) annotationName is a value specific to your application such as myapp.example.com/last-applied-configuration
type Overwrite ¶
type Overwrite bool
Resolve conflicts by using values from the manifest values
func (Overwrite) ApplyWith ¶
func (i Overwrite) ApplyWith(opts *ApplyOptions)
type Owner ¶
type Owner interface {
v1.Object
schema.ObjectKind
}
Owner is a partial Kubernetes metadata schema.
type Path ¶
type Path string
Path is a Source represented as a comma-delimited list of files, directories, and URL's
func (Path) Parse ¶
func (p Path) Parse() ([]unstructured.Unstructured, error)
type Preconditions ¶
type Preconditions metav1.Preconditions
Must be fulfilled before a deletion is carried out
func (Preconditions) DeleteWith ¶
func (p Preconditions) DeleteWith(opts *DeleteOptions)
type Predicate ¶
type Predicate func(u *unstructured.Unstructured) bool
Predicate returns true if u should be included in result
func All ¶
All returns a predicate that returns true unless any of its passed predicates return false.
func Any ¶
Any returns a predicate that returns false unless any of its passed predicates return true.
func ByAnnotation ¶
ByAnnotation returns resources that contain a particular annotation and value. A value of "" denotes *ANY* value
func ByGVK ¶
func ByGVK(gvk schema.GroupVersionKind) Predicate
ByGVK returns resources of a particular GroupVersionKind
func ByLabel ¶
ByLabel returns resources that contain a particular label and value. A value of "" denotes *ANY* value
type PropagationPolicy ¶
type PropagationPolicy metav1.DeletionPropagation
Whether and how garbage collection will be performed.
func (PropagationPolicy) DeleteWith ¶
func (p PropagationPolicy) DeleteWith(opts *DeleteOptions)
type Recursive ¶
type Recursive string
Recursive is identical to Path, but dirs are searched recursively
func (Recursive) Parse ¶
func (r Recursive) Parse() ([]unstructured.Unstructured, error)
type Slice ¶
type Slice []unstructured.Unstructured
Slice is a Source comprised of existing objects
func (Slice) Parse ¶
func (s Slice) Parse() ([]unstructured.Unstructured, error)
type Source ¶
type Source interface {
Parse() ([]unstructured.Unstructured, error)
}
Source is the interface through which all Manifests are created.
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 Transformer which adds an OwnerReference pointing to `owner`