v2

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: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// TaskMetadataPath specifies the relative URI path for serving task metadata.
	TaskMetadataPath = "/v2/metadata"

	// TaskWithTagsMetadataPath specifies the relative URI path for serving task metadata with Container Instance and Task Tags.
	TaskWithTagsMetadataPath = "/v2/metadataWithTags"

	// TaskMetadataPathWithSlash specifies the relative URI path for serving task metadata.
	TaskMetadataPathWithSlash = TaskMetadataPath + "/"

	// TaskWithTagsMetadataPath specifies the relative URI path for serving task metadata with Container Instance and Task Tags.
	TaskWithTagsMetadataPathWithSlash = TaskWithTagsMetadataPath + "/"
)
View Source
const (

	// TaskStatsPath specifies the relative URI path for serving task stats.
	TaskStatsPath = "/v2/stats"

	// TaskStatsPathWithSlash specifies the relative URI path for serving task stats.
	TaskStatsPathWithSlash = TaskStatsPath + "/"
)

Variables

View Source
var ContainerMetadataPath = TaskMetadataPathWithSlash + utils.ConstructMuxVar(metadataContainerIDMuxName, utils.AnythingButEmptyRegEx)

ContainerMetadataPath specifies the relative URI path for serving container metadata.

View Source
var ContainerStatsPath = TaskStatsPathWithSlash + utils.ConstructMuxVar(statsContainerIDMuxName, utils.AnythingButEmptyRegEx)

ContainerStatsPath specifies the relative URI path for serving container stats.

View Source
var CredentialsPath = credentials.V2CredentialsPath + "/" + utils.ConstructMuxVar(credentialsIDMuxName, utils.AnythingRegEx)

CredentialsPath specifies the relative URI path for serving task IAM credentials. Use "AnythingRegEx" regex to handle the case where the "credentialsIDMuxName" is empty, this is because the name that's used to extract dynamic value in gorilla cannot be empty by default. If we don't do this, we will get 404 error when we access "/v2/credentials/", but it should be 400 error.

Functions

func CredentialsHandler

func CredentialsHandler(credentialsManager credentials.Manager, auditLogger audit.AuditLogger) func(http.ResponseWriter, *http.Request)

CredentialsHandler creates response for the 'v2/credentials' API.

func NewTaskStatsResponse

func NewTaskStatsResponse(taskARN string,
	state dockerstate.TaskEngineState,
	statsEngine stats.Engine) (map[string]*types.StatsJSON, error)

NewTaskStatsResponse returns a new task stats response object

func TaskContainerMetadataHandler

func TaskContainerMetadataHandler(state dockerstate.TaskEngineState, ecsClient api.ECSClient, cluster, az, containerInstanceArn string, propagateTags bool) func(http.ResponseWriter, *http.Request)

TaskContainerMetadataHandler returns the handler method for handling task and container metadata requests.

func TaskContainerStatsHandler added in v1.21.0

func TaskContainerStatsHandler(state dockerstate.TaskEngineState, statsEngine stats.Engine) func(http.ResponseWriter, *http.Request)

TaskContainerStatsHandler returns the handler method for handling task and container stats requests.

func WriteContainerMetadataResponse added in v1.21.0

func WriteContainerMetadataResponse(w http.ResponseWriter, containerID string, state dockerstate.TaskEngineState)

WriteContainerMetadataResponse writes the container metadata to response writer.

func WriteContainerStatsResponse added in v1.21.0

func WriteContainerStatsResponse(w http.ResponseWriter,
	taskARN string,
	containerID string,
	statsEngine stats.Engine)

WriteContainerStatsResponse writes the container stats to response writer.

func WriteTaskMetadataResponse added in v1.21.0

func WriteTaskMetadataResponse(w http.ResponseWriter, taskARN string, cluster string, state dockerstate.TaskEngineState, ecsClient api.ECSClient, az, containerInstanceArn string, propagateTags bool)

WriteTaskMetadataResponse writes the task metadata to response writer.

func WriteTaskStatsResponse added in v1.21.0

func WriteTaskStatsResponse(w http.ResponseWriter,
	taskARN string,
	state dockerstate.TaskEngineState,
	statsEngine stats.Engine)

WriteTaskStatsResponse writes the task stats to response writer.

Types

type ContainerResponse

