entity

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const NoImageErrStr = "spec.containers[0].image: Required value"

NoImageErrStr is the error message returned by k8s when the image field has been left blank.

Variables

View Source
var (
	// ErrorNilObject is when a deploy.KubeObject is null.
	ErrorNilObject = errors.New("an object was nil, this is not allowed")
	// ErrorInvalidAttachType is when the Type of the attached object in invalid.
	ErrorInvalidAttachType = errors.New("the entity to be attached is of an unknown type")
	// ErrorBadAttachOrder is when an attachment is attempted in an improper order
	ErrorBadAttachOrder = errors.New("entities cannot attach to entities of a lower type")
	// ErrorMaxAttached is when an Entity cannot support more Entities attaching
	ErrorMaxAttached = errors.New("no more entities can be attached")
	// ErrorNilEntity is when an entity is nil
	ErrorNilEntity = errors.New("entities cannot be nil")
)
View Source
var (
	// ErrorEmptyImageString is when an Image is created with an empty name
	ErrorEmptyImageString = errors.New("image.Image's String was empty")
	// ErrorNilImage is when an Image is created with a nil *image.Image.
	ErrorNilImage = errors.New("*image.Image cannot be nil")
)
View Source
var DefaultContainer = kube.Container{
	ImagePullPolicy: kube.PullAlways,
}

DefaultContainer is the default for all new Containers

View Source
var DefaultPodSpec = kube.PodSpec{
	RestartPolicy: kube.RestartPolicyAlways,
	DNSPolicy:     kube.DNSDefault,
}

DefaultPodSpec is the default for newly created Pods

View Source
var (
	// ErrMissingContainer is where the Pod is being used in a context where it must be valid and doesn't have a Container.
	ErrMissingContainer = errors.New("pod must have containers to be deployed")
)
View Source
var (
	// ErrMissingImage is where the Container is being used in a context where it must be valid and doesn't have an Image.
	ErrMissingImage = errors.New("container must have an image to be deployed")
)
View Source
var (
	// ErrMissingPod is when the RC is being used in a context where it must be valid and doesn't have a Pod.
	ErrMissingPod = errors.New("replication controller must have pod to be deployed")
)

Functions

This section is empty.

Types

type Builder

type Builder interface {
	// Build returns an Entity based on the implementations internal logic, Errors are returned if state is invalid.
	Build() (Entity, error)
}

Builder is used by input sources that create Entities.

type Container

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

Container represents kube.Container in the Redspread hierarchy.

func NewContainer

func NewContainer(container kube.Container, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Container, error)

NewContainer creates a new Entity for the provided kube.Container. Container must be valid.

func (*Container) Attach

func (c *Container) Attach(e Entity) error

Attach is only possible for images.

func (Container) DefaultMeta

func (base Container) DefaultMeta() kube.ObjectMeta

DefaultMeta returns the ObjectMeta that the Entity was created with

func (*Container) Deployment

func (c *Container) Deployment() (*deploy.Deployment, error)

Deployment is created with Container attached to Pod. The pod is named after the kube.Container.

func (*Container) Images

func (c *Container) Images() []*image.Image

Images returns the Container's image

func (Container) Objects

func (base Container) Objects() []deploy.KubeObject

Objects returns slice of objects attached to Entity

func (Container) Source

func (base Container) Source() string

Source returns an import source specific identifier

func (Container) Type

func (base Container) Type() Type

Type returns itself for trivial implementation of Entity

type Entity

type Entity interface {
	deploy.Deployable
	Type() Type
	Objects() []deploy.KubeObject
	Source() string
	Attach(Entity) error
	DefaultMeta() kube.ObjectMeta
	// contains filtered or unexported methods
}

Entity is the fundamental building block of `spread`'s internal representation of state. Entities exist for both constructs that already exist in Kubernetes (RC, Pod, Container) as well as ones that have been added (image).

An entity must at all times be capable of producing a Deployment.

Entities are attached in the order: Image -> Container -> Pod -> RC. Attachments out of order are not allowed.

type Image

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

Image represents a Docker image in the Redspread hierarchy. It wraps image.Image.

func NewImage

func NewImage(image *image.Image, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Image, error)

