apiresource

package module
v0.0.0-...-e8a76eb Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: MIT Imports: 11 Imported by: 1

README

pgk apiresource

This package contains a general Kubernetes API Resource handling.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResource

type APIResource struct {
	Kind     string
	Metadata struct {
		Name      string
		Namespace string
	}
}

APIResource holds the object information of the API Object

func NewResource

func NewResource(r io.Reader) (resource *APIResource, err error)

NewResource parses a YAML of a Kubernetes Resource description returns an initialized API Resource returns an error, if the Reader contains no valid yaml

func (*APIResource) Checksum

func (r *APIResource) Checksum() string

Checksum returns a SHA256 checksum of the APIResource as a string

func (*APIResource) Exists

func (r *APIResource) Exists() bool

Exists returns a bool. true if the Object exists in the cluster, false if not It returns also false, when there is no information if the resource is namespaced

func (*APIResource) Label

func (r *APIResource) Label()

Label labels the resource in the cluster

func (*APIResource) Namespaced

func (r *APIResource) Namespaced() (b bool, err error)

Namespaced returns a bool if the API Resource is namespaced or not returns an error if Kind is not found TODO must be made dynamic by fetching supported API-Resources from current cluster

type Collection

type Collection struct {
	Items map[string]*APIResource
	// contains filtered or unexported fields
}

Collection holds a collection of resources and the the corresponding manifests

func NewCollection

func NewCollection() *Collection

NewCollection returns an empty collection of API resources

func (*Collection) Add

func (c *Collection) Add(manifest []byte, path string) error

Add adds API Resources from the given manifest manifest is a byte array containing the manifest path is the path of the manifest file returns an error if the manifest is invalid

func (*Collection) Exists

func (c *Collection) Exists() bool

Exists returns a bool. true if the resources exists in the cluster, false if not It returns also false, when there is no information if the resource is namespaced

func (*Collection) Label

func (c *Collection) Label()

Label labels all resources of the collection in the cluster

func (*Collection) LoadFromDirectory

func (c *Collection) LoadFromDirectory(directory string) error

LoadFromDirectory loads collections from YAML files within the directory recursively returns an error if something is wrong with the files

Jump to

Keyboard shortcuts

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