core

package
v0.3.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EtcdEndpoints []string
	K8sHost       string
	K8sUser       string
	K8sPass       string
	AwsRegion     string

	AwsAZ       string
	AwsSgID     string
	AwsSubnetID string
)

Functions

func ImageRepoName

func ImageRepoName(m *types.ContainerBlueprint) string

Types

type AppCollection

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

func (*AppCollection) Create

func (c *AppCollection) Create(r *AppResource) (*AppResource, error)

Create takes an App and creates it in etcd. It also creates a Kubernetes Namespace with the name of the App.

func (*AppCollection) EtcdKey

func (c *AppCollection) EtcdKey(name types.ID) string

EtcdKey implements the Collection interface.

func (*AppCollection) Get

func (c *AppCollection) Get(name types.ID) (*AppResource, error)

Get takes a name and returns an AppResource if it exists.

func (*AppCollection) InitializeResource

func (c *AppCollection) InitializeResource(r Resource) error

InitializeResource implements the Collection interface.

func (*AppCollection) List

func (c *AppCollection) List() (*AppList, error)

List returns an AppList.

func (*AppCollection) New

func (c *AppCollection) New() *AppResource

New initializes an App with a pointer to the Collection.

type AppList

type AppList struct {
	Items []*AppResource `json:"items"`
}

NOTE this does not inherit from types like model does; all we need is a List object, internally, that has a slice of our composed model above.

type AppResource

type AppResource struct {
	*types.App
	// contains filtered or unexported fields
}

func (*AppResource) Components

func (r *AppResource) Components() *ComponentCollection

Components returns a ComponentCollection with a pointer to the AppResource.

func (*AppResource) Delete

func (r *AppResource) Delete() error

Delete cascades deletes to all Components, deletes the Kube Namespace, and deletes the App in etcd.

func (*AppResource) PersistableObject

func (r *AppResource) PersistableObject() interface{}

PersistableObject satisfies the Resource interface

func (*AppResource) ProvisionSecret

func (r *AppResource) ProvisionSecret(repo *ImageRepoResource) error

type AwsVolume

type AwsVolume struct {
	Blueprint *types.VolumeBlueprint
	Instance  *InstanceResource
	// contains filtered or unexported fields
}

func (*AwsVolume) Create added in v0.3.3

func (m *AwsVolume) Create() error

func (*AwsVolume) Delete

func (m *AwsVolume) Delete() error

Delete deletes the EBS volume on AWS.

func (*AwsVolume) Exists added in v0.3.3

func (m *AwsVolume) Exists() (bool, error)

func (*AwsVolume) NeedsResize added in v0.3.0

func (m *AwsVolume) NeedsResize() bool

NeedsResize returns true if the actual EBS size does not match the blueprint.

func (*AwsVolume) Resize added in v0.3.0

func (m *AwsVolume) Resize() error

Resize snapshots the volume, creates a new volume from the snapshot, deletes the old volume, and renames the new volume to have the old name.

func (*AwsVolume) WaitForAvailable

func (m *AwsVolume) WaitForAvailable() error

type Collection

type Collection interface {
	EtcdKey(id types.ID) string

	// InitializeResource is called when unmarshalling objects from etcd.
	// Primarily, it sets a pointer to the Collection on the Resource.
	InitializeResource(r Resource) error
}

Collection is an interface for defining behavior of a collection of Resources.

type ComponentCollection

type ComponentCollection struct {
	App *AppResource
	// contains filtered or unexported fields
}

func (*ComponentCollection) Create

Create takes an Component and creates it in etcd.

func (*ComponentCollection) EtcdKey

func (c *ComponentCollection) EtcdKey(name types.ID) string

EtcdKey implements the Collection interface.

func (*ComponentCollection) Get

Get takes a name and returns an ComponentResource if it exists.

func (*ComponentCollection) InitializeResource

func (c *ComponentCollection) InitializeResource(r Resource) error

InitializeResource implements the Collection interface.

