container

package
v1.50.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DockerHealthCheckType is the type of container health check provided by docker
	DockerHealthCheckType = "docker"

	// AuthTypeECR is to use image pull auth over ECR
	AuthTypeECR = "ecr"

	// AuthTypeASM is to use image pull auth over AWS Secrets Manager
	AuthTypeASM = "asm"

	// MetadataURIEnvironmentVariableName defines the name of the environment
	// variable in containers' config, which can be used by the containers to access the
	// v3 metadata endpoint
	MetadataURIEnvironmentVariableName = "ECS_CONTAINER_METADATA_URI"

	// MetadataURIEnvVarNameV4 defines the name of the environment
	// variable in containers' config, which can be used by the containers to access the
	// v4 metadata endpoint
	MetadataURIEnvVarNameV4 = "ECS_CONTAINER_METADATA_URI_V4"

	// MetadataURIFormat defines the URI format for v4 metadata endpoint
	MetadataURIFormatV4 = "http://169.254.170.2/v4/%s"

	// SecretProviderSSM is to show secret provider being SSM
	SecretProviderSSM = "ssm"

	// SecretProviderASM is to show secret provider being ASM
	SecretProviderASM = "asm"

	// SecretTypeEnv is to show secret type being ENVIRONMENT_VARIABLE
	SecretTypeEnv = "ENVIRONMENT_VARIABLE"

	// TargetLogDriver is to show secret target being "LOG_DRIVER", the default will be "CONTAINER"
	SecretTargetLogDriver = "LOG_DRIVER"
)
View Source
const (
	// UnrecognizedTransportProtocolErrorName is an error where the protocol of the binding is invalid
	UnrecognizedTransportProtocolErrorName = "UnrecognizedTransportProtocol"
	// UnparseablePortErrorName is an error where the port configuration is invalid
	UnparseablePortErrorName = "UnparsablePort"
)
View Source
const (
	// DockerContainerMinimumMemoryInBytes is the minimum amount of
	// memory to be allocated to a docker container
	DockerContainerMinimumMemoryInBytes = 4 * 1024 * 1024 // 4MB
)

Variables

View Source
var (
	// MetadataURIFormat defines the URI format for v3 metadata endpoint. Made as a var to be able to
	// overwrite it in test.
	MetadataURIFormat = "http://169.254.170.2/v3/%s"
)

Functions

This section is empty.

Types

type ASMAuthData

type ASMAuthData struct {
	// CredentialsParameter is set by ACS and specifies the name of the
	// parameter to retrieve from ASM
	CredentialsParameter string `json:"credentialsParameter"`
	// Region is set by ACS and specifies the region to fetch the
	// secret from
	Region string `json:"region"`
	// contains filtered or unexported fields
}

ASMAuthData is the authentication data required for Docker private registry auth

func (*ASMAuthData) GetDockerAuthConfig

func (auth *ASMAuthData) GetDockerAuthConfig() types.AuthConfig

GetDockerAuthConfig returns the pull credentials in the auth

func (*ASMAuthData) SetDockerAuthConfig

func (auth *ASMAuthData) SetDockerAuthConfig(dac types.AuthConfig)

SetDockerAuthConfig sets the credentials to pull from ECR in the auth

type Container