type ContainerResponse struct {
	ID            string                      `json:"DockerId"`
	Name          string                      `json:"Name"`
	DockerName    string                      `json:"DockerName"`
	Image         string                      `json:"Image"`
	ImageID       string                      `json:"ImageID"`
	Ports         []v1.PortResponse           `json:"Ports,omitempty"`
	Labels        map[string]string           `json:"Labels,omitempty"`
	DesiredStatus string                      `json:"DesiredStatus"`
	KnownStatus   string                      `json:"KnownStatus"`
	ExitCode      *int                        `json:"ExitCode,omitempty"`
	Limits        LimitsResponse              `json:"Limits"`
	CreatedAt     *time.Time                  `json:"CreatedAt,omitempty"`
	StartedAt     *time.Time                  `json:"StartedAt,omitempty"`
	FinishedAt    *time.Time                  `json:"FinishedAt,omitempty"`
	Type          string                      `json:"Type"`
	Networks      []containermetadata.Network `json:"Networks,omitempty"`
	Health        *apicontainer.HealthStatus  `json:"Health,omitempty"`
	Volumes       []v1.VolumeResponse         `json:"Volumes,omitempty"`
	LogDriver     string                      `json:"LogDriver,omitempty"`
	LogOptions    map[string]string           `json:"LogOptions,omitempty"`
	ContainerARN  string                      `json:"ContainerARN,omitempty"`
}

ContainerResponse defines the schema for the container response JSON object

func NewContainerResponse

func NewContainerResponse(
	dockerContainer *apicontainer.DockerContainer,
	eni *apieni.ENI,
	includeV4Metadata bool,
) ContainerResponse

NewContainerResponse creates a new container response TODO: remove includeV4Metadata from NewContainerResponse

func NewContainerResponseFromState added in v1.48.0

func NewContainerResponseFromState(
	containerID string,
	state dockerstate.TaskEngineState,
	includeV4Metadata bool,
) (*ContainerResponse, error)

NewContainerResponseFromState creates a new container response based on container id TODO: remove includeV4Metadata from NewContainerResponseFromState/NewContainerResponse

type ErrorResponse added in v1.50.0

type ErrorResponse struct {
	ErrorField   string `json:"ErrorField,omitempty"`
	ErrorCode    string `json:"ErrorCode,omitempty"`
	ErrorMessage string `json:"ErrorMessage,omitempty"`
	StatusCode   int    `json:"StatusCode,omitempty"`
	RequestId    string `json:"RequestId,omitempty"`
	ResourceARN  string `json:"ResourceARN,omitempty"`
}

ErrorResponse defined the schema for error response JSON object

type LimitsResponse

type LimitsResponse struct {
	CPU    *float64 `json:"CPU,omitempty"`
	Memory *int64   `json:"Memory,omitempty"`
}

LimitsResponse defines the schema for task/cpu limits response JSON object

type TaskResponse

type TaskResponse struct {
	Cluster               string              `json:"Cluster"`
	TaskARN               string              `json:"TaskARN"`
	Family                string              `json:"Family"`
	Revision              string              `json:"Revision"`
	DesiredStatus         string              `json:"DesiredStatus,omitempty"`
	KnownStatus           string              `json:"KnownStatus"`
	Containers            []ContainerResponse `json:"Containers,omitempty"`
	Limits                *LimitsResponse     `json:"Limits,omitempty"`
	PullStartedAt         *time.Time          `json:"PullStartedAt,omitempty"`
	PullStoppedAt         *time.Time          `json:"PullStoppedAt,omitempty"`
	ExecutionStoppedAt    *time.Time          `json:"ExecutionStoppedAt,omitempty"`
	AvailabilityZone      string              `json:"AvailabilityZone,omitempty"`
	TaskTags              map[string]string   `json:"TaskTags,omitempty"`
	ContainerInstanceTags map[string]string   `json:"ContainerInstanceTags,omitempty"`
	LaunchType            string              `json:"LaunchType,omitempty"`
	Errors                []ErrorResponse     `json:"Errors,omitempty"`
}

TaskResponse defines the schema for the task response JSON object

func NewTaskResponse

func NewTaskResponse(
	taskARN string,
	state dockerstate.TaskEngineState,
	ecsClient api.ECSClient,
	cluster string,
	az string,
	containerInstanceArn string,
	propagateTags bool,
	includeV4Metadata bool,
) (*TaskResponse, error)

NewTaskResponse creates a new response object for the task

Jump to

Keyboard shortcuts

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