func (*ComponentCollection) List

func (c *ComponentCollection) List() (*ComponentList, error)

List returns an ComponentList.

func (*ComponentCollection) New

New initializes an Component with a pointer to the Collection.

type ComponentList

type ComponentList struct {
	Items []*ComponentResource `json:"items"`
}

type ComponentResource

type ComponentResource struct {
	*types.Component
	// contains filtered or unexported fields
}

func (*ComponentResource) App

func (r *ComponentResource) App() *AppResource

func (*ComponentResource) CurrentRelease

func (r *ComponentResource) CurrentRelease() (*ReleaseResource, error)

func (*ComponentResource) Delete

func (r *ComponentResource) Delete() error

Delete cascades delete calls to current and target releases, and deletes the Component in etcd.

TODO this should somehow stop any ongoing tasks related to the Component.

func (*ComponentResource) PersistableObject

func (r *ComponentResource) PersistableObject() interface{}

PersistableObject satisfies the Resource interface

func (*ComponentResource) Releases

func (r *ComponentResource) Releases() *ReleaseCollection

func (*ComponentResource) Save

func (r *ComponentResource) Save() error

Save saves the Component in etcd through an update.

func (*ComponentResource) TargetRelease

func (r *ComponentResource) TargetRelease() (*ReleaseResource, error)

type Core

type Core struct {
	DB          *DB
	K8S         *guber.Client
	EC2         *ec2.EC2
	ELB         *elb.ELB
	AutoScaling *autoscaling.AutoScaling
}

func New

func New(httpsMode bool, aws_access_key_id string, aws_secret_access_key string) *Core

func (*Core) Apps

func (c *Core) Apps() *AppCollection

Top-level resources ==============================================================================

func (*Core) Entrypoints

func (c *Core) Entrypoints() *EntrypointCollection

func (*Core) ImageRepos

func (c *Core) ImageRepos() *ImageRepoCollection

func (*Core) Tasks

func (c *Core) Tasks() *TaskCollection

type DB

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

func NewDB

func NewDB(endpoints []string) *DB

func (*DB) CompareAndSwap

func (db *DB) CompareAndSwap(r Collection, id types.ID, old Resource, new Resource) error

func (*DB) Create

func (db *DB) Create(r Collection, id types.ID, m Resource) error

func (*DB) CreateDir

func (db *DB) CreateDir(key string) (*etcd.Response, error)

TODO

func (*DB) CreateInOrder

func (db *DB) CreateInOrder(r Collection, m OrderedResource) error

func (*DB) Delete

func (db *DB) Delete(r Collection, id types.ID) error

func (*DB) Get

func (db *DB) Get(r Collection, id types.ID, out Resource) error

func (*DB) List

func (db *DB) List(r Collection, out interface{}) error

func (*DB) ListInOrder

func (db *DB) ListInOrder(r Collection, out interface{}) error

------------------------------------------------------------------------------

func (*DB) Update

func (db *DB) Update(r Collection, id types.ID, m Resource) error

type EntrypointCollection

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

func (*EntrypointCollection) Create

Create takes an Entrypoint and creates it in etcd. It also creates a Kubernetes Namespace with the name of the Entrypoint.

func (*EntrypointCollection) EtcdKey

func (c *EntrypointCollection) EtcdKey(domain types.ID) string

EtcdKey implements the Collection interface.

func (*EntrypointCollection) Get

Get takes a name and returns an EntrypointResource if it exists.

func (*EntrypointCollection) InitializeResource

func (c *EntrypointCollection) InitializeResource(r Resource) error

InitializeResource implements the Collection interface.

func (*EntrypointCollection) List

List returns an EntrypointList.

func (*EntrypointCollection) New

New initializes an Entrypoint with a pointer to the Collection.

type EntrypointList

type EntrypointList struct {
	Items []*EntrypointResource `json:"items"`
}

NOTE this does not inherit from types like model does; all we need is a List object, internally, that has a slice of our composed model above.