type Container struct {
	// Name is the name of the container specified in the task definition
	Name string
	// RuntimeID is the docker id of the container
	RuntimeID string
	// TaskARNUnsafe is the task ARN of the task that the container belongs to. Access should be
	// protected by lock i.e. via GetTaskARN and SetTaskARN.
	TaskARNUnsafe string `json:"taskARN"`
	// DependsOnUnsafe is the field which specifies the ordering for container startup and shutdown.
	DependsOnUnsafe []DependsOn `json:"dependsOn,omitempty"`
	// ManagedAgentsUnsafe presently contains only the executeCommandAgent
	ManagedAgentsUnsafe []ManagedAgent `json:"managedAgents,omitempty"`
	// V3EndpointID is a container identifier used to construct v3 metadata endpoint; it's unique among
	// all the containers managed by the agent
	V3EndpointID string
	// Image is the image name specified in the task definition
	Image string
	// ImageID is the local ID of the image used in the container
	ImageID string
	// ImageDigest is the sha-256 digest of the container image as pulled from the repository
	ImageDigest string
	// Command is the command to run in the container which is specified in the task definition
	Command []string
	// CPU is the cpu limitation of the container which is specified in the task definition
	CPU uint `json:"Cpu"`
	// GPUIDs is the list of GPU ids for a container
	GPUIDs []string
	// Memory is the memory limitation of the container which is specified in the task definition
	Memory uint
	// Links contains a list of containers to link, corresponding to docker option: --link
	Links []string
	// FirelensConfig contains configuration for a Firelens container
	FirelensConfig *FirelensConfig `json:"firelensConfiguration"`
	// VolumesFrom contains a list of container's volume to use, corresponding to docker option: --volumes-from
	VolumesFrom []VolumeFrom `json:"volumesFrom"`
	// MountPoints contains a list of volume mount paths
	MountPoints []MountPoint `json:"mountPoints"`
	// Ports contains a list of ports binding configuration
	Ports []PortBinding `json:"portMappings"`
	// Secrets contains a list of secret
	Secrets []Secret `json:"secrets"`
	// Essential denotes whether the container is essential or not
	Essential bool
	// EntryPoint is entrypoint of the container, corresponding to docker option: --entrypoint
	EntryPoint *[]string
	// Environment is the environment variable set in the container
	Environment map[string]string `json:"environment"`
	// EnvironmentFiles is the list of environmentFile used to populate environment variables
	EnvironmentFiles []EnvironmentFile `json:"environmentFiles"`
	// Overrides contains the configuration to override of a container
	Overrides ContainerOverrides `json:"overrides"`
	// DockerConfig is the configuration used to create the container
	DockerConfig DockerConfig `json:"dockerConfig"`
	// RegistryAuthentication is the auth data used to pull image
	RegistryAuthentication *RegistryAuthenticationData `json:"registryAuthentication"`
	// HealthCheckType is the mechanism to use for the container health check
	// currently it only supports 'DOCKER'
	HealthCheckType string `json:"healthCheckType,omitempty"`
	// Health contains the health check information of container health check
	Health HealthStatus `json:"-"`
	// LogsAuthStrategy specifies how the logs driver for the container will be
	// authenticated
	LogsAuthStrategy string
	// StartTimeout specifies the time value after which if a container has a dependency
	// on another container and the dependency conditions are 'SUCCESS', 'COMPLETE', 'HEALTHY',
	// then that dependency will not be resolved.
	StartTimeout uint
	// StopTimeout specifies the time value to be passed as StopContainer api call
	StopTimeout uint

	// DesiredStatusUnsafe represents the state where the container should go. Generally,
	// the desired status is informed by the ECS backend as a result of either
	// API calls made to ECS or decisions made by the ECS service scheduler,
	// though the agent may also set the DesiredStatusUnsafe if a different "essential"
	// container in the task exits. The DesiredStatus is almost always either
	// ContainerRunning or ContainerStopped.
	// NOTE: Do not access DesiredStatusUnsafe directly.  Instead, use `GetDesiredStatus`
	// and `SetDesiredStatus`.
	// TODO DesiredStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON
	// is handled properly so that the state storage continues to work.
	DesiredStatusUnsafe apicontainerstatus.ContainerStatus `json:"desiredStatus"`

	// KnownStatusUnsafe represents the state where the container is.
	// NOTE: Do not access `KnownStatusUnsafe` directly.  Instead, use `GetKnownStatus`
	// and `SetKnownStatus`.
	// TODO KnownStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON
	// is handled properly so that the state storage continues to work.
	KnownStatusUnsafe apicontainerstatus.ContainerStatus `json:"KnownStatus"`

	// TransitionDependenciesMap is a map of the dependent container status to other
	// dependencies that must be satisfied in order for this container to transition.
	TransitionDependenciesMap TransitionDependenciesMap `json:"TransitionDependencySet"`

	// SteadyStateDependencies is a list of containers that must be in "steady state" before
	// this one is created
	// Note: Current logic requires that the containers specified here are run
	// before this container can even be pulled.
	//
	// Deprecated: Use TransitionDependencySet instead. SteadyStateDependencies is retained for compatibility with old
	// state files.
	SteadyStateDependencies []string `json:"RunDependencies"`

	// Type specifies the container type. Except the 'Normal' type, all other types
	// are not directly specified by task definitions, but created by the agent. The
	// JSON tag is retained as this field's previous name 'IsInternal' for maintaining
	// backwards compatibility. Please see JSON parsing hooks for this type for more
	// details
	Type ContainerType `json:"IsInternal"`

	// AppliedStatus is the status that has been "applied" (e.g., we've called Pull,
	// Create, Start, or Stop) but we don't yet know that the application was successful.
	// No need to save it in the state file, as agent will synchronize the container status
	// on restart and for some operation eg: pull, it has to be recalled again.
	AppliedStatus apicontainerstatus.ContainerStatus `json:"-"`
	// ApplyingError is an error that occurred trying to transition the container
	// to its desired state. It is propagated to the backend in the form
	// 'Name: ErrorString' as the 'reason' field.
	ApplyingError *apierrors.DefaultNamedError

	// SentStatusUnsafe represents the last KnownStatusUnsafe that was sent to the ECS
	// SubmitContainerStateChange API.
	// TODO SentStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON is
	// handled properly so that the state storage continues to work.
	SentStatusUnsafe apicontainerstatus.ContainerStatus `json:"SentStatus"`

	// MetadataFileUpdated is set to true when we have completed updating the
	// metadata file
	MetadataFileUpdated bool `json:"metadataFileUpdated"`

	// KnownExitCodeUnsafe specifies the exit code for the container.
	// It is exposed outside of the package so that it's marshalled/unmarshalled in
	// the JSON body while saving the state.
	// NOTE: Do not access KnownExitCodeUnsafe directly. Instead, use `GetKnownExitCode`
	// and `SetKnownExitCode`.
	KnownExitCodeUnsafe *int `json:"KnownExitCode"`

	// KnownPortBindingsUnsafe is an array of port bindings for the container.
	KnownPortBindingsUnsafe []PortBinding `json:"KnownPortBindings"`

	// VolumesUnsafe is an array of volume mounts in the container.
	VolumesUnsafe []types.MountPoint `json:"-"`

	// NetworkModeUnsafe is the network mode in which the container is started
	NetworkModeUnsafe string `json:"-"`

	// NetworksUnsafe denotes the Docker Network Settings in the container.
	NetworkSettingsUnsafe *types.NetworkSettings `json:"-"`

	// SteadyStateStatusUnsafe specifies the steady state status for the container
	// If uninitialized, it's assumed to be set to 'ContainerRunning'. Even though
	// it's not only supposed to be set when the container is being created, it's
	// exposed outside of the package so that it's marshalled/unmarshalled in the
	// the JSON body while saving the state
	SteadyStateStatusUnsafe *apicontainerstatus.ContainerStatus `json:"SteadyStateStatus,omitempty"`

	// ContainerArn is the Arn of this container.
	ContainerArn string `json:"ContainerArn,omitempty"`
	// contains filtered or unexported fields
}

