Documentation ¶
Overview ¶
Package ecs provides implementations of interfaces to interact with and manage ECS-backed pods and pod definitions. It also contains some helper functionality for using the ECS API directly.
Index ¶
- Constants
- func ConvertFailureToError(f types.Failure) error
- func ExportTags(tags map[string]string) []types.Tag
- type BasicClient
- func (c *BasicClient) DeregisterTaskDefinition(ctx context.Context, in *ecs.DeregisterTaskDefinitionInput) (*ecs.DeregisterTaskDefinitionOutput, error)
- func (c *BasicClient) DescribeTaskDefinition(ctx context.Context, in *ecs.DescribeTaskDefinitionInput) (*ecs.DescribeTaskDefinitionOutput, error)
- func (c *BasicClient) DescribeTasks(ctx context.Context, in *ecs.DescribeTasksInput) (*ecs.DescribeTasksOutput, error)
- func (c *BasicClient) ListTaskDefinitions(ctx context.Context, in *ecs.ListTaskDefinitionsInput) (*ecs.ListTaskDefinitionsOutput, error)
- func (c *BasicClient) ListTasks(ctx context.Context, in *ecs.ListTasksInput) (*ecs.ListTasksOutput, error)
- func (c *BasicClient) RegisterTaskDefinition(ctx context.Context, in *ecs.RegisterTaskDefinitionInput) (*ecs.RegisterTaskDefinitionOutput, error)
- func (c *BasicClient) RunTask(ctx context.Context, in *ecs.RunTaskInput) (*ecs.RunTaskOutput, error)
- func (c *BasicClient) StopTask(ctx context.Context, in *ecs.StopTaskInput) (*ecs.StopTaskOutput, error)
- func (c *BasicClient) TagResource(ctx context.Context, in *ecs.TagResourceInput) (*ecs.TagResourceOutput, error)
- type BasicPod
- func (p *BasicPod) Delete(ctx context.Context) error
- func (p *BasicPod) LatestStatusInfo(ctx context.Context) (*cocoa.ECSPodStatusInfo, error)
- func (p *BasicPod) Resources() cocoa.ECSPodResources
- func (p *BasicPod) StatusInfo() cocoa.ECSPodStatusInfo
- func (p *BasicPod) Stop(ctx context.Context) error
- type BasicPodCreator
- type BasicPodCreatorOptions
- func (o *BasicPodCreatorOptions) SetCache(pdc cocoa.ECSPodDefinitionCache) *BasicPodCreatorOptions
- func (o *BasicPodCreatorOptions) SetClient(c cocoa.ECSClient) *BasicPodCreatorOptions
- func (o *BasicPodCreatorOptions) SetVault(v cocoa.Vault) *BasicPodCreatorOptions
- func (o *BasicPodCreatorOptions) Validate() error
- type BasicPodDefinitionManager
- type BasicPodDefinitionManagerOptions
- func (o *BasicPodDefinitionManagerOptions) SetCache(pdc cocoa.ECSPodDefinitionCache) *BasicPodDefinitionManagerOptions
- func (o *BasicPodDefinitionManagerOptions) SetClient(c cocoa.ECSClient) *BasicPodDefinitionManagerOptions
- func (o *BasicPodDefinitionManagerOptions) SetVault(v cocoa.Vault) *BasicPodDefinitionManagerOptions
- func (o *BasicPodDefinitionManagerOptions) Validate() error
- type BasicPodOptions
- func (o *BasicPodOptions) SetClient(c cocoa.ECSClient) *BasicPodOptions
- func (o *BasicPodOptions) SetResources(res cocoa.ECSPodResources) *BasicPodOptions
- func (o *BasicPodOptions) SetStatusInfo(s cocoa.ECSPodStatusInfo) *BasicPodOptions
- func (o *BasicPodOptions) SetVault(v cocoa.Vault) *BasicPodOptions
- func (o *BasicPodOptions) Validate() error
- type ContainerInstanceStatus
- type TaskStatus
Constants ¶
const ReasonTaskMissing = "MISSING"
ReasonTaskMissing indicates that a task cannot be found because it is missing. This can happen for reasons such as the task never existed, or it has been stopped for a long time.
Variables ¶
This section is empty.
Functions ¶
func ConvertFailureToError ¶
ConvertFailureToError converts an ECS failure message into a formatted error. If the failure is due to being unable to find the task, it will return a cocoa.ECSTaskNotFound error. Docs: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/api_failures_messages.html
Types ¶
type BasicClient ¶
type BasicClient struct { awsutil.BaseClient // contains filtered or unexported fields }
BasicClient provides a cocoa.ECSClient implementation that wraps the AWS ECS API. It supports retrying requests using exponential backoff and jitter.
func NewBasicClient ¶
func NewBasicClient(ctx context.Context, opts awsutil.ClientOptions) (*BasicClient, error)
NewBasicClient creates a new AWS ECS client from the given options.
func (*BasicClient) DeregisterTaskDefinition ¶
func (c *BasicClient) DeregisterTaskDefinition(ctx context.Context, in *ecs.DeregisterTaskDefinitionInput) (*ecs.DeregisterTaskDefinitionOutput, error)
DeregisterTaskDefinition deregisters an existing task definition.
func (*BasicClient) DescribeTaskDefinition ¶
func (c *BasicClient) DescribeTaskDefinition(ctx context.Context, in *ecs.DescribeTaskDefinitionInput) (*ecs.DescribeTaskDefinitionOutput, error)
DescribeTaskDefinition describes an existing task definition.
func (*BasicClient) DescribeTasks ¶
func (c *BasicClient) DescribeTasks(ctx context.Context, in *ecs.DescribeTasksInput) (*ecs.DescribeTasksOutput, error)
DescribeTasks describes one or more existing tasks.
func (*BasicClient) ListTaskDefinitions ¶
func (c *BasicClient) ListTaskDefinitions(ctx context.Context, in *ecs.ListTaskDefinitionsInput) (*ecs.ListTaskDefinitionsOutput, error)
ListTaskDefinitions returns the ARNs for the task definitions that match the input filters.
func (*BasicClient) ListTasks ¶
func (c *BasicClient) ListTasks(ctx context.Context, in *ecs.ListTasksInput) (*ecs.ListTasksOutput, error)
ListTasks returns the ARNs for the task that match the input filters.
func (*BasicClient) RegisterTaskDefinition ¶
func (c *BasicClient) RegisterTaskDefinition(ctx context.Context, in *ecs.RegisterTaskDefinitionInput) (*ecs.RegisterTaskDefinitionOutput, error)
RegisterTaskDefinition registers a new task definition.
func (*BasicClient) RunTask ¶
func (c *BasicClient) RunTask(ctx context.Context, in *ecs.RunTaskInput) (*ecs.RunTaskOutput, error)
RunTask runs a new task.
func (*BasicClient) StopTask ¶
func (c *BasicClient) StopTask(ctx context.Context, in *ecs.StopTaskInput) (*ecs.StopTaskOutput, error)
StopTask stops a running task.
func (*BasicClient) TagResource ¶
func (c *BasicClient) TagResource(ctx context.Context, in *ecs.TagResourceInput) (*ecs.TagResourceOutput, error)
TagResource adds tags to an existing resource in ECS.
type BasicPod ¶
type BasicPod struct {
// contains filtered or unexported fields
}
BasicPod represents a pod that is backed by AWS ECS.
func NewBasicPod ¶
func NewBasicPod(opts ...*BasicPodOptions) (*BasicPod, error)
NewBasicPod initializes a new pod that is backed by ECS.
func (*BasicPod) LatestStatusInfo ¶
LatestStatusInfo returns the most up-to-date status information for the pod.
func (*BasicPod) Resources ¶
func (p *BasicPod) Resources() cocoa.ECSPodResources
Resources returns information about the resources used by the pod.
func (*BasicPod) StatusInfo ¶
func (p *BasicPod) StatusInfo() cocoa.ECSPodStatusInfo
StatusInfo returns the cached status information for the pod.
type BasicPodCreator ¶
type BasicPodCreator struct {
// contains filtered or unexported fields
}
BasicPodCreator provides a cocoa.ECSPodCreator implementation to create AWS ECS pods.
func NewBasicPodCreator ¶
func NewBasicPodCreator(opts BasicPodCreatorOptions) (*BasicPodCreator, error)
NewBasicPodCreator creates a new pod creator optionally backed by a cache.
func (*BasicPodCreator) CreatePod ¶
func (pc *BasicPodCreator) CreatePod(ctx context.Context, opts ...cocoa.ECSPodCreationOptions) (cocoa.ECSPod, error)
CreatePod creates a new pod backed by AWS ECS.
func (*BasicPodCreator) CreatePodFromExistingDefinition ¶
func (pc *BasicPodCreator) CreatePodFromExistingDefinition(ctx context.Context, def cocoa.ECSTaskDefinition, opts ...cocoa.ECSPodExecutionOptions) (cocoa.ECSPod, error)
CreatePodFromExistingDefinition creates a new pod backed by AWS ECS from an existing definition.
type BasicPodCreatorOptions ¶
type BasicPodCreatorOptions struct { Client cocoa.ECSClient Vault cocoa.Vault Cache cocoa.ECSPodDefinitionCache }
BasicPodCreatorOptions are options to create a basic ECS pod creator that's optionally backed by a cache.
func NewBasicPodCreatorOptions ¶
func NewBasicPodCreatorOptions() *BasicPodCreatorOptions
NewBasicPodCreatorOptions returns new uninitialized options to create a basic pod creator.
func (*BasicPodCreatorOptions) SetCache ¶
func (o *BasicPodCreatorOptions) SetCache(pdc cocoa.ECSPodDefinitionCache) *BasicPodCreatorOptions
SetCache sets the cache used to track pod definitions externally.
func (*BasicPodCreatorOptions) SetClient ¶
func (o *BasicPodCreatorOptions) SetClient(c cocoa.ECSClient) *BasicPodCreatorOptions
SetClient sets the client the pod creator uses to communicate with ECS.
func (*BasicPodCreatorOptions) SetVault ¶
func (o *BasicPodCreatorOptions) SetVault(v cocoa.Vault) *BasicPodCreatorOptions
SetVault sets the vault that the pod creator uses to manage secrets.
func (*BasicPodCreatorOptions) Validate ¶
func (o *BasicPodCreatorOptions) Validate() error
Validate checks that the required parameters to initialize a pod creator are given.
type BasicPodDefinitionManager ¶
type BasicPodDefinitionManager struct {
// contains filtered or unexported fields
}
BasicPodDefinitionManager manages pod definitions, which are configuration templates used to run pods. It can be optionally backed by an external cache to keep track of the pod definitions.
func NewBasicPodDefinitionManager ¶
func NewBasicPodDefinitionManager(opts BasicPodDefinitionManagerOptions) (*BasicPodDefinitionManager, error)
NewBasicPodDefinitionManager creates a new pod definition manager optionally backed by a cache.
func (*BasicPodDefinitionManager) CreatePodDefinition ¶
func (m *BasicPodDefinitionManager) CreatePodDefinition(ctx context.Context, opts ...cocoa.ECSPodDefinitionOptions) (*cocoa.ECSPodDefinitionItem, error)
CreatePodDefinition creates a pod definition and caches it if it is using a cache.
func (*BasicPodDefinitionManager) DeletePodDefinition ¶
func (m *BasicPodDefinitionManager) DeletePodDefinition(ctx context.Context, id string) error
DeletePodDefinition deletes a pod definition and deletes it from the cache if it is using a cache.
type BasicPodDefinitionManagerOptions ¶
type BasicPodDefinitionManagerOptions struct { Client cocoa.ECSClient Vault cocoa.Vault Cache cocoa.ECSPodDefinitionCache }
BasicPodDefinitionManagerOptions are options to create a basic ECS pod definition manager that's optionally backed by a cache.
func NewBasicPodDefinitionManagerOptions ¶
func NewBasicPodDefinitionManagerOptions() *BasicPodDefinitionManagerOptions
NewBasicPodDefinitionManagerOptions returns new uninitialized options to create a basic pod definition manager.
func (*BasicPodDefinitionManagerOptions) SetCache ¶
func (o *BasicPodDefinitionManagerOptions) SetCache(pdc cocoa.ECSPodDefinitionCache) *BasicPodDefinitionManagerOptions
SetCache sets the cache used to track pod definitions externally.
func (*BasicPodDefinitionManagerOptions) SetClient ¶
func (o *BasicPodDefinitionManagerOptions) SetClient(c cocoa.ECSClient) *BasicPodDefinitionManagerOptions
SetClient sets the client the pod manager uses to communicate with ECS.
func (*BasicPodDefinitionManagerOptions) SetVault ¶
func (o *BasicPodDefinitionManagerOptions) SetVault(v cocoa.Vault) *BasicPodDefinitionManagerOptions
SetVault sets the vault that the pod manager uses to manage secrets.
func (*BasicPodDefinitionManagerOptions) Validate ¶
func (o *BasicPodDefinitionManagerOptions) Validate() error
Validate checks that the required parameters to initialize a pod definition manager are given.
type BasicPodOptions ¶
type BasicPodOptions struct { Client cocoa.ECSClient Vault cocoa.Vault Resources *cocoa.ECSPodResources StatusInfo *cocoa.ECSPodStatusInfo }
BasicPodOptions are options to create a basic ECS pod.
func MergePodOptions ¶
func MergePodOptions(opts ...*BasicPodOptions) BasicPodOptions
MergePodOptions merges all the given options describing an ECS pod. Options are applied in the order that they're specified and conflicting options are overwritten.
func NewBasicPodOptions ¶
func NewBasicPodOptions() *BasicPodOptions
NewBasicPodOptions returns new uninitialized options to create a basic ECS pod.
func (*BasicPodOptions) SetClient ¶
func (o *BasicPodOptions) SetClient(c cocoa.ECSClient) *BasicPodOptions
SetClient sets the client the pod uses to communicate with ECS.
func (*BasicPodOptions) SetResources ¶
func (o *BasicPodOptions) SetResources(res cocoa.ECSPodResources) *BasicPodOptions
SetResources sets the resources used by the pod.
func (*BasicPodOptions) SetStatusInfo ¶
func (o *BasicPodOptions) SetStatusInfo(s cocoa.ECSPodStatusInfo) *BasicPodOptions
SetStatusInfo sets the current status for the pod.
func (*BasicPodOptions) SetVault ¶
func (o *BasicPodOptions) SetVault(v cocoa.Vault) *BasicPodOptions
SetVault sets the vault that the pod uses to manage secrets.
func (*BasicPodOptions) Validate ¶
func (o *BasicPodOptions) Validate() error
Validate checks that the required parameters to initialize a pod are given.
type ContainerInstanceStatus ¶
type ContainerInstanceStatus string
ContainerInstanceStatus represents a status from the ECS API for a container instance running tasks.
const ( // ContainerInstanceStatusRegistering indicates that the container instance // is registering with the cluster. For container instances using AWSVPC // trunking, this includes provisioning the trunk elastic network interface. ContainerInstanceStatusRegistering ContainerInstanceStatus = "REGISTERING" // ContainerInstanceStatusRegistrationFailed indicates that the container // instance attempted to register but failed. ContainerInstanceStatusRegistrationFailed ContainerInstanceStatus = "REGISTRATION_FAILED" // ContainerInstanceStatusActive indicates that the container instance is // ready to run tasks. When the container instance is active, ECS can // schedule tasks for placement on it. ContainerInstanceStatusActive ContainerInstanceStatus = "ACTIVE" // ContainerInstanceStatusDeregistering indicates that the container // instance is deregistering from the cluster. For container instances using // AWSVPC trunking, this includes deprovisioning the trunk elastic network // interface. ContainerInstanceStatusDeregistering ContainerInstanceStatus = "DEREGISTERING" // ContainerInstanceStatusInactive indicates that the container instance has // been terminated and deregistered from the cluster. ContainerInstanceStatusInactive ContainerInstanceStatus = "INACTIVE" // ContainerInstanceStatusDraining indicates that the container instance is // running, but ECS will not schedule new tasks for placement on it. ContainerInstanceStatusDraining ContainerInstanceStatus = "DRAINING" )
Constants representing ECS container instance states.
type TaskStatus ¶
type TaskStatus string
TaskStatus represents a status from the ECS API for either a task or a container.
const ( // TaskStatusProvisioning indicates that ECS is performing additional work // before launching the task (e.g. provisioning a network interface for // AWSVPC). TaskStatusProvisioning TaskStatus = "PROVISIONING" // TaskStatusPending is a transition state indicating that ECS is waiting // for the container agent to act. TaskStatusPending TaskStatus = "PENDING" // TaskStatusActivating indicates that the task is launched but needs to // perform additional work before the task is fully running (e.g. service // discovery setup). TaskStatusActivating TaskStatus = "ACTIVATING" // TaskStatusRunning indicates that the task is running. TaskStatusRunning TaskStatus = "RUNNING" // TaskStatusDeactivating indicates that the task is preparing to stop but // needs to perform additional work first (e.g. deregistering load balancer // target groups). TaskStatusDeactivating TaskStatus = "DEACTIVATING" // TaskStatusStopping is a transition state indicating that ECS is waiting // for the container agent to act. TaskStatusStopping TaskStatus = "STOPPING" // TaskStatusDeprovisioning indicates that the task is no longer running but // needs to perform additional work before the task is fully stopped (e.g. // detaching the network interface for AWSVPC). TaskStatusDeprovisioning TaskStatus = "DEPROVISIONING" // TaskStatusStopped indicates that the task is stopped. TaskStatusStopped TaskStatus = "STOPPED" )
Constants representing ECS task or container states.
func (TaskStatus) After ¶
func (s TaskStatus) After(other TaskStatus) bool
After returns whether or not this task status occurs later in the ECS task lifecycle than the other task status. Docs: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-lifecycle.html
func (TaskStatus) Before ¶
func (s TaskStatus) Before(other TaskStatus) bool
Before returns whether or not this task status occurs earlier in the ECS task lifecycle than the other task status. Docs: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-lifecycle.html
func (TaskStatus) ToCocoaStatus ¶
func (s TaskStatus) ToCocoaStatus() cocoa.ECSStatus
ToCocoaStatus converts a task or container ECS status into its equivalent Cocoa status.