api

package
v0.0.0-...-0dec3e3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2014 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ECS_SERVICE = "ecs"

	DEFAULT_CLUSTER_NAME = "default"
)
View Source
const DOCKER_MINIMUM_MEMORY = 4 * 1024 * 1024 // 4MB

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiECSClient

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

func (*ApiECSClient) CreateCluster

func (client *ApiECSClient) CreateCluster(clusterName string) (string, error)

CreateCluster creates a cluster from a given name and returns its arn

func (*ApiECSClient) CredentialProvider

func (client *ApiECSClient) CredentialProvider() credentials.AWSCredentialProvider

func (*ApiECSClient) DeregisterContainerInstance

func (client *ApiECSClient) DeregisterContainerInstance(containerInstanceArn string) error

func (*ApiECSClient) DiscoverPollEndpoint

func (client *ApiECSClient) DiscoverPollEndpoint(containerInstanceArn string) (string, error)

func (*ApiECSClient) RegisterContainerInstance

func (client *ApiECSClient) RegisterContainerInstance() (string, error)

func (*ApiECSClient) SubmitContainerStateChange

func (client *ApiECSClient) SubmitContainerStateChange(change ContainerStateChange) utils.RetriableError

func (*ApiECSClient) SubmitTaskStateChange

func (client *ApiECSClient) SubmitTaskStateChange(change ContainerStateChange) utils.RetriableError

type Container

type Container struct {
	Name        string
	Image       string
	Command     []string
	Cpu         uint
	Memory      uint
	Links       []string
	BindMounts  []string
	VolumesFrom []string
	Ports       []PortBinding `json:"portMappings"`
	Essential   bool
	EntryPoint  *[]string
	Environment map[string]string  `json:"environment"`
	Overrides   ContainerOverrides `json:"overrides"`

	DesiredStatus ContainerStatus `json:"desiredStatus"`
	AppliedStatus ContainerStatus
	KnownStatus   ContainerStatus

	KnownExitCode     *int
	KnownPortBindings []PortBinding

	// Not upstream; todo move this out into a wrapper type
	StatusLock sync.Mutex
}

func (*Container) DockerConfig

func (container *Container) DockerConfig() (*docker.Config, error)

DockerConfig converts the given container in this task to the format of GoDockerClient's 'Config' struct

func (*Container) Overridden

func (c *Container) Overridden() *Container

Overriden returns

func (*Container) String

func (c *Container) String() string

type ContainerOverrides

type ContainerOverrides struct {
	Command *[]string `json:"command"`
}

func (*ContainerOverrides) UnmarshalJSON

func (overrides *ContainerOverrides) UnmarshalJSON(b []byte) error

This custom unmarshaller is needed because the json sent to us as a string rather than a fully typed object. We support both formats in the hopes that one day everything will be fully typed Note: the `json:",string"` tag DOES NOT apply here; it DOES NOT work with struct types, only ints/floats/etc. We're basically doing that though We also intentionally fail if there are any keys we were unable to unmarshal into our struct

type ContainerOverridesCopy

type ContainerOverridesCopy ContainerOverrides

A type alias that doesn't have a custom unmarshaller so we can unmarshal into something without recursing

type ContainerStateChange

type ContainerStateChange struct {
	TaskArn       string
	ContainerName string
	Status        ContainerStatus

	Reason       string
	ExitCode     *int
	PortBindings []PortBinding

	TaskStatus TaskStatus // TaskStatusNone if this does not result in a task state change
}

type ContainerStatus

type ContainerStatus int32
const (
	ContainerStatusNone ContainerStatus = iota
	ContainerStatusUnknown
	ContainerPulled
	ContainerCreated
	ContainerRunning
	ContainerStopped
	ContainerDead
)

func (*ContainerStatus) String

func (cs *ContainerStatus) String() string

func (*ContainerStatus) UnmarshalJSON

func (cs *ContainerStatus) UnmarshalJSON(b []byte) error