Container is the internal representation of a container in the ECS agent

func NewContainerWithSteadyState

func NewContainerWithSteadyState(steadyState apicontainerstatus.ContainerStatus) *Container

NewContainerWithSteadyState creates a new Container object with the specified steady state. Containers that need the non default steady state set will use this method instead of setting it directly

func (*Container) AWSLogAuthExecutionRole

func (c *Container) AWSLogAuthExecutionRole() bool

AWSLogAuthExecutionRole returns true if the auth is by execution role

func (*Container) AddContainerDependency added in v1.30.0

func (c *Container) AddContainerDependency(name string, condition string)

AddContainerDependency adds a container dependency to a container.

func (*Container) BuildContainerDependency

func (c *Container) BuildContainerDependency(contName string,
	satisfiedStatus apicontainerstatus.ContainerStatus,
	dependentStatus apicontainerstatus.ContainerStatus)

BuildContainerDependency adds a new dependency container and satisfied status to the dependent container

func (*Container) BuildResourceDependency

func (c *Container) BuildResourceDependency(resourceName string,
	requiredStatus resourcestatus.ResourceStatus,
	dependentStatus apicontainerstatus.ContainerStatus)

BuildResourceDependency adds a new resource dependency by taking in the required status of the resource that satisfies the dependency and the dependent container status, whose transition is dependent on the resource. example: if container's PULLED transition is dependent on volume resource's CREATED status, then RequiredStatus=VolumeCreated and dependentStatus=ContainerPulled

func (*Container) DependsOnContainer added in v1.30.0

func (c *Container) DependsOnContainer(name string) bool

DependsOnContainer checks whether a container depends on another container.

func (*Container) DesiredTerminal

func (c *Container) DesiredTerminal() bool

DesiredTerminal returns true if the container's desired status is STOPPED

func (*Container) GetAppliedStatus

func (c *Container) GetAppliedStatus() apicontainerstatus.ContainerStatus

GetAppliedStatus returns the transitioning status of container

func (*Container) GetCreatedAt

func (c *Container) GetCreatedAt() time.Time

GetCreatedAt sets the timestamp for container's creation time

func (*Container) GetCredentialSpec added in v1.34.0

func (c *Container) GetCredentialSpec() (string, error)

GetCredentialSpec is used to retrieve the current credentialspec resource

func (*Container) GetDependsOn added in v1.30.0

func (c *Container) GetDependsOn() []DependsOn

func (*Container) GetDesiredStatus

func (c *Container) GetDesiredStatus() apicontainerstatus.ContainerStatus

GetDesiredStatus gets the desired status of the container

func (*Container) GetEnvironmentFiles added in v1.39.0

func (c *Container) GetEnvironmentFiles() []EnvironmentFile

GetEnvironmentFiles returns the container's environment files.

func (*Container) GetFinishedAt

func (c *Container) GetFinishedAt() time.Time

GetFinishedAt sets the timestamp for container's stopped time

func (*Container) GetFirelensConfig added in v1.30.0

func (c *Container) GetFirelensConfig() *FirelensConfig

GetFirelensConfig returns the container's firelens config.

func (*Container) GetHealthStatus

func (c *Container) GetHealthStatus() HealthStatus

GetHealthStatus returns the container health information

func (*Container) GetHostConfig added in v1.30.0

func (c *Container) GetHostConfig() *string

GetHostConfig returns the container's host config.

func (*Container) GetImageDigest added in v1.31.0

func (c *Container) GetImageDigest() string

GetImageDigest gets the ImageDigest for a container

func (*Container) GetKnownExitCode

func (c *Container) GetKnownExitCode() *int

