ecs

package
v0.0.0-...-69a3ef4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 15 Imported by: 2

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

View Source
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

func ConvertFailureToError(f types.Failure) error

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

func ExportTags

func ExportTags(tags map[string]string) []types.Tag

ExportTags converts a mapping of tag names to values into ECS tags.

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

func (c *BasicClient) Close(ctx context.Context) error

Close cleans up all resources owned by the client.

func (*BasicClient) DeregisterTaskDefinition

DeregisterTaskDefinition deregisters an existing task definition.

func (*BasicClient) DescribeTaskDefinition

DescribeTaskDefinition describes an existing task definition.

func (*BasicClient) DescribeTasks

DescribeTasks describes one or more existing tasks.

func (*BasicClient) ListTaskDefinitions

ListTaskDefinitions returns the ARNs for the task definitions that match the input filters.

func (*BasicClient) ListTasks

ListTasks returns the ARNs for the task that match the input filters.

func (*BasicClient) RegisterTaskDefinition

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

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

func (p *BasicPod) Delete(ctx context.Context) error

Delete deletes the pod and its owned resources.

func (*BasicPod) LatestStatusInfo

func (p *BasicPod) LatestStatusInfo(ctx context.Context) (*cocoa.ECSPodStatusInfo, error)

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.

func (*BasicPod) Stop

func (p *BasicPod) Stop(ctx context.Context) error

Stop stops the running pod without cleaning up any of its underlying resources.

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

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

SetCache sets the cache used to track pod definitions externally.

func (*BasicPodCreatorOptions) SetClient

SetClient sets the client the pod creator uses to communicate with ECS.

func (*BasicPodCreatorOptions) SetVault

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

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

SetCache sets the cache used to track pod definitions externally.

func (*BasicPodDefinitionManagerOptions) SetClient

SetClient sets the client the pod manager uses to communicate with ECS.

func (*BasicPodDefinitionManagerOptions) SetVault

SetVault sets the vault that the pod manager uses to manage secrets.

func (*BasicPodDefinitionManagerOptions) Validate

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

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

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.

Jump to

Keyboard shortcuts

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