type DockerContainer

type DockerContainer struct {
	DockerId   string
	DockerName string // needed for linking

	Container *Container
}

This is a mapping between containers-as-docker-knows-them and containers-as-we-know-them. This is primarily used in DockerState, but lives here such that tasks and containers know how to convert themselves into Docker's desired config format

type ECSClient

type ECSClient interface {
	CredentialProvider() credentials.AWSCredentialProvider
	RegisterContainerInstance() (string, error)
	SubmitTaskStateChange(change ContainerStateChange) utils.RetriableError
	SubmitContainerStateChange(change ContainerStateChange) utils.RetriableError
	DiscoverPollEndpoint(containerInstanceArn string) (string, error)
	DeregisterContainerInstance(containerInstanceArn string) error
}

func NewECSClient

func NewECSClient(credentialProvider credentials.AWSCredentialProvider, config *config.Config, insecureSkipVerify bool) ECSClient

type PortBinding

type PortBinding struct {
	ContainerPort uint16
	HostPort      uint16
	BindIp        string
}

func PortBindingFromDockerPortBinding

func PortBindingFromDockerPortBinding(dockerPortBindings map[docker.Port][]docker.PortBinding) ([]PortBinding, error)

PortBindingFromDockerPortBinding constructs a PortBinding slice from a docker NetworkSettings.Ports map. It prefers to fail-hard rather than report incorrect information, so any issues in docker's data will result in an error

type Resource

type Resource struct {
	Name        string
	Type        string
	DoubleValue float64
	LongValue   int64
}

type StateChangeError

type StateChangeError struct {
	Retriable bool
	// contains filtered or unexported fields
}

Implements Error & Retriable

func NewStateChangeError

func NewStateChangeError(message string, retriable bool) *StateChangeError

func (*StateChangeError) Error

func (sce *StateChangeError) Error() string

func (*StateChangeError) Retry

func (sce *StateChangeError) Retry() bool

type Task

type Task struct {
	Arn        string
	Overrides  TaskOverrides `json:"ignore"` // No taskOverrides right now
	Family     string
	Version    string
	Containers []*Container

	DesiredStatus TaskStatus
	KnownStatus   TaskStatus
	// contains filtered or unexported fields
}

func RemoveFromTaskArray

func RemoveFromTaskArray(arr []*Task, ndx int) []*Task

RemoveFromTaskArray removes the element at ndx from an array of task pointers, arr. If the ndx is out of bounds, it returns arr unchanged.

func (*Task) ContainerByName

func (task *Task) ContainerByName(name string) (*Container, bool)

func (*Task) ContainersByName

func (task *Task) ContainersByName() map[string]*Container

func (*Task) DockerHostConfig

func (task *Task) DockerHostConfig(container *Container, dockerContainerMap map[string]*DockerContainer) (*docker.HostConfig, error)

func (*Task) InferContainerDesiredStatus

func (task *Task) InferContainerDesiredStatus()

InferContainerDesiredStatus ensures that all container's desired statuses are compatible with whatever status the task desires to be at or is at. This is used both to initialize container statuses of new tasks and to force auxilery containers into terminal states (e.g. the essential containers died already)

func (*Task) Overridden

func (task *Task) Overridden() *Task

Overridden returns a copy of the task with all container's overridden and itself overridden as well

func (*Task) String

func (t *Task) String() string

type TaskOverrides

type TaskOverrides struct{}

type TaskStatus

type TaskStatus int32
const (
	TaskStatusNone TaskStatus = iota
	TaskStatusUnknown
	TaskPulled
	TaskCreated
	TaskRunning
	TaskStopped
	TaskDead
)

func (*TaskStatus) ContainerStatus

func (ts *TaskStatus) ContainerStatus() ContainerStatus

func (*TaskStatus) String

func (ts *TaskStatus) String() string

func (*TaskStatus) UnmarshalJSON

func (ts *TaskStatus) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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