GetKnownExitCode returns the container exit code

func (*Container) GetKnownPortBindings

func (c *Container) GetKnownPortBindings() []PortBinding

GetKnownPortBindings gets the ports for a container

func (*Container) GetKnownStatus

func (c *Container) GetKnownStatus() apicontainerstatus.ContainerStatus

GetKnownStatus returns the known status of the container

func (*Container) GetLabels

func (c *Container) GetLabels() map[string]string

GetLabels gets the labels for a container

func (*Container) GetLogDriver added in v1.30.0

func (c *Container) GetLogDriver() string

GetLogDriver returns the log driver used by the container.

func (*Container) GetLogOptions added in v1.45.0

func (c *Container) GetLogOptions() map[string]string

GetLogOptions gets the log 'options' map passed into the task definition. see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html

func (*Container) GetManagedAgentByName added in v1.50.0

func (c *Container) GetManagedAgentByName(agentName string) (ManagedAgent, bool)

GetManagedAgentByName retrieves the managed agent with the name specified and a boolean indicating whether an agent was found or not. note: a zero value for ManagedAgent if the name is not known to this container.

func (*Container) GetManagedAgentSentStatus added in v1.50.0

func (c *Container) GetManagedAgentSentStatus(agentName string) apicontainerstatus.ManagedAgentStatus

func (*Container) GetManagedAgentStatus added in v1.50.0

func (c *Container) GetManagedAgentStatus(agentName string) apicontainerstatus.ManagedAgentStatus

func (*Container) GetManagedAgents added in v1.50.0

func (c *Container) GetManagedAgents() []ManagedAgent

GetManagedAgents returns the managed agents configured for this container

func (*Container) GetNetworkMode added in v1.25.3

func (c *Container) GetNetworkMode() string

GetNetworkMode returns the network mode of the container

func (*Container) GetNetworkModeFromHostConfig added in v1.31.0

func (c *Container) GetNetworkModeFromHostConfig() string

GetNetworkModeFromHostConfig returns the network mode used by the container from the host config .

func (*Container) GetNetworkSettings added in v1.25.3

func (c *Container) GetNetworkSettings() *types.NetworkSettings

GetNetworkSettings returns the networks field in a container

func (*Container) GetNextKnownStateProgression

func (c *Container) GetNextKnownStateProgression() apicontainerstatus.ContainerStatus

GetNextKnownStateProgression returns the state that the container should progress to based on its `KnownState`. The progression is incremental until the container reaches its steady state. From then on, it transitions to `ContainerStopped`.

For example: a. if the steady state of the container is defined as `ContainerRunning`, the progression is: Container: None -> Pulled -> Created -> Running* -> Stopped -> Zombie

b. if the steady state of the container is defined as `ContainerResourcesProvisioned`, the progression is: Container: None -> Pulled -> Created -> Running -> Provisioned* -> Stopped -> Zombie

c. if the steady state of the container is defined as `ContainerCreated`, the progression is: Container: None -> Pulled -> Created* -> Stopped -> Zombie

func (*Container) GetRuntimeID added in v1.30.0

func (c *Container) GetRuntimeID() string

GetRuntimeID gets the DockerID for a container

func (*Container) GetSentStatus

func (c *Container) GetSentStatus() apicontainerstatus.ContainerStatus

GetSentStatus safely returns the SentStatusUnsafe of the container

func (*Container) GetStartTimeout added in v1.26.0

func (c *Container) GetStartTimeout() time.Duration

func (*Container) GetStartedAt

func (c *Container) GetStartedAt() time.Time

GetStartedAt sets the timestamp for container's start time

func (*Container) GetSteadyStateStatus

func (c *Container) GetSteadyStateStatus() apicontainerstatus.ContainerStatus

GetSteadyStateStatus returns the steady state status for the container. If Container.steadyState is not initialized, the default steady state status defined by `defaultContainerSteadyStateStatus` is returned. The 'pause' container's steady state differs from that of other containers, as the 'pause' container can reach its teady state once networking resources have been provisioned for it, which is done in the `ContainerResourcesProvisioned` state

func (*Container) GetStopTimeout added in v1.26.0

func (c *Container) GetStopTimeout() time.Duration

func (*Container) GetTaskARN added in v1.44.0

func (c *Container) GetTaskARN() string

GetTaskARN returns the task arn of the container.

func (*Container) GetV3EndpointID added in v1.21.0

func (c *Container) GetV3EndpointID() string

GetV3EndpointID returns the v3 endpoint id of container

func (*Container) GetVolumes added in v1.20.2

func (c *Container) GetVolumes() []types.MountPoint

GetVolumes returns the volumes mounted in a container

func (*Container) HasContainerDependencies added in v1.30.0

func (c *Container) HasContainerDependencies() bool

HasContainerDependencies checks whether a container has any container dependency.

func (*Container) HasNotAndWillNotStart added in v1.48.1

func (c *Container) HasNotAndWillNotStart() bool