type EntrypointResource

type EntrypointResource struct {
	*types.Entrypoint
	// contains filtered or unexported fields
}

func (*EntrypointResource) AddPort

func (r *EntrypointResource) AddPort(elbPort int, instancePort int) error

AddPort creates a listener on the ELB.

func (*EntrypointResource) Delete

func (r *EntrypointResource) Delete() error

Delete cascades deletes to all Components, deletes the Kube Namespace, and deletes the Entrypoint in etcd.

func (*EntrypointResource) PersistableObject

func (r *EntrypointResource) PersistableObject() interface{}

PersistableObject satisfies the Resource interface

func (*EntrypointResource) RemovePort

func (r *EntrypointResource) RemovePort(elbPort int) error

RemovePort removes a listener from the ELB.

func (*EntrypointResource) Save

func (r *EntrypointResource) Save() error

Save saves the Entrypoint in etcd through an update.

type ExternalPort added in v0.3.2

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

func NewExternalPort added in v0.3.2

func NewExternalPort(p *types.Port, r *ReleaseResource, e *EntrypointResource) *ExternalPort

NOTE we pass entrypoint here, instead of simply finding from the port definition because it prevents unnecessary multiple lookups on the Entrypoint

func (*ExternalPort) AddToELB added in v0.3.2

func (ep *ExternalPort) AddToELB() error

TODO like the comment above, this only applies when there is an EntrypointDomain

func (*ExternalPort) Address added in v0.3.2

func (ep *ExternalPort) Address() *types.PortAddress

func (*ExternalPort) RemoveFromELB added in v0.3.2

func (ep *ExternalPort) RemoveFromELB() error

type ImageRepoCollection

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

func (*ImageRepoCollection) Create

Create takes an ImageRepo and creates it in etcd. It also creates a Kubernetes Namespace with the name of the ImageRepo.

func (*ImageRepoCollection) EtcdKey

func (c *ImageRepoCollection) EtcdKey(name types.ID) string

EtcdKey implements the Collection interface.

func (*ImageRepoCollection) Get

Get takes a name and returns an ImageRepoResource if it exists.

func (*ImageRepoCollection) InitializeResource

func (c *ImageRepoCollection) InitializeResource(r Resource) error

InitializeResource implements the Collection interface.

func (*ImageRepoCollection) List

func (c *ImageRepoCollection) List() (*ImageRepoList, error)

List returns an ImageRepoList.

func (*ImageRepoCollection) New

New initializes an ImageRepo with a pointer to the Collection.

type ImageRepoList

type ImageRepoList struct {
	Items []*ImageRepoResource `json:"items"`
}

NOTE this does not inherit from types like model does; all we need is a List object, internally, that has a slice of our composed model above.

type ImageRepoResource

type ImageRepoResource struct {
	*types.ImageRepo
	// contains filtered or unexported fields
}

func (*ImageRepoResource) Delete

func (r *ImageRepoResource) Delete() error

Delete deletes the ImageRepo in etcd.

func (*ImageRepoResource) PersistableObject

func (r *ImageRepoResource) PersistableObject() interface{}

PersistableObject satisfies the Resource interface

type InstanceCollection

type InstanceCollection struct {
	Release *ReleaseResource
	// contains filtered or unexported fields
}

func (*InstanceCollection) Get

Get takes an id and returns an InstanceResource if it exists.

func (*InstanceCollection) List

func (c *InstanceCollection) List() *InstanceList

List returns an InstanceList.

func (*InstanceCollection) New

New initializes an Instance with a pointer to the Collection.

type InstanceList

type InstanceList struct {
	Items []*InstanceResource `json:"items"`
}

type InstanceResource

type InstanceResource struct {
	*types.Instance
	// contains filtered or unexported fields
}

func (*InstanceResource) App

func (r *InstanceResource) App() *AppResource

func (*InstanceResource) Component

func (r *InstanceResource) Component() *ComponentResource