NewImage creates a new Entity for the image.Image it's provided with.

func (*Image) Attach

func (c *Image) Attach(e Entity) error

Attach is not allowed on Images

func (Image) DefaultMeta

func (base Image) DefaultMeta() kube.ObjectMeta

DefaultMeta returns the ObjectMeta that the Entity was created with

func (*Image) Deployment

func (c *Image) Deployment() (*deploy.Deployment, error)

Deployment is created with image attached to default pod. The GenerateName of the Pod is the name of the image.

func (*Image) Images

func (c *Image) Images() []*image.Image

Images returns the associated image.Image

func (Image) Objects

func (base Image) Objects() []deploy.KubeObject

Objects returns slice of objects attached to Entity

func (Image) Source

func (base Image) Source() string

Source returns an import source specific identifier

func (Image) Type

func (base Image) Type() Type

Type returns itself for trivial implementation of Entity

type Pod

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

Pod represents kube.Pod in the Redspread hierarchy.

func NewDefaultPod

func NewDefaultPod(meta kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Pod, error)

NewDefaultPod creates a Pod using spreads defaults without any containers attached. Containers must be attached before this Pod can be deployed.

func NewPod

func NewPod(kubePod *kube.Pod, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Pod, error)

NewPod creates a Entity for a corresponding *kube.Pod. Pod must be valid.

func NewPodFromPodSpec

func NewPodFromPodSpec(meta kube.ObjectMeta, podSpec kube.PodSpec, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Pod, error)

NewPodFromPodSpec creates a new Pod using ObjectMeta and a PodSpec.

func (*Pod) Attach

func (c *Pod) Attach(curEntity Entity) error

Attach appends Images and Containers.

func (Pod) DefaultMeta

func (base Pod) DefaultMeta() kube.ObjectMeta

DefaultMeta returns the ObjectMeta that the Entity was created with

func (*Pod) Deployment

func (c *Pod) Deployment() (*deploy.Deployment, error)

Deployment is created containing Pod with attached Containers.

func (*Pod) Images

func (c *Pod) Images() (images []*image.Image)

Images for all Containers in Pod

func (Pod) Objects

func (base Pod) Objects() []deploy.KubeObject

Objects returns slice of objects attached to Entity

func (Pod) Source

func (base Pod) Source() string

Source returns an import source specific identifier

func (Pod) Type

func (base Pod) Type() Type

Type returns itself for trivial implementation of Entity

type ReplicationController

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

ReplicationController represents kube.ReplicationController in the Redspread hierarchy.

func NewReplicationController

func NewReplicationController(kubeRC *kube.ReplicationController, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*ReplicationController, error)

NewReplicationController creates a new Entity for the provided kube.ReplicationController. Must be valid.

func (*ReplicationController) Attach

func (c *ReplicationController) Attach(e Entity) error

Attach allows Pods, Containers, and Images to be attached.

func (ReplicationController) DefaultMeta

func (base ReplicationController) DefaultMeta() kube.ObjectMeta

DefaultMeta returns the ObjectMeta that the Entity was created with

func (*ReplicationController) Deployment

func (c *ReplicationController) Deployment() (*deploy.Deployment, error)

Deployment is created for RC attached with it's Pod.

func (*ReplicationController) Images

func (c *ReplicationController) Images() (images []*image.Image)

Images contained by ReplicationController's Pods.

func (ReplicationController) Objects

func (base ReplicationController) Objects() []deploy.KubeObject

Objects returns slice of objects attached to Entity

func (ReplicationController) Source

func (base ReplicationController) Source() string

Source returns an import source specific identifier

func (ReplicationController) Type

func (base ReplicationController) Type() Type

Type returns itself for trivial implementation of Entity

type Type

type Type int

Type identifies the entity's type.

const (
	// EntityApplication is for Application (top of tree)
	EntityApplication Type = iota
	// EntityReplicationController is for ReplicationController
	EntityReplicationController
	// EntityPod is for Pod
	EntityPod
	// EntityContainer is for Container
	EntityContainer
	// EntityImage is for Image
	EntityImage
)

func (Type) String

func (t Type) String() string

String prints the name of the type

Jump to

Keyboard shortcuts

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