HasNotAndWillNotStart returns true if the container has never started, and is not going to start in the future. This is true if the following are all true: 1. Container's known status is earlier than running; 2. Container's desired status is stopped; 3. Container is not in the middle a transition (indicated by applied status is none status).

func (*Container) HasSecret added in v1.30.0

func (c *Container) HasSecret(f func(s Secret) bool) bool

HasSecret returns whether a container has secret based on a certain condition.

func (*Container) HealthStatusShouldBeReported

func (c *Container) HealthStatusShouldBeReported() bool

HealthStatusShouldBeReported returns true if the health check is defined in the task definition

func (*Container) InjectV3MetadataEndpoint added in v1.21.0

func (c *Container) InjectV3MetadataEndpoint()

InjectV3MetadataEndpoint injects the v3 metadata endpoint as an environment variable for a container

func (*Container) InjectV4MetadataEndpoint added in v1.39.0

func (c *Container) InjectV4MetadataEndpoint()

InjectV4MetadataEndpoint injects the v4 metadata endpoint as an environment variable for a container

func (*Container) IsEssential

func (c *Container) IsEssential() bool

IsEssential returns whether the container is an essential container or not

func (*Container) IsInternal

func (c *Container) IsInternal() bool

IsInternal returns true if the container type is `ContainerCNIPause` or `ContainerNamespacePause`. It returns false otherwise

func (*Container) IsKnownSteadyState

func (c *Container) IsKnownSteadyState() bool

IsKnownSteadyState returns true if the `KnownState` of the container equals the `steadyState` defined for the container

func (*Container) IsMetadataFileUpdated

func (c *Container) IsMetadataFileUpdated() bool

IsMetadataFileUpdated returns true if the metadata file has been once the metadata file is ready and will no longer change

func (*Container) IsRunning

func (c *Container) IsRunning() bool

IsRunning returns true if the container's known status is either RUNNING or RESOURCES_PROVISIONED. It returns false otherwise

func (*Container) KnownTerminal

func (c *Container) KnownTerminal() bool

KnownTerminal returns true if the container's known status is STOPPED

func (*Container) MarshalJSON added in v1.35.0

func (c *Container) MarshalJSON() ([]byte, error)

MarshalJSON wraps Go's marshalling logic with a necessary read lock.

func (*Container) MergeEnvironmentVariables added in v1.22.0

func (c *Container) MergeEnvironmentVariables(envVars map[string]string)

MergeEnvironmentVariables appends additional envVarName:envVarValue pairs to the the container's environment values structure

func (*Container) MergeEnvironmentVariablesFromEnvfiles added in v1.39.0

func (c *Container) MergeEnvironmentVariablesFromEnvfiles(envVarsList []map[string]string) error

MergeEnvironmentVariablesFromEnvfiles appends environment variable pairs from the retrieved envfiles to the container's environment values list envvars from envfiles will have lower precedence than existing envvars

func (*Container) RequireNeuronRuntime added in v1.41.0

func (c *Container) RequireNeuronRuntime() bool

RequireNeuronRuntime checks if the container needs to use the neuron runtime.

func (*Container) RequiresCredentialSpec added in v1.34.0

func (c *Container) RequiresCredentialSpec() bool

RequiresCredentialSpec checks if container needs a credentialspec resource

func (*Container) SetASMDockerAuthConfig

func (c *Container) SetASMDockerAuthConfig(dac types.AuthConfig)

SetASMDockerAuthConfig add the docker auth config data to the RegistryAuthentication struct held by the container, this is then passed down to the docker client to pull the image

func (*Container) SetAppliedStatus

func (c *Container) SetAppliedStatus(status apicontainerstatus.ContainerStatus) bool

SetAppliedStatus sets the applied status of container and returns whether the container is already in a transition

func (*Container) SetCreatedAt

func (c *Container) SetCreatedAt(createdAt time.Time)

SetCreatedAt sets the timestamp for container's creation time

func (*Container) SetDependsOn added in v1.30.0

func (c *Container) SetDependsOn(dependsOn []DependsOn)

func (*Container) SetDesiredStatus

func (c *Container) SetDesiredStatus(status apicontainerstatus.ContainerStatus)

SetDesiredStatus sets the desired status of the container

func (*Container) SetFinishedAt

func (c *Container) SetFinishedAt(finishedAt time.Time)

SetFinishedAt sets the timestamp for container's stopped time

func (*Container) SetHealthStatus

func (c *Container) SetHealthStatus(health HealthStatus)

SetHealthStatus sets the container health status

func (*Container) SetImageDigest added in v1.31.0

func (c *Container) SetImageDigest(ImageDigest string)

SetImageDigest sets the ImageDigest for a container

func (*Container) SetKnownExitCode

func (c *Container) SetKnownExitCode(i *int)

SetKnownExitCode sets exit code field in container struct

func (*Container) SetKnownPortBindings

func (c *Container) SetKnownPortBindings(ports []PortBinding)

SetKnownPortBindings sets the ports for a container

func (*Container) SetKnownStatus

