api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2015 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DOCKER_MINIMUM_MEMORY = 4 * 1024 * 1024 // 4MB
View Source
const (
	ECS_SERVICE = "ecs"
)
View Source
const EcsMaxReasonLength = 255

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError added in v1.0.0

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

Implements Error & Retriable

func NewAPIError added in v1.0.0

func NewAPIError(err error) *APIError

func (*APIError) Error added in v1.0.0

func (apiErr *APIError) Error() string

func (*APIError) Retry added in v1.0.0

func (apiErr *APIError) Retry() bool

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) 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 ApplyingError

type ApplyingError struct {
	Err string `json:"error"`
}

ApplyingError is an error indicating something that went wrong transitioning from one state to another. For now it's very simple (and exists in part to ensure that there's a symetric marshal/unmarshal for the error).

func NewApplyingError

func NewApplyingError(err error) *ApplyingError

func (*ApplyingError) Error

func (ae *ApplyingError) Error() string

type Container

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

	DesiredStatus ContainerStatus `json:"desiredStatus"`
	KnownStatus   ContainerStatus

	// RunDependencies is a list of containers that must be run before
	// this one is created
	RunDependencies []string
	// 'Internal' containers are ones that are not directly specified by task definitions, but created by the agent
	IsInternal bool

	AppliedStatus ContainerStatus
	ApplyingError *ApplyingError

	SentStatus ContainerStatus

	KnownExitCode     *int
	KnownPortBindings []PortBinding

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

func (*Container) DesiredTerminal

func (c *Container) DesiredTerminal() bool

func (*Container) KnownTerminal

func (c *Container) KnownTerminal() bool

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

	Task      *Task
	Container *Container
}

type ContainerStatus

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

	ContainerZombie // Impossible status to use as a virtual 'max'
)

func (*ContainerStatus) MarshalJSON

func (cs *ContainerStatus) MarshalJSON() ([]byte, error)

func (*ContainerStatus) String

func (cs *ContainerStatus) String() string

func (*ContainerStatus) TaskStatus

func (cs *ContainerStatus) TaskStatus() TaskStatus

func (*ContainerStatus) Terminal

func (cs *ContainerStatus) Terminal() bool

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

func (*DockerContainer) String

func (dc *DockerContainer) String() string

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)
}

func NewECSClient

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

type EmptyHostVolume

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

func (*EmptyHostVolume) SourcePath

func (e *EmptyHostVolume) SourcePath() string

type FSHostVolume

type FSHostVolume struct {
	FSSourcePath string `json:"sourcePath"`
}

FSHostVolume is a simple type of HostVolume which references an arbitrary location on the host as the Volume.

func (*FSHostVolume) SourcePath

func (fs *FSHostVolume) SourcePath() string

SourcePath returns the path on the host filesystem that should be mounted

type HostVolume

type HostVolume interface {
	SourcePath() string
}

HostVolume is an interface for something that may be used as the host half of a docker volume mount

type MountPoint

type MountPoint struct {
	SourceVolume  string `json:"sourceVolume"`
	ContainerPath string `json:"containerPath"`
	ReadOnly      bool   `json:"readOnly"`
}

MountPoint describes the in-container location of a Volume and references that Volume by name.

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.

type Resource

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

type Task

type Task struct {
	Arn        string
	Overrides  TaskOverrides `json:"-"`
	Family     string
	Version    string
	Containers []*Container
	Volumes    []TaskVolume `json:"volumes"`

	DesiredStatus TaskStatus
	KnownStatus   TaskStatus
	KnownTime     time.Time

	SentStatus 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 TaskFromACS added in v1.0.0

func TaskFromACS(task *ecsacs.Task) (*Task, error)

func (*Task) ContainerByName

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

func (*Task) DockerConfig

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

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

func (*Task) DockerHostConfig

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

func (*Task) HostVolumeByName

func (task *Task) HostVolumeByName(name string) (HostVolume, bool)

HostVolumeByName returns the task Volume for the given a volume name in that task. The second return value indicates the presense of that volume

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) PostUnmarshalTask

func (task *Task) PostUnmarshalTask()

PostUnmarshalTask is run after a task has been unmarshalled, but before it has been run. It is possible it will be subsequently called after that and should be able to handle such an occurrence appropriately (e.g. behave idempotently).

func (*Task) String

func (t *Task) String() string

func (*Task) UpdateMountPoints

func (task *Task) UpdateMountPoints(cont *Container, vols map[string]string)

func (*Task) UpdateTaskStatus

func (task *Task) UpdateTaskStatus() (newStatus TaskStatus)

UpdateTaskState updates the given task's status based on its container's status. For example, if an essential container stops, it will set the task to stopped. It returns a TaskStatus indicating what change occured or TaskStatusNone if there was no change

type TaskOverrides

type TaskOverrides struct{}

type TaskStatus

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

func (*TaskStatus) BackendStatus added in v1.0.0

func (ts *TaskStatus) BackendStatus() string

Mapping task status in the agent to that in the backend

func (*TaskStatus) ContainerStatus

func (ts *TaskStatus) ContainerStatus() ContainerStatus

func (*TaskStatus) MarshalJSON

func (ts *TaskStatus) MarshalJSON() ([]byte, error)

func (*TaskStatus) String

func (ts *TaskStatus) String() string

func (*TaskStatus) Terminal

func (ts *TaskStatus) Terminal() bool

func (*TaskStatus) UnmarshalJSON

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

type TaskVolume

type TaskVolume struct {
	Name   string `json:"name"`
	Volume HostVolume
}

TaskVolume is a definition of all the volumes available for containers to reference within a task. It must be named.

func (*TaskVolume) MarshalJSON

func (tv *TaskVolume) MarshalJSON() ([]byte, error)

func (*TaskVolume) UnmarshalJSON

func (tv *TaskVolume) UnmarshalJSON(b []byte) error

UnmarshalJSON for TaskVolume determines the name and volume type, and unmarshals it into the appropriate HostVolume fulfilling interfaces

type VolumeFrom

type VolumeFrom struct {
	SourceContainer string `json:"sourceContainer"`
	ReadOnly        bool   `json:"readOnly"`
}

VolumeFrom is a volume which references another container as its source.

Directories

Path Synopsis
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.

Jump to

Keyboard shortcuts

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