crds

package
v0.0.0-...-7a2065e Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCRDStorage

func NewCRDStorage(client ClientInterface) storage.PersistenceLayer

NewCRDStorage creates a Custom Resource Definition persistence layer

Types

type Client

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

Client implements a true CRD rest client

func NewClient

func NewClient(cl *rest.RESTClient, scheme *runtime.Scheme, namespace string, t Type) Client

NewClient creates a CRD client for a given resource type.

func (*Client) Create

func (c *Client) Create(obj Object) (Object, error)

Create implements ClientInterface

func (*Client) Delete

func (c *Client) Delete(name string, options *v1.DeleteOptions) error

Delete implements ClientInterface

func (*Client) Get

func (c *Client) Get(name string) (Object, error)

Get implements ClientInterface

func (*Client) List

func (c *Client) List(opts v1.ListOptions) (Collection, error)

List implements ClientInterface

func (*Client) NewCollection

func (c *Client) NewCollection() Collection

NewCollection implements ClientInterface

func (*Client) NewObject

func (c *Client) NewObject() Object

NewObject implements ClientInterface

func (*Client) Update

func (c *Client) Update(obj Object) (Object, error)

Update implements ClientInterface

type ClientInterface

type ClientInterface interface {
	// NewObject instantiates a new object of the type supported by the client
	NewObject() Object
	// NewCollection instantiates a new collection of the type supported by the client
	NewCollection() Collection
	// Create a new object
	Create(obj Object) (Object, error)
	// Update an existing object, fails if object does not exist
	Update(obj Object) (Object, error)
	// Delete an existing object, fails if objects does not exist
	Delete(name string, options *v1.DeleteOptions) error
	// Get an existing object
	Get(name string) (Object, error)
	// LIst existing objects
	List(opts v1.ListOptions) (Collection, error)
}

ClientInterface is used for testing.

func NewResourceClient

func NewResourceClient() (ClientInterface, error)

NewResourceClient creates a CRD rest client for common.Resource

func NewResourceConfigClient

func NewResourceConfigClient() (ClientInterface, error)

NewResourceConfigClient creates a CRD rest client for common.Resource

func NewTestResourceClient

func NewTestResourceClient() ClientInterface

NewTestResourceClient creates a fake CRD rest client for common.Resource

func NewTestResourceConfigClient

func NewTestResourceConfigClient() ClientInterface

NewTestResourceConfigClient creates a fake CRD rest client for common.Resource

type Collection

type Collection interface {
	runtime.Object
	SetItems([]Object)
	GetItems() []Object
}

Collection is a list of Object interface.

type Object

type Object interface {
	runtime.Object
	GetName() string
	FromItem(item common.Item)
	ToItem() common.Item
}

Object extends the runtime.Object interface. CRD are just a representation of the actual boskos object which should implements the common.Item interface.

type ResourceCollection

type ResourceCollection struct {
	v1.TypeMeta `json:",inline"`
	v1.ListMeta `json:"metadata,omitempty"`
	Items       []*ResourceObject `json:"items"`
}

ResourceCollection is the Collection implementation

func (*ResourceCollection) DeepCopyObject

func (in *ResourceCollection) DeepCopyObject() runtime.Object

DeepCopyObject implements Collection interface

func (*ResourceCollection) GetItems

func (in *ResourceCollection) GetItems() []Object

GetItems implements Collection interface

func (*ResourceCollection) SetItems

func (in *ResourceCollection) SetItems(objects []Object)

SetItems implements Collection interface

type ResourceObject

type ResourceObject struct {
	v1.TypeMeta   `json:",inline"`
	v1.ObjectMeta `json:"metadata,omitempty"`
	Spec          ResourceSpec   `json:"spec,omitempty"`
	Status        ResourceStatus `json:"status,omitempty"`
}

ResourceObject represents common.ResourceObject. It implements the Object interface.

func (*ResourceObject) DeepCopyObject

func (in *ResourceObject) DeepCopyObject() runtime.Object

DeepCopyObject implements runtime.Object interface

func (*ResourceObject) FromItem

func (in *ResourceObject) FromItem(i common.Item)

FromItem implements Object interface

func (*ResourceObject) GetName

func (in *ResourceObject) GetName() string

GetName returns a unique identifier for a given resource

func (*ResourceObject) ToItem

func (in *ResourceObject) ToItem() common.Item

ToItem implements Object interface

type ResourceSpec

type ResourceSpec struct {
	Type string `json:"type"`
}

ResourceSpec holds information that are not likely to change

type ResourceStatus

type ResourceStatus struct {
	State      string           `json:"state,omitempty"`
	Owner      string           `json:"owner"`
	LastUpdate time.Time        `json:"lastUpdate,omitempty"`
	UserData   *common.UserData `json:"userData,omitempty"`
}

ResourceStatus holds information that are likely to change

type ResourcesConfigCollection

type ResourcesConfigCollection struct {
	v1.TypeMeta `json:",inline"`
	v1.ListMeta `json:"metadata,omitempty"`
	Items       []*ResourcesConfigObject `json:"items"`
}

ResourcesConfigCollection implements the Collections interface

func (*ResourcesConfigCollection) DeepCopyObject

func (in *ResourcesConfigCollection) DeepCopyObject() runtime.Object

DeepCopyObject implements the runtime.Object interface

func (*ResourcesConfigCollection) GetItems

func (in *ResourcesConfigCollection) GetItems() []Object

GetItems implements the Collection interface

func (*ResourcesConfigCollection) SetItems

func (in *ResourcesConfigCollection) SetItems(objects []Object)

SetItems implements the Collection interface

type ResourcesConfigObject

type ResourcesConfigObject struct {
	v1.TypeMeta   `json:",inline"`
	v1.ObjectMeta `json:"metadata,omitempty"`
	Spec          ResourcesConfigSpec `json:"spec"`
}

ResourcesConfigObject holds generalized configuration information about how the resource needs to be created. Some Resource might not have a ResourceConfig (Example Project)

func (*ResourcesConfigObject) DeepCopyObject

func (in *ResourcesConfigObject) DeepCopyObject() runtime.Object

DeepCopyObject implements the runtime.Object interface

func (*ResourcesConfigObject) FromItem

func (in *ResourcesConfigObject) FromItem(i common.Item)

FromItem implements the Object interface

func (*ResourcesConfigObject) GetName

func (in *ResourcesConfigObject) GetName() string

GetName implements the Object interface

func (*ResourcesConfigObject) ToItem

func (in *ResourcesConfigObject) ToItem() common.Item

ToItem implements the Object interface

type ResourcesConfigSpec

type ResourcesConfigSpec struct {
	Config common.ConfigType    `json:"config"`
	Needs  common.ResourceNeeds `json:"needs"`
}

ResourcesConfigSpec holds config implementation specific configuration as well as resource needs

type Type

type Type struct {
	Kind, ListKind   string
	Singular, Plural string
	Object           Object
	Collection       Collection
}

Type defines a Custom Resource Definition (CRD) Type.

Jump to

Keyboard shortcuts

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