func (c *Container) SetKnownStatus(status apicontainerstatus.ContainerStatus)

SetKnownStatus sets the known status of the container and update the container applied status

func (*Container) SetLabels

func (c *Container) SetLabels(labels map[string]string)

SetLabels sets the labels for a container

func (*Container) SetMetadataFileUpdated

func (c *Container) SetMetadataFileUpdated()

SetMetadataFileUpdated sets the container's MetadataFileUpdated status to true

func (*Container) SetNetworkMode added in v1.25.3

func (c *Container) SetNetworkMode(networkMode string)

SetNetworkMode sets the network mode of the container

func (*Container) SetNetworkSettings added in v1.25.3

func (c *Container) SetNetworkSettings(networks *types.NetworkSettings)

SetNetworkSettings sets the networks field in a container

func (*Container) SetRegistryAuthCredentials

func (c *Container) SetRegistryAuthCredentials(credential credentials.IAMRoleCredentials)

SetRegistryAuthCredentials sets the credentials for pulling image from ECR

func (*Container) SetRuntimeID added in v1.30.0

func (c *Container) SetRuntimeID(RuntimeID string)

SetRuntimeID sets the DockerID for a container

func (*Container) SetSentStatus

func (c *Container) SetSentStatus(status apicontainerstatus.ContainerStatus)

SetSentStatus safely sets the SentStatusUnsafe of the container

func (*Container) SetStartedAt

func (c *Container) SetStartedAt(startedAt time.Time)

SetStartedAt sets the timestamp for container's start time

func (*Container) SetTaskARN added in v1.44.0

func (c *Container) SetTaskARN(arn string)

SetTaskARN sets the task arn of the container.

func (*Container) SetV3EndpointID added in v1.21.0

func (c *Container) SetV3EndpointID(v3EndpointID string)

SetV3EndpointID sets the v3 endpoint id of container

func (*Container) SetVolumes added in v1.20.2

func (c *Container) SetVolumes(volumes []types.MountPoint)

SetVolumes sets the volumes mounted in a container

func (*Container) ShouldCreateWithASMSecret added in v1.23.0

func (c *Container) ShouldCreateWithASMSecret() bool

ShouldCreateWithASMSecret returns true if this container needs to get secret value from AWS Secrets Manager

func (*Container) ShouldCreateWithEnvFiles added in v1.39.0

func (c *Container) ShouldCreateWithEnvFiles() bool

ShouldCreateWithEnvFiles returns true if this container needs to retrieve environment variable files

func (*Container) ShouldCreateWithSSMSecret added in v1.22.0

func (c *Container) ShouldCreateWithSSMSecret() bool

ShouldCreateWithSSMSecret returns true if this container needs to get secret value from SSM Parameter Store

func (*Container) ShouldPullWithASMAuth

func (c *Container) ShouldPullWithASMAuth() bool

ShouldPullWithASMAuth returns true if this container needs to retrieve private registry authentication data from ASM

func (*Container) ShouldPullWithExecutionRole

func (c *Container) ShouldPullWithExecutionRole() bool

ShouldPullWithExecutionRole returns whether this container has its own ECR credentials

func (*Container) String

func (c *Container) String() string

String returns a human readable string representation of this object

func (*Container) UpdateManagedAgentByName added in v1.50.0

func (c *Container) UpdateManagedAgentByName(agentName string, state ManagedAgentState) bool

UpdateManagedAgentByName updates the state of the managed agent with the name specified. If the agent is not found, this method returns false.

func (*Container) UpdateManagedAgentSentStatus added in v1.50.0

func (c *Container) UpdateManagedAgentSentStatus(agentName string, status apicontainerstatus.ManagedAgentStatus) bool

UpdateManagedAgentSentStatus updates the sent status of the managed agent with the name specified. If the agent is not found, this method returns false.

func (*Container) UpdateManagedAgentStatus added in v1.50.0

func (c *Container) UpdateManagedAgentStatus(agentName string, status apicontainerstatus.ManagedAgentStatus) bool

UpdateManagedAgentStatus updates the status of the managed agent with the name specified. If the agent is not found, this method returns false.

type ContainerDependency

type ContainerDependency struct {
	// ContainerName defines the container on which a transition depends
	ContainerName string `json:"ContainerName"`
	// SatisfiedStatus defines the status that satisfies the dependency
	SatisfiedStatus apicontainerstatus.ContainerStatus `json:"SatisfiedStatus"`
	// DependentStatus defines the status that cannot be reached until the
	// resource satisfies the dependency
	DependentStatus apicontainerstatus.ContainerStatus `json:"DependentStatus,omitempty"`
}

ContainerDependency defines the relationship between a dependent container and its dependency.

type ContainerOverrides

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

ContainerOverrides are overrides applied to the container

func (*ContainerOverrides) UnmarshalJSON

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

UnmarshalJSON overrides the logic for parsing the JSON-encoded ContainerOverrides data 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

ContainerOverridesCopy is a type alias that doesn't have a custom unmarshaller so we can unmarshal ContainerOverrides data into something without recursing