func (*InstanceResource) Delete

func (r *InstanceResource) Delete() (err error)

Delete tears down the instance

func (*InstanceResource) DeleteVolumes

func (r *InstanceResource) DeleteVolumes() error

exposed for use in deploy_component.go

func (*InstanceResource) IsStarted

func (r *InstanceResource) IsStarted() bool

func (*InstanceResource) IsStopped

func (r *InstanceResource) IsStopped() bool

func (*InstanceResource) Release

func (r *InstanceResource) Release() *ReleaseResource

func (*InstanceResource) Start

func (r *InstanceResource) Start() error

The following 2 are only diff from Provision() and Delete() in that they do not delete the create or delete the volumes.

func (*InstanceResource) Stop

func (r *InstanceResource) Stop() error

func (*InstanceResource) Volumes

func (r *InstanceResource) Volumes() (vols []*AwsVolume)

type InternalPort added in v0.3.2

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

func NewInternalPort added in v0.3.2

func NewInternalPort(p *types.Port, r *ReleaseResource) *InternalPort

func (*InternalPort) Address added in v0.3.2

func (ip *InternalPort) Address() *types.PortAddress

type OrderedResource

type OrderedResource interface {
	PersistableObject() interface{}
	SetID(id types.ID)
}

OrderedResource is similar to Resource, but provides a SetID() method to set an auto-generated ID from etcd on the Resource.

type ReleaseCollection

type ReleaseCollection struct {
	Component *ComponentResource
	// contains filtered or unexported fields
}

func (*ReleaseCollection) Create

Create takes an Release and creates it in etcd.

func (*ReleaseCollection) EtcdKey

func (c *ReleaseCollection) EtcdKey(timestamp types.ID) string

EtcdKey implements the Collection interface.

func (*ReleaseCollection) Get

Get takes an id and returns an ReleaseResource if it exists.

func (*ReleaseCollection) InitializeResource

func (c *ReleaseCollection) InitializeResource(r Resource) error

InitializeResource implements the Collection interface.

func (*ReleaseCollection) List

func (c *ReleaseCollection) List() (*ReleaseList, error)

List returns an ReleaseList.

func (*ReleaseCollection) New

New initializes an Release with a pointer to the Collection.

type ReleaseList

type ReleaseList struct {
	Items []*ReleaseResource `json:"items"`
}

type ReleaseResource

type ReleaseResource struct {
	*types.Release

	// TODO these are shared between releases, it's kinda funky right now
	ExternalService *guber.Service `json:"-"`
	InternalService *guber.Service `json:"-"`
	// contains filtered or unexported fields
}

func (*ReleaseResource) AddNewPorts added in v0.3.2

func (newR *ReleaseResource) AddNewPorts(oldR *ReleaseResource) error

AddNewPorts adds any new ports defined in containers to the existing Services. This is used as a part of the deployment process, and is used in conjunction with RemoveOldPorts. We use the config returned from the services themselves, as opposed to just updating the config, because auto-assigned ports need to be preserved.

func (*ReleaseResource) App

func (r *ReleaseResource) App() *AppResource

func (*ReleaseResource) Component

func (r *ReleaseResource) Component() *ComponentResource

func (*ReleaseResource) Delete

func (r *ReleaseResource) Delete() error

Delete removes all assets (volumes, pods, etc.) and deletes the Release in etcd.

func (*ReleaseResource) ExternalPorts added in v0.3.2

func (r *ReleaseResource) ExternalPorts() (ports []*ExternalPort)

func (*ReleaseResource) ExternalServiceName added in v0.3.2

func (r *ReleaseResource) ExternalServiceName() string

func (*ReleaseResource) ImagePullSecrets

func (r *ReleaseResource) ImagePullSecrets() (pullSecrets []*guber.ImagePullSecret, err error)

TODO naming inconsistencies for kube definitions of resources ImagePullSecrets returns repo names defined for Kube pods

func (*ReleaseResource) Instances

