resource

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package resource implements representations of k8s API resources as "unstructured" objects.

Index

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

func (n ResId) CopyWithNewNamespace(ns string) ResId

CopyWithNewNamespace make a new copy from current ResId and set a new namespace

func (ResId) CopyWithNewPrefix added in v1.0.6

func (n ResId) CopyWithNewPrefix(p string) ResId

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

func (n ResId) GvknEquals(id ResId) bool

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

func (n ResId) GvknString() string

GvknString of ResId based on GVK and name

func (ResId) Name added in v1.0.2

func (n ResId) Name() string

Name returns resource name.

func (ResId) Namespace added in v1.0.6

func (n ResId) Namespace() string

Namespace returns resource namespace.

func (ResId) Prefix added in v1.0.6

func (n ResId) Prefix() string

Prefix returns name prefix.

func (ResId) String added in v1.0.2

func (n ResId) String() string

String of ResId based on GVK, name and prefix

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

func NewResourceFromMap(m map[string]interface{}) *Resource

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

func (r *Resource) GetFieldValue(fieldPath string) (string, error)

GetFieldValue returns value at the given fieldpath.

func (*Resource) Id added in v1.0.2

func (r *Resource) Id() ResId

Id returns the ResId for the resource.

func (*Resource) IsGenerated added in v1.0.5

func (r *Resource) IsGenerated() bool

IsGenerated checks if the resource is generated from a generator

func (*Resource) Merge added in v1.0.2

func (r *Resource) Merge(other *Resource)

Merge performs merge with other resource.

func (*Resource) Replace added in v1.0.2

func (r *Resource) Replace(other *Resource)

Replace performs replace with other resource.

func (*Resource) SetBehavior added in v1.0.2

func (r *Resource) SetBehavior(b GenerationBehavior) *Resource

SetBehavior changes the resource to the new behavior

Jump to

Keyboard shortcuts

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