type ContainerType

type ContainerType int32

ContainerType represents the type of the internal container created

const (
	// ContainerNormal represents the container type for 'Normal' containers
	// These are the ones specified in the task definition via container
	// definitions
	ContainerNormal ContainerType = iota
	// ContainerEmptyHostVolume represents the internal container type
	// for the empty volumes container
	ContainerEmptyHostVolume
	// ContainerCNIPause represents the internal container type for the
	// pause container
	ContainerCNIPause

	// ContainerNamespacePause represents the internal container type for
	// sharing either PID or IPC resource namespaces. Regardless if one or
	// both flags are used, only 1 of these containers need to be active
	ContainerNamespacePause
)

func (*ContainerType) MarshalJSON

func (containerType *ContainerType) MarshalJSON() ([]byte, error)

MarshalJSON overrides the logic for JSON-encoding a ContainerType object

func (ContainerType) String

func (containerType ContainerType) String() string

String converts the container type enum to a string

func (*ContainerType) UnmarshalJSON

func (containerType *ContainerType) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the container type field in the JSON encoded string into the ContainerType object

type DependsOn added in v1.26.0

type DependsOn struct {
	ContainerName string `json:"containerName"`
	Condition     string `json:"condition"`
}

type DockerConfig

type DockerConfig struct {
	// Config is the configuration used to create container
	Config *string `json:"config"`
	// HostConfig is the configuration of container related to host resource
	HostConfig *string `json:"hostConfig"`
	// Version specifies the docker client API version to use
	Version *string `json:"version"`
}

DockerConfig represents additional metadata about a container to run. It's remodeled from the `ecsacs` api model file. Eventually it should not exist once this remodeling is refactored out.

type DockerContainer

type DockerContainer struct {
	DockerID   string `json:"DockerId"`
	DockerName string // needed for linking

	Container *Container
}

DockerContainer 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

String returns a human readable string representation of DockerContainer

type DockerEventType

type DockerEventType int

DockerEventType represents the type of docker events

const (
	// ContainerStatusEvent represents the container status change events from docker
	// currently create, start, stop, die, restart and oom event will have this type
	ContainerStatusEvent DockerEventType = iota
	// ContainerHealthEvent represents the container health status event from docker
	// "health_status: unhealthy" and "health_status: healthy" will have this type
	ContainerHealthEvent
)

func (DockerEventType) String

func (eventType DockerEventType) String() string

type ECRAuthData

type ECRAuthData struct {
	EndpointOverride string `json:"endpointOverride"`
	Region           string `json:"region"`
	RegistryID       string `json:"registryId"`
	UseExecutionRole bool   `json:"useExecutionRole"`
	// contains filtered or unexported fields
}

ECRAuthData is the authentication details for ECR specifying the region, registryID, and possible endpoint override

func (*ECRAuthData) GetDockerAuthConfig added in v1.28.1

func (auth *ECRAuthData) GetDockerAuthConfig() types.AuthConfig

GetDockerAuthConfig returns the pull credentials in the auth

func (*ECRAuthData) GetPullCredentials

func (auth *ECRAuthData) GetPullCredentials() credentials.IAMRoleCredentials

GetPullCredentials returns the pull credentials in the auth

func (*ECRAuthData) SetDockerAuthConfig added in v1.28.1

func (auth *ECRAuthData) SetDockerAuthConfig(dac types.AuthConfig)

SetDockerAuthConfig sets the credentials to pull from ECR in the ecr auth data

func (*ECRAuthData) SetPullCredentials

func (auth *ECRAuthData) SetPullCredentials(creds credentials.IAMRoleCredentials)

SetPullCredentials sets the credentials to pull from ECR in the auth

type EnvironmentFile added in v1.39.0

type EnvironmentFile struct {
	Value string `json:"value"`
	Type  string `json:"type"`
}

type FirelensConfig added in v1.30.0

type FirelensConfig struct {
	Type    string            `json:"type"`
	Options map[string]string `json:"options"`
}

FirelensConfig describes the type and options of a Firelens container.

type HealthStatus

type HealthStatus struct {
	// Status is the container health status
	Status apicontainerstatus.ContainerHealthStatus `json:"status,omitempty"`
	// Since is the timestamp when container health status changed
	Since *time.Time `json:"statusSince,omitempty"`
	// ExitCode is the exitcode of health check if failed
	ExitCode int `json:"exitCode,omitempty"`
	// Output is the output of health check
	Output string `json:"output,omitempty"`
}

HealthStatus contains the health check result returned by docker

type ManagedAgent added in v1.50.0

type ManagedAgent struct {
	ManagedAgentState
	// Name is the name of this managed agent. This name is streamed down from ACS.
	Name string `json:"name,omitempty"`
	// Properties of this managed agent. Properties are streamed down from ACS.
	Properties map[string]string `json:"properties,omitempty"`
}

type ManagedAgentState added in v1.50.0