func (r *ReleaseResource) Instances() *InstanceCollection

func (*ReleaseResource) InternalPorts added in v0.3.2

func (r *ReleaseResource) InternalPorts() (ports []*InternalPort)

func (*ReleaseResource) InternalServiceName added in v0.3.2

func (r *ReleaseResource) InternalServiceName() string

func (*ReleaseResource) IsStarted

func (r *ReleaseResource) IsStarted() bool

func (*ReleaseResource) IsStopped

func (r *ReleaseResource) IsStopped() bool

func (*ReleaseResource) PersistableObject

func (r *ReleaseResource) PersistableObject() interface{}

PersistableObject satisfies the Resource interface

func (*ReleaseResource) Provision

func (r *ReleaseResource) Provision() error

Provision creates needed assets for all instances. It does not actually start instances -- that is handled by deploy.go.

func (*ReleaseResource) RemoveOldPorts added in v0.3.2

func (newR *ReleaseResource) RemoveOldPorts(oldR *ReleaseResource) error

func (*ReleaseResource) Save added in v0.3.1

func (r *ReleaseResource) Save() error

Save saves the Release in etcd through an update.

type Resource

type Resource interface {
	// PersistableObject returns the portion (or whole) of the Resource meant to
	// be marshalled and stored in the DB. This allows for dynamic "virtual"
	// values to be loaded and displayed in the API without needing to be stored.
	PersistableObject() interface{}
}

Resource is an interface used mainly for generalized marshalling purposes for resource types.

type TaskCollection

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

func (*TaskCollection) Create

func (c *TaskCollection) Create(r *TaskResource) (*TaskResource, error)

Create takes an Task and creates it in etcd. It also creates a Kubernetes Namespace with the name of the Task.

func (*TaskCollection) EtcdKey

func (c *TaskCollection) EtcdKey(id types.ID) string

EtcdKey implements the Collection interface.

func (*TaskCollection) Get

func (c *TaskCollection) Get(id types.ID) (*TaskResource, error)

Get takes a name and returns an TaskResource if it exists.

func (*TaskCollection) InitializeResource

func (c *TaskCollection) InitializeResource(r Resource) error

InitializeResource implements the Collection interface.

func (*TaskCollection) List

func (c *TaskCollection) List() (*TaskList, error)

List returns an TaskList.

func (*TaskCollection) New

func (c *TaskCollection) New() *TaskResource

New initializes an Task with a pointer to the Collection.

func (*TaskCollection) Start

func (c *TaskCollection) Start(t types.TaskType, msg interface{}) (*TaskResource, error)

NOTE kinda like a New().Save()

type TaskList

type TaskList struct {
	Items []*TaskResource `json:"items"`
}

NOTE this does not inherit from types like model does; all we need is a List object, internally, that has a slice of our composed model above.

type TaskResource

type TaskResource struct {
	*types.Task

	ID types.ID `json:"id"`
	// contains filtered or unexported fields
}

func (*TaskResource) Claim

func (r *TaskResource) Claim() error

Claim updates the Task status to "RUNNING" and returns nil. CompareAndSwap is used to prevent a race condition and ensure only one worker performs the task.

func (*TaskResource) Delete

func (r *TaskResource) Delete() error

Delete deletes the Task in etcd.

func (*TaskResource) IsQueued

func (r *TaskResource) IsQueued() bool

func (*TaskResource) PersistableObject

func (r *TaskResource) PersistableObject() interface{}

PersistableObject satisfies the Resource interface

func (*TaskResource) RecordError

func (r *TaskResource) RecordError(err error) error

func (*TaskResource) Save

func (r *TaskResource) Save() error

Save saves the Task in etcd through an update.

func (*TaskResource) SetID

func (r *TaskResource) SetID(id types.ID)

Implements OrderedModel interface

func (*TaskResource) TypeName added in v0.3.0

func (r *TaskResource) TypeName() string

Jump to

Keyboard shortcuts

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