Documentation ¶
Overview ¶
Package resource implements representations of k8s API resources as "unstructured" objects.
Index ¶
- type GenerationBehavior
- type ResId
- func (n ResId) CopyWithNewNamespace(ns string) ResId
- func (n ResId) CopyWithNewPrefix(p string) ResId
- func (n ResId) Gvk() schema.GroupVersionKind
- func (n ResId) GvknEquals(id ResId) bool
- func (n ResId) GvknString() string
- func (n ResId) Name() string
- func (n ResId) Namespace() string
- func (n ResId) Prefix() string
- func (n ResId) String() string
- type Resource
- func (r *Resource) Behavior() GenerationBehavior
- func (r *Resource) GetFieldValue(fieldPath string) (string, error)
- func (r *Resource) Id() ResId
- func (r *Resource) IsGenerated() bool
- func (r *Resource) Merge(other *Resource)
- func (r *Resource) Replace(other *Resource)
- func (r *Resource) SetBehavior(b GenerationBehavior) *Resource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GenerationBehavior ¶ added in v1.0.2
type GenerationBehavior int
GenerationBehavior specifies generation behavior of configmaps, secrets and maybe other resources.
const ( // BehaviorUnspecified is an Unspecified behavior; typically treated as a Create. BehaviorUnspecified GenerationBehavior = iota // BehaviorCreate makes a new resource. BehaviorCreate // BehaviorReplace replaces a resource. BehaviorReplace // BehaviorMerge attempts to merge a new resource with an existing resource. BehaviorMerge )
func NewGenerationBehavior ¶ added in v1.0.2
func NewGenerationBehavior(s string) GenerationBehavior
NewGenerationBehavior converts a string to a GenerationBehavior.
func (GenerationBehavior) String ¶ added in v1.0.2
func (b GenerationBehavior) String() string
String converts a GenerationBehavior to a string.
type ResId ¶ added in v1.0.2
type ResId struct {
// contains filtered or unexported fields
}
ResId conflates GroupVersionKind with a textual name to uniquely identify a kubernetes resource (object).
func NewResId ¶ added in v1.0.2
func NewResId(g schema.GroupVersionKind, n string) ResId
NewResId creates new resource identifier
func NewResIdWithPrefix ¶ added in v1.0.6
func NewResIdWithPrefix(g schema.GroupVersionKind, n, p string) ResId
NewResIdWithPrefix creates new resource identifier with a prefix
func NewResIdWithPrefixNamespace ¶ added in v1.0.6
func NewResIdWithPrefixNamespace(g schema.GroupVersionKind, n, p, ns string) ResId
NewResIdWithPrefixNamespace creates new resource identifier with a prefix and a namespace
func (ResId) CopyWithNewNamespace ¶ added in v1.0.6
CopyWithNewNamespace make a new copy from current ResId and set a new namespace
func (ResId) CopyWithNewPrefix ¶ added in v1.0.6
CopyWithNewPrefix make a new copy from current ResId and append a new prefix
func (ResId) Gvk ¶ added in v1.0.2
func (n ResId) Gvk() schema.GroupVersionKind
Gvk returns Group/Version/Kind of the resource.
func (ResId) GvknEquals ¶ added in v1.0.6
GvknEquals return if two ResId have the same Group/Version/Kind and name The comparison excludes prefix
func (ResId) GvknString ¶ added in v1.0.6
GvknString of ResId based on GVK and name
type Resource ¶
type Resource struct { unstructured.Unstructured // contains filtered or unexported fields }
Resource is an "Unstructured" (json/map form) Kubernetes API resource object paired with a GenerationBehavior.
func NewResourceFromMap ¶ added in v1.0.2
NewResourceFromMap returns a new instance of Resource.
func NewResourceFromUnstruct ¶ added in v1.0.2
func NewResourceFromUnstruct(u unstructured.Unstructured) *Resource
NewResourceFromUnstruct returns a new instance of Resource.
func NewResourceWithBehavior ¶ added in v1.0.2
func NewResourceWithBehavior(obj runtime.Object, b GenerationBehavior) (*Resource, error)
NewResourceWithBehavior returns a new instance of Resource.
func (*Resource) Behavior ¶
func (r *Resource) Behavior() GenerationBehavior
Behavior returns the behavior for the resource.
func (*Resource) GetFieldValue ¶ added in v1.0.2
GetFieldValue returns value at the given fieldpath.
func (*Resource) IsGenerated ¶ added in v1.0.5
IsGenerated checks if the resource is generated from a generator
func (*Resource) SetBehavior ¶ added in v1.0.2
func (r *Resource) SetBehavior(b GenerationBehavior) *Resource
SetBehavior changes the resource to the new behavior