type ManagedAgentState struct {
	// ID of this managed agent state
	ID string `json:"id,omitempty"`
	// TODO: [ecs-exec] Change variable name from Status to KnownStatus in future PR to avoid noise
	// Status is the managed agent health status
	Status apicontainerstatus.ManagedAgentStatus `json:"status,omitempty"`
	// SentStatus is the managed agent sent status
	SentStatus apicontainerstatus.ManagedAgentStatus `json:"sentStatus,omitempty"`
	// Reason is a placeholder for failure messaging
	Reason string `json:"reason,omitempty"`
	// LastStartedAt is the timestamp when the status last went from PENDING->RUNNING
	LastStartedAt time.Time `json:"lastStartedAt,omitempty"`
	// Metadata holds metadata about the managed agent
	Metadata map[string]interface{} `json:"metadata,omitempty"`
	// InitFailed indicates if exec agent initialization failed
	InitFailed bool `json:"initFailed,omitempty"`
}

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 is the port inside the container
	ContainerPort uint16
	// HostPort is the port exposed on the host
	HostPort uint16
	// BindIP is the IP address to which the port is bound
	BindIP string `json:"BindIp"`
	// Protocol is the protocol of the port
	Protocol TransportProtocol
}

PortBinding represents a port binding for a container

func PortBindingFromDockerPortBinding

func PortBindingFromDockerPortBinding(dockerPortBindings nat.PortMap) ([]PortBinding, apierrors.NamedError)

PortBindingFromDockerPortBinding constructs a PortBinding slice from a docker NetworkSettings.Ports map.

type RegistryAuthenticationData

type RegistryAuthenticationData struct {
	Type        string       `json:"type"`
	ECRAuthData *ECRAuthData `json:"ecrAuthData"`
	ASMAuthData *ASMAuthData `json:"asmAuthData"`
}

RegistryAuthenticationData is the authentication data sent by the ECS backend. Currently, the only supported authentication data is for ECR.

type ResourceDependency

type ResourceDependency struct {
	// Name defines the Resource on which a transition depends
	Name string `json:"Name"`
	// RequiredStatus defines the status that satisfies the dependency
	RequiredStatus resourcestatus.ResourceStatus `json:"RequiredStatus"`
}

ResourceDependency defines the relationship between a dependent container and its resource dependency.

func (*ResourceDependency) GetRequiredStatus

func (rd *ResourceDependency) GetRequiredStatus() resourcestatus.ResourceStatus

GetRequiredStatus returns the required status for the dependency

type Secret added in v1.22.0

type Secret struct {
	Name          string `json:"name"`
	ValueFrom     string `json:"valueFrom"`
	Region        string `json:"region"`
	ContainerPath string `json:"containerPath"`
	Type          string `json:"type"`
	Provider      string `json:"provider"`
	Target        string `json:"target"`
}

Secret contains all essential attributes needed for ECS secrets vending as environment variables/tmpfs files

func (*Secret) GetSecretResourceCacheKey added in v1.23.0

func (s *Secret) GetSecretResourceCacheKey() string

GetSecretResourceCacheKey returns the key required to access the secret from the ssmsecret resource

type TransitionDependenciesMap

type TransitionDependenciesMap map[apicontainerstatus.ContainerStatus]TransitionDependencySet

TransitionDependenciesMap is a map of the dependent container status to other dependencies that must be satisfied.

func (*TransitionDependenciesMap) UnmarshalJSON

func (td *TransitionDependenciesMap) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the TransitionDependencySet tag in the JSON encoded string into the TransitionDependenciesMap object

type TransitionDependencySet

type TransitionDependencySet struct {
	// ContainerDependencies is the set of containers on which a transition is
	// dependent.
	ContainerDependencies []ContainerDependency `json:"ContainerDependencies"`
	// ResourceDependencies is the set of resources on which a transition is
	// dependent.
	ResourceDependencies []ResourceDependency `json:"ResourceDependencies"`
}

TransitionDependencySet contains dependencies that impact transitions of containers.

type TransportProtocol

type TransportProtocol int32

TransportProtocol is an enumeration of valid transport protocols

const (
	// TransportProtocolTCP represents TCP
	TransportProtocolTCP TransportProtocol = iota
	// TransportProtocolUDP represents UDP
	TransportProtocolUDP
)

func NewTransportProtocol

func NewTransportProtocol(protocol string) (TransportProtocol, error)

NewTransportProtocol returns a TransportProtocol from a string in the task

func (*TransportProtocol) MarshalJSON

func (tp *TransportProtocol) MarshalJSON() ([]byte, error)

MarshalJSON overrides the logic for JSON-encoding the TransportProtocol type

func (*TransportProtocol) String

func (tp *TransportProtocol) String() string

String converts TransportProtocol to a string

func (*TransportProtocol) UnmarshalJSON

func (tp *TransportProtocol) UnmarshalJSON(b []byte) error

UnmarshalJSON for TransportProtocol determines whether to use TCP or UDP, setting TCP as the zero-value but treating other unrecognized values as errors

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

Jump to

Keyboard shortcuts

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