{"modulePath":"github.com/alxche2021/amazon-ecs-agent","version":"v1.50.2","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package task\n\n## Constants\n\n```go\nconst (\n\t// NetworkPauseContainerName is the internal name for the pause container\n\tNetworkPauseContainerName = \"~internal~ecs~pause\"\n\n\t// NamespacePauseContainerName is the internal name for the IPC resource namespace and/or\n\t// PID namespace sharing pause container\n\tNamespacePauseContainerName = \"~internal~ecs~pause~namespace\"\n\n\tNvidiaVisibleDevicesEnvVar = \"NVIDIA_VISIBLE_DEVICES\"\n\tGPUAssociationType         = \"gpu\"\n\n\tContainerOrderingCreateCondition = \"CREATE\"\n\tContainerOrderingStartCondition  = \"START\"\n\n\t// specifies bridge type mode for a task\n\tBridgeNetworkMode = \"bridge\"\n\n\t// specifies awsvpc type mode for a task\n\tAWSVPCNetworkMode = \"awsvpc\"\n)\n```\n\n```go\nconst (\n\tHostVolumeType                 = \"host\"\n\tDockerVolumeType               = \"docker\"\n\tEFSVolumeType                  = \"efs\"\n\tFSxWindowsFileServerVolumeType = \"fsxWindowsFileServer\"\n)\n```\n\n## Types\n\n```go\ntype Association struct {\n\t// Containers are the container names that can use this association.\n\tContainers []string `json:\"containers\"`\n\t// Content describes this association.\n\tContent EncodedString `json:\"content\"`\n\t// Name is a unique identifier of the association within a task.\n\tName string `json:\"name\"`\n\t// Type specifies the type of this association.\n\tType string `json:\"type\"`\n}\n```\nAssociation is a definition of a device (or other potential things) that is associated with a task.\n\n```go\ntype EncodedString struct {\n\t// Encoding is the encoding type of the value.\n\tEncoding string `json:\"encoding\"`\n\t// Value is the content of the encoded string.\n\tValue string `json:\"value\"`\n}\n```\nEncodedString is used to describe an association, the consumer of the association data should be responsible to decode it. We don't model it in Agent, or check the value of the encoded string, we just pass whatever we get from ACS, because we don't want Agent to be coupled with a specific association.\n\n```go\ntype Option func(*Task) error\n```\nOption defines a function that can be executed in some task API methods in order to perform custom configurations of the task\n\n```go\ntype PlatformFields struct{}\n```\nPlatformFields consists of fields specific to Linux for a task\n\n```go\ntype Task struct {\n\t// Arn is the unique identifier for the task\n\tArn string\n\t// Overrides are the overrides applied to a task\n\tOverrides TaskOverrides `json:\"-\"`\n\t// Family is the name of the task definition family\n\tFamily string\n\t// Version is the version of the task definition\n\tVersion string\n\t// Containers are the containers for the task\n\tContainers []*apicontainer.Container\n\t// Associations are the available associations for the task.\n\tAssociations []Association `json:\"associations\"`\n\t// ResourcesMapUnsafe is the map of resource type to corresponding resources\n\tResourcesMapUnsafe resourcetype.ResourcesMap `json:\"resources\"`\n\t// Volumes are the volumes for the task\n\tVolumes []TaskVolume `json:\"volumes\"`\n\t// CPU is a task-level limit for compute resources. A value of 1 means that\n\t// the task may access 100% of 1 vCPU on the instance\n\tCPU float64 `json:\"Cpu,omitempty\"`\n\t// Memory is a task-level limit for memory resources in bytes\n\tMemory int64 `json:\"Memory,omitempty\"`\n\t// DesiredStatusUnsafe represents the state where the task should go. Generally,\n\t// the desired status is informed by the ECS backend as a result of either\n\t// API calls made to ECS or decisions made by the ECS service scheduler.\n\t// The DesiredStatusUnsafe is almost always either apitaskstatus.TaskRunning or apitaskstatus.TaskStopped.\n\t// NOTE: Do not access DesiredStatusUnsafe directly.  Instead, use `UpdateStatus`,\n\t// `UpdateDesiredStatus`, `SetDesiredStatus`, and `SetDesiredStatus`.\n\t// TODO DesiredStatusUnsafe should probably be private with appropriately written\n\t// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON\n\t// is handled properly so that the state storage continues to work.\n\tDesiredStatusUnsafe apitaskstatus.TaskStatus `json:\"DesiredStatus\"`\n\n\t// KnownStatusUnsafe represents the state where the task is.  This is generally\n\t// the minimum of equivalent status types for the containers in the task;\n\t// if one container is at ContainerRunning and another is at ContainerPulled,\n\t// the task KnownStatusUnsafe would be TaskPulled.\n\t// NOTE: Do not access KnownStatusUnsafe directly.  Instead, use `UpdateStatus`,\n\t// and `GetKnownStatus`.\n\t// TODO KnownStatusUnsafe should probably be private with appropriately written\n\t// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON\n\t// is handled properly so that the state storage continues to work.\n\tKnownStatusUnsafe apitaskstatus.TaskStatus `json:\"KnownStatus\"`\n\t// KnownStatusTimeUnsafe captures the time when the KnownStatusUnsafe was last updated.\n\t// NOTE: Do not access KnownStatusTime directly, instead use `GetKnownStatusTime`.\n\tKnownStatusTimeUnsafe time.Time `json:\"KnownTime\"`\n\n\t// PullStartedAtUnsafe is the timestamp when the task start pulling the first container,\n\t// it won't be set if the pull never happens\n\tPullStartedAtUnsafe time.Time `json:\"PullStartedAt\"`\n\t// PullStoppedAtUnsafe is the timestamp when the task finished pulling the last container,\n\t// it won't be set if the pull never happens\n\tPullStoppedAtUnsafe time.Time `json:\"PullStoppedAt\"`\n\t// ExecutionStoppedAtUnsafe is the timestamp when the task desired status moved to stopped,\n\t// which is when the any of the essential containers stopped\n\tExecutionStoppedAtUnsafe time.Time `json:\"ExecutionStoppedAt\"`\n\n\t// SentStatusUnsafe represents the last KnownStatusUnsafe that was sent to the ECS SubmitTaskStateChange API.\n\t// TODO(samuelkarp) SentStatusUnsafe needs a lock and setters/getters.\n\t// TODO SentStatusUnsafe should probably be private with appropriately written\n\t// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON\n\t// is handled properly so that the state storage continues to work.\n\tSentStatusUnsafe apitaskstatus.TaskStatus `json:\"SentStatus\"`\n\n\tStartSequenceNumber int64\n\tStopSequenceNumber  int64\n\n\t// ExecutionCredentialsID is the ID of credentials that are used by agent to\n\t// perform some action at the task level, such as pulling image from ECR\n\tExecutionCredentialsID string `json:\"executionCredentialsID\"`\n\n\t// ENIs is the list of Elastic Network Interfaces assigned to this task. The\n\t// TaskENIs type is helpful when decoding state files which might have stored\n\t// ENIs as a single ENI object instead of a list.\n\tENIs TaskENIs `json:\"ENI\"`\n\n\t// AppMesh is the service mesh specified by the task\n\tAppMesh *apiappmesh.AppMesh\n\n\t// MemoryCPULimitsEnabled to determine if task supports CPU, memory limits\n\tMemoryCPULimitsEnabled bool `json:\"MemoryCPULimitsEnabled,omitempty\"`\n\n\t// PlatformFields consists of fields specific to linux/windows for a task\n\tPlatformFields PlatformFields `json:\"PlatformFields,omitempty\"`\n\n\t// PIDMode is used to determine how PID namespaces are organized between\n\t// containers of the Task\n\tPIDMode string `json:\"PidMode,omitempty\"`\n\n\t// IPCMode is used to determine how IPC resources should be shared among\n\t// containers of the Task\n\tIPCMode string `json:\"IpcMode,omitempty\"`\n\n\t// NvidiaRuntime is the runtime to pass Nvidia GPU devices to containers\n\tNvidiaRuntime string `json:\"NvidiaRuntime,omitempty\"`\n\n\t// LocalIPAddressUnsafe stores the local IP address allocated to the bridge that connects the task network\n\t// namespace and the host network namespace, for tasks in awsvpc network mode (tasks in other network mode won't\n\t// have a value for this). This field should be accessed via GetLocalIPAddress and SetLocalIPAddress.\n\tLocalIPAddressUnsafe string `json:\"LocalIPAddress,omitempty\"`\n\n\t// LaunchType is the launch type of this task.\n\tLaunchType string `json:\"LaunchType,omitempty\"`\n\t// contains filtered or unexported fields\n}\n```\nTask is the internal representation of a task in the ECS agent\n\n```go\nfunc RemoveFromTaskArray(arr []*Task, ndx int) []*Task\n```\nRemoveFromTaskArray removes the element at ndx from an array of task pointers, arr. If the ndx is out of bounds, it returns arr unchanged.\n\n```go\nfunc TaskFromACS(acsTask *ecsacs.Task, envelope *ecsacs.PayloadMessage) (*Task, error)\n```\nTaskFromACS translates ecsacs.Task to apitask.Task by first marshaling the received ecsacs.Task to json and unmarshaling it as apitask.Task\n\n```go\nfunc (task *Task) AddFirelensContainerBindMounts(firelensConfig *apicontainer.FirelensConfig, hostConfig *dockercontainer.HostConfig,\n\tconfig *config.Config) *apierrors.HostConfigError\n```\nAddFirelensContainerBindMounts adds config file bind mount and socket directory bind mount to the firelens container's host config.\n\n```go\nfunc (task *Task) AddResource(resourceType string, resource taskresource.TaskResource)\n```\nAddResource adds a resource to ResourcesMap\n\n```go\nfunc (task *Task) AddTaskENI(eni *apieni.ENI)\n```\nAddTaskENI adds ENI information to the task.\n\n```go\nfunc (task *Task) ApplyExecutionRoleLogsAuth(hostConfig *dockercontainer.HostConfig, credentialsManager credentials.Manager) *apierrors.HostConfigError\n```\nApplyExecutionRoleLogsAuth will check whether the task has execution role credentials, and add the genereated credentials endpoint to the associated HostConfig\n\n```go\nfunc (task *Task) AssociationByTypeAndName(associationType, associationName string) (*Association, bool)\n```\nAssociationByTypeAndName gets an association of a certain type and name\n\n```go\nfunc (task *Task) AssociationsByTypeAndContainer(associationType, containerName string) []string\n```\nAssociationByTypeAndContainer gets a list of names of all the associations associated with a container and of a certain type\n\n```go\nfunc (task *Task) BuildCNIConfig(includeIPAMConfig bool, cniConfig *ecscni.Config) (*ecscni.Config, error)\n```\nBuildCNIConfig builds a list of CNI network configurations for the task. If includeIPAMConfig is set to true, the list also includes the bridge IPAM configuration.\n\n```go\nfunc (task *Task) BuildCgroupRoot() (string, error)\n```\nBuildCgroupRoot helps build the task cgroup prefix Example: /ecs/task-id\n\n```go\nfunc (task *Task) BuildLinuxResourceSpec(cGroupCPUPeriod time.Duration) (specs.LinuxResources, error)\n```\nBuildLinuxResourceSpec returns a linuxResources object for the task cgroup\n\n```go\nfunc (task *Task) ContainerByName(name string) (*apicontainer.Container, bool)\n```\nContainerByName returns the \\*Container for the given name\n\n```go\nfunc (task *Task) DockerConfig(container *apicontainer.Container, apiVersion dockerclient.DockerVersion) (*dockercontainer.Config, *apierrors.DockerClientConfigError)\n```\nDockerConfig converts the given container in this task to the format of the Docker SDK 'Config' struct\n\n```go\nfunc (task *Task) DockerHostConfig(container *apicontainer.Container, dockerContainerMap map[string]*apicontainer.DockerContainer, apiVersion dockerclient.DockerVersion, cfg *config.Config) (*dockercontainer.HostConfig, *apierrors.HostConfigError)\n```\nDockerHostConfig construct the configuration recognized by docker\n\n```go\nfunc (task *Task) GetAppMesh() *apiappmesh.AppMesh\n```\nGetAppMesh returns the app mesh config of the task\n\n```go\nfunc (task *Task) GetContainerIndex(containerName string) int\n```\nGetContainerIndex returns the index of the container in the container list. This doesn't count internal container.\n\n```go\nfunc (task *Task) GetCredentialSpecResource() ([]taskresource.TaskResource, bool)\n```\nGetCredentialSpecResource retrieves credentialspec resource from resource map\n\n```go\nfunc (task *Task) GetCredentialsID() string\n```\nGetCredentialsID gets the credentials ID for the task\n\n```go\nfunc (task *Task) GetCredentialsRelativeURI() string\n```\nGetCredentialsRelativeURI returns the credentials relative uri for the task\n\n```go\nfunc (task *Task) GetDesiredStatus() apitaskstatus.TaskStatus\n```\nGetDesiredStatus gets the desired status of the task\n\n```go\nfunc (task *Task) GetExecutionCredentialsID() string\n```\nGetExecutionCredentialsID gets the credentials ID for the task\n\n```go\nfunc (task *Task) GetExecutionStoppedAt() time.Time\n```\nGetExecutionStoppedAt returns the task executionStoppedAt timestamp\n\n```go\nfunc (task *Task) GetFirelensContainer() *apicontainer.Container\n```\nGetFirelensContainer returns the firelens container in the task, if there is one.\n\n```go\nfunc (task *Task) GetID() (string, error)\n```\nGetID is used to retrieve the taskID from taskARN Reference: [http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-ecs](http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-ecs)\n\n```go\nfunc (task *Task) GetKnownStatus() apitaskstatus.TaskStatus\n```\nGetKnownStatus gets the KnownStatus of the task\n\n```go\nfunc (task *Task) GetKnownStatusTime() time.Time\n```\nGetKnownStatusTime gets the KnownStatusTime of the task\n\n```go\nfunc (task *Task) GetLocalIPAddress() string\n```\nGetLocalIPAddress returns the local IP address of the task.\n\n```go\nfunc (task *Task) GetPrimaryENI() *apieni.ENI\n```\nGetPrimaryENI returns the primary ENI of the task. Since ACS can potentially send multiple ENIs to the agent, the first ENI in the list is considered as the primary ENI.\n\n```go\nfunc (task *Task) GetPullStartedAt() time.Time\n```\nGetPullStartedAt returns the PullStartedAt timestamp\n\n```go\nfunc (task *Task) GetPullStoppedAt() time.Time\n```\nGetPullStoppedAt returns the PullStoppedAt timestamp\n\n```go\nfunc (task *Task) GetResources() []taskresource.TaskResource\n```\nGetResources returns the list of task resources from ResourcesMap\n\n```go\nfunc (task *Task) GetSentStatus() apitaskstatus.TaskStatus\n```\nGetSentStatus safely returns the SentStatus of the task\n\n```go\nfunc (task *Task) GetStopSequenceNumber() int64\n```\nGetStopSequenceNumber returns the stop sequence number of a task\n\n```go\nfunc (task *Task) GetTaskENIs() []*apieni.ENI\n```\nGetTaskENIs returns the list of ENIs for the task.\n\n```go\nfunc (task *Task) GetTerminalReason() string\n```\nGetTerminalReason retrieves the terminalReason string\n\n```go\nfunc (task *Task) HostVolumeByName(name string) (taskresourcevolume.Volume, bool)\n```\nHostVolumeByName returns the task Volume for the given a volume name in that task. The second return value indicates the presence of that volume\n\n```go\nfunc (task *Task) InitializeResources(resourceFields *taskresource.ResourceFields)\n```\nInitializeResources initializes the required field in the task on agent restart Some of the fields in task isn't saved in the agent state file, agent needs to initialize these fields before processing the task, eg: docker client in resource\n\n```go\nfunc (task *Task) IsNetworkModeAWSVPC() bool\n```\nIsNetworkModeAWSVPC checks if the task is configured to use the AWSVPC task networking feature.\n\n```go\nfunc (task *Task) MarshalJSON() ([]byte, error)\n```\nMarshalJSON wraps Go's marshalling logic with a necessary read lock.\n\n```go\nfunc (task *Task) MergeEnvVarsFromEnvfiles(container *apicontainer.Container) *apierrors.ResourceInitError\n```\nMergeEnvVarsFromEnvfiles should be called when creating a container - this method reads the environment variables specified in the environment files that was downloaded to disk and merges it with existing environment variables\n\n```go\nfunc (task *Task) PopulateASMAuthData(container *apicontainer.Container) error\n```\nPopulateASMAuthData sets docker auth credentials for a container\n\n```go\nfunc (task *Task) PopulateSecretLogOptionsToFirelensContainer(firelensContainer *apicontainer.Container) *apierrors.DockerClientConfigError\n```\nPopulateSecretLogOptionsToFirelensContainer collects secret log option values for awsfirelens log driver from task resource and specified then as envs of firelens container. Firelens container will use the envs to resolve config file variables constructed for secret log options when loading the config file.\n\n```go\nfunc (task *Task) PopulateSecrets(hostConfig *dockercontainer.HostConfig, container *apicontainer.Container) *apierrors.DockerClientConfigError\n```\nPopulateSecrets appends secrets to container's env var map and hostconfig section\n\n```go\nfunc (task *Task) PostUnmarshalTask(cfg *config.Config,\n\tcredentialsManager credentials.Manager, resourceFields *taskresource.ResourceFields,\n\tdockerClient dockerapi.DockerClient, ctx context.Context, options ...Option) error\n```\nPostUnmarshalTask 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).\n\n```go\nfunc (task *Task) RecordExecutionStoppedAt(container *apicontainer.Container)\n```\nRecordExecutionStoppedAt checks if this is an essential container stopped and set the task executionStoppedAt timestamps\n\n```go\nfunc (task *Task) SetAppMesh(appMesh *apiappmesh.AppMesh)\n```\nSetAppMesh sets the app mesh config of the task\n\n```go\nfunc (task *Task) SetCredentialsID(id string)\n```\nSetCredentialsID sets the credentials ID for the task\n\n```go\nfunc (task *Task) SetCredentialsRelativeURI(uri string)\n```\nSetCredentialsRelativeURI sets the credentials relative uri for the task\n\n```go\nfunc (task *Task) SetDesiredStatus(status apitaskstatus.TaskStatus)\n```\nSetDesiredStatus sets the desired status of the task\n\n```go\nfunc (task *Task) SetExecutionRoleCredentialsID(id string)\n```\nSetExecutionRoleCredentialsID sets the ID for the task execution role credentials\n\n```go\nfunc (task *Task) SetExecutionStoppedAt(timestamp time.Time) bool\n```\nSetExecutionStoppedAt sets the ExecutionStoppedAt timestamp of the task\n\n```go\nfunc (task *Task) SetKnownStatus(status apitaskstatus.TaskStatus)\n```\nSetKnownStatus sets the known status of the task\n\n```go\nfunc (task *Task) SetLocalIPAddress(addr string)\n```\nSetLocalIPAddress sets the local IP address of the task.\n\n```go\nfunc (task *Task) SetPausePIDInVolumeResources(pid string)\n```\nSetPausePIDInVolumeResources sets the pause container pid field in each volume resource.\n\n```go\nfunc (task *Task) SetPullStartedAt(timestamp time.Time) bool\n```\nSetPullStartedAt sets the task pullstartedat timestamp and returns whether this field was updated or not\n\n```go\nfunc (task *Task) SetPullStoppedAt(timestamp time.Time)\n```\nSetPullStoppedAt sets the task pullstoppedat timestamp\n\n```go\nfunc (task *Task) SetSentStatus(status apitaskstatus.TaskStatus)\n```\nSetSentStatus safely sets the SentStatus of the task\n\n```go\nfunc (task *Task) SetStopSequenceNumber(seqnum int64)\n```\nSetStopSequenceNumber sets the stop seqence number of a task\n\n```go\nfunc (task *Task) SetTerminalReason(reason string)\n```\nSetTerminalReason sets the terminalReason string and this can only be set once per the task's lifecycle. This field does not accept updates.\n\n```go\nfunc (task *Task) String() string\n```\nString returns a human readable string representation of this object\n\n```go\nfunc (task *Task) UpdateDesiredStatus()\n```\nUpdateDesiredStatus sets the known status of the task\n\n```go\nfunc (task *Task) UpdateMountPoints(cont *apicontainer.Container, vols []types.MountPoint)\n```\nUpdateMountPoints updates the mount points of volumes that were created without specifying a host path.  This is used as part of the empty host volume feature.\n\n```go\nfunc (task *Task) UpdateStatus() bool\n```\nUpdateStatus updates a task's known and desired statuses to be compatible with all of its containers It will return a bool indicating if there was a change\n\n```go\ntype TaskENIs []*apieni.ENI\n```\nTaskENIs type enumerates the list of ENI objects as a type. It is used for implementing a custom unmarshaler. The unmarshaler is capable of unmarshaling both a list of ENI objects into the TaskENIs type (the new scheme) or a single ENI object into the TaskENIs type (the old scheme before this object was introduced).\n\nThe 'task' package is deemed to be a better home for this than the 'eni' package since this is only required for unmarshaling 'Task' object. None of the functionality/types in the 'eni' package themselves have any dependencies on this type.\n\n```go\nfunc (taskENIs *TaskENIs) UnmarshalJSON(b []byte) error\n```\n\n```go\ntype TaskOverrides struct{}\n```\nTaskOverrides are the overrides applied to a task\n\n```go\ntype TaskVolume struct {\n\tType   string `json:\"type\"`\n\tName   string `json:\"name\"`\n\tVolume taskresourcevolume.Volume\n}\n```\nTaskVolume is a definition of all the volumes available for containers to reference within a task. It must be named.\n\n```go\nfunc (tv *TaskVolume) MarshalJSON() ([]byte, error)\n```\nMarshalJSON overrides the logic for JSON-encoding a TaskVolume object\n\n```go\nfunc (tv *TaskVolume) UnmarshalJSON(b []byte) error\n```\nUnmarshalJSON for TaskVolume determines the name and volume type, and unmarshals it into the appropriate HostVolume fulfilling interfaces\n\n","path":"github.com/alxche2021/amazon-ecs-agent/agent/api/task","name":"task","synopsis":"","isRedistributable":true}
