diff --git a/agent/containermetadata/parse_metadata.go b/agent/containermetadata/parse_metadata.go index 96d45148727..e979fd48e46 100644 --- a/agent/containermetadata/parse_metadata.go +++ b/agent/containermetadata/parse_metadata.go @@ -19,6 +19,7 @@ import ( apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container" apitask "github.com/aws/amazon-ecs-agent/agent/api/task" + tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response" "github.com/cihub/seelog" "github.com/docker/docker/api/types" dockercontainer "github.com/docker/docker/api/types/container" @@ -142,17 +143,17 @@ func parseNetworkMetadata(settings *types.NetworkSettings, hostConfig *dockercon // Extensive Network information is not available for Docker API versions 1.17-1.20 // Instead we only get the details of the first network - networkList := make([]Network, 0) + networkList := make([]tmdsresponse.Network, 0) if len(settings.Networks) > 0 { for modeFromSettings, containerNetwork := range settings.Networks { networkMode := modeFromSettings ipv4Addresses := []string{containerNetwork.IPAddress} - network := Network{NetworkMode: networkMode, IPv4Addresses: ipv4Addresses} + network := tmdsresponse.Network{NetworkMode: networkMode, IPv4Addresses: ipv4Addresses} networkList = append(networkList, network) } } else { ipv4Addresses := []string{ipv4AddressFromSettings} - network := Network{NetworkMode: networkModeFromHostConfig, IPv4Addresses: ipv4Addresses} + network := tmdsresponse.Network{NetworkMode: networkModeFromHostConfig, IPv4Addresses: ipv4Addresses} networkList = append(networkList, network) } diff --git a/agent/containermetadata/types.go b/agent/containermetadata/types.go index e3276a52c10..2b7c8353045 100644 --- a/agent/containermetadata/types.go +++ b/agent/containermetadata/types.go @@ -20,6 +20,7 @@ import ( "time" apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container" + tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response" "github.com/docker/docker/api/types" ) @@ -82,19 +83,12 @@ type DockerMetadataClient interface { InspectContainer(context.Context, string, time.Duration) (*types.ContainerJSON, error) } -// Network is a struct that keeps track of metadata of a network interface -type Network struct { - NetworkMode string `json:"NetworkMode,omitempty"` - IPv4Addresses []string `json:"IPv4Addresses,omitempty"` - IPv6Addresses []string `json:"IPv6Addresses,omitempty"` -} - // NetworkMetadata keeps track of the data we parse from the Network Settings // in docker containers. While most information is redundant with the internal // Network struct, we keeps this wrapper in case we wish to add data specifically // from the NetworkSettings type NetworkMetadata struct { - networks []Network + networks []tmdsresponse.Network } // DockerContainerMetadata keeps track of all metadata acquired from Docker inspection @@ -147,7 +141,7 @@ type metadataSerializer struct { ImageID string `json:"ImageID,omitempty"` ImageName string `json:"ImageName,omitempty"` Ports []apicontainer.PortBinding `json:"PortMappings,omitempty"` - Networks []Network `json:"Networks,omitempty"` + Networks []tmdsresponse.Network `json:"Networks,omitempty"` MetadataFileStatus MetadataStatus `json:"MetadataFileStatus,omitempty"` AvailabilityZone string `json:"AvailabilityZone,omitempty"` HostPrivateIPv4Address string `json:"HostPrivateIPv4Address,omitempty"` diff --git a/agent/handlers/task_server_setup_test.go b/agent/handlers/task_server_setup_test.go index 2e8807617db..ecda0e81dc8 100644 --- a/agent/handlers/task_server_setup_test.go +++ b/agent/handlers/task_server_setup_test.go @@ -35,11 +35,9 @@ import ( apitask "github.com/aws/amazon-ecs-agent/agent/api/task" apitaskstatus "github.com/aws/amazon-ecs-agent/agent/api/task/status" "github.com/aws/amazon-ecs-agent/agent/config" - "github.com/aws/amazon-ecs-agent/agent/containermetadata" "github.com/aws/amazon-ecs-agent/agent/ecs_client/model/ecs" mock_dockerstate "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate/mocks" task_protection_v1 "github.com/aws/amazon-ecs-agent/agent/handlers/agentapi/taskprotection/v1/handlers" - v1 "github.com/aws/amazon-ecs-agent/agent/handlers/v1" v2 "github.com/aws/amazon-ecs-agent/agent/handlers/v2" v3 "github.com/aws/amazon-ecs-agent/agent/handlers/v3" v4 "github.com/aws/amazon-ecs-agent/agent/handlers/v4" @@ -50,6 +48,7 @@ import ( "github.com/aws/amazon-ecs-agent/ecs-agent/credentials" mock_credentials "github.com/aws/amazon-ecs-agent/ecs-agent/credentials/mocks" mock_audit "github.com/aws/amazon-ecs-agent/ecs-agent/logger/audit/mocks" + tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response" "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils" tmdsv1 "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v1" "github.com/aws/aws-sdk-go/aws" @@ -242,14 +241,14 @@ var ( }, Type: containerType, Labels: labels, - Ports: []v1.PortResponse{ + Ports: []tmdsresponse.PortResponse{ { ContainerPort: containerPort, Protocol: containerPortProtocol, HostPort: containerPort, }, }, - Networks: []containermetadata.Network{ + Networks: []tmdsresponse.Network{ { NetworkMode: utils.NetworkModeAWSVPC, IPv4Addresses: []string{eniIPv4Address}, @@ -348,13 +347,13 @@ var ( }, Type: containerType, Labels: labels, - Ports: []v1.PortResponse{ + Ports: []tmdsresponse.PortResponse{ { ContainerPort: containerPort, Protocol: containerPortProtocol, }, }, - Networks: []containermetadata.Network{ + Networks: []tmdsresponse.Network{ { NetworkMode: bridgeMode, IPv4Addresses: []string{bridgeIPAddr}, @@ -395,14 +394,14 @@ var ( }, Type: containerType, Labels: labels, - Ports: []v1.PortResponse{ + Ports: []tmdsresponse.PortResponse{ { ContainerPort: containerPort, Protocol: containerPortProtocol, HostPort: containerPort, }, }, - Networks: []containermetadata.Network{ + Networks: []tmdsresponse.Network{ { NetworkMode: utils.NetworkModeAWSVPC, IPv4Addresses: []string{eniIPv4Address}, @@ -410,7 +409,7 @@ var ( }, }, Networks: []v4.Network{{ - Network: containermetadata.Network{ + Network: tmdsresponse.Network{ NetworkMode: utils.NetworkModeAWSVPC, IPv4Addresses: []string{eniIPv4Address}, }, @@ -485,7 +484,7 @@ var ( expectedV4BridgeContainerResponse = v4.ContainerResponse{ ContainerResponse: &expectedBridgeContainerResponse, Networks: []v4.Network{{ - Network: containermetadata.Network{ + Network: tmdsresponse.Network{ NetworkMode: bridgeMode, IPv4Addresses: []string{bridgeIPAddr}, }, diff --git a/agent/handlers/v1/response.go b/agent/handlers/v1/response.go index 43ce3a55aaa..0284e40ff9f 100644 --- a/agent/handlers/v1/response.go +++ b/agent/handlers/v1/response.go @@ -16,9 +16,9 @@ package v1 import ( apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container" apitask "github.com/aws/amazon-ecs-agent/agent/api/task" - "github.com/aws/amazon-ecs-agent/agent/containermetadata" "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate" apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni" + tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response" "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils" ) @@ -46,28 +46,12 @@ type TasksResponse struct { // ContainerResponse is the schema for the container response JSON object type ContainerResponse struct { - DockerID string `json:"DockerId"` - DockerName string `json:"DockerName"` - Name string `json:"Name"` - Ports []PortResponse `json:"Ports,omitempty"` - Networks []containermetadata.Network `json:"Networks,omitempty"` - Volumes []VolumeResponse `json:"Volumes,omitempty"` -} - -// VolumeResponse is the schema for the volume response JSON object -type VolumeResponse struct { - DockerName string `json:"DockerName,omitempty"` - Source string `json:"Source,omitempty"` - Destination string `json:"Destination,omitempty"` -} - -// PortResponse defines the schema for portmapping response JSON -// object. -type PortResponse struct { - ContainerPort uint16 `json:"ContainerPort,omitempty"` - Protocol string `json:"Protocol,omitempty"` - HostPort uint16 `json:"HostPort,omitempty"` - HostIp string `json:"HostIp,omitempty"` + DockerID string `json:"DockerId"` + DockerName string `json:"DockerName"` + Name string `json:"Name"` + Ports []tmdsresponse.PortResponse `json:"Ports,omitempty"` + Networks []tmdsresponse.Network `json:"Networks,omitempty"` + Volumes []tmdsresponse.VolumeResponse `json:"Volumes,omitempty"` } // NewTaskResponse creates a TaskResponse for a task. @@ -113,7 +97,7 @@ func NewContainerResponse(dockerContainer *apicontainer.DockerContainer, eni *ap resp.Volumes = NewVolumesResponse(dockerContainer) if eni != nil { - resp.Networks = []containermetadata.Network{ + resp.Networks = []tmdsresponse.Network{ { NetworkMode: utils.NetworkModeAWSVPC, IPv4Addresses: eni.GetIPV4Addresses(), @@ -125,9 +109,9 @@ func NewContainerResponse(dockerContainer *apicontainer.DockerContainer, eni *ap } // NewPortBindingsResponse creates PortResponse for a container. -func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni *apieni.ENI) []PortResponse { +func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni *apieni.ENI) []tmdsresponse.PortResponse { container := dockerContainer.Container - resp := []PortResponse{} + resp := []tmdsresponse.PortResponse{} bindings := container.GetKnownPortBindings() @@ -138,7 +122,7 @@ func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni } for _, binding := range bindings { - port := PortResponse{ + port := tmdsresponse.PortResponse{ ContainerPort: binding.ContainerPort, Protocol: binding.Protocol.String(), } @@ -155,14 +139,14 @@ func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni } // NewVolumesResponse creates VolumeResponse for a container -func NewVolumesResponse(dockerContainer *apicontainer.DockerContainer) []VolumeResponse { +func NewVolumesResponse(dockerContainer *apicontainer.DockerContainer) []tmdsresponse.VolumeResponse { container := dockerContainer.Container - var resp []VolumeResponse + var resp []tmdsresponse.VolumeResponse volumes := container.GetVolumes() for _, volume := range volumes { - volResp := VolumeResponse{ + volResp := tmdsresponse.VolumeResponse{ DockerName: volume.Name, Source: volume.Source, Destination: volume.Destination, diff --git a/agent/handlers/v2/response.go b/agent/handlers/v2/response.go index f80c4dc39a7..8ac65c4cd77 100644 --- a/agent/handlers/v2/response.go +++ b/agent/handlers/v2/response.go @@ -20,10 +20,10 @@ import ( "github.com/aws/amazon-ecs-agent/agent/api" apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container" - "github.com/aws/amazon-ecs-agent/agent/containermetadata" "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate" v1 "github.com/aws/amazon-ecs-agent/agent/handlers/v1" apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni" + tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response" "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils" "github.com/aws/aws-sdk-go/aws" "github.com/cihub/seelog" @@ -53,27 +53,27 @@ type TaskResponse struct { // ContainerResponse defines the schema for the container response // JSON object 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"` + ID string `json:"DockerId"` + Name string `json:"Name"` + DockerName string `json:"DockerName"` + Image string `json:"Image"` + ImageID string `json:"ImageID"` + Ports []tmdsresponse.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 []tmdsresponse.Network `json:"Networks,omitempty"` + Health *apicontainer.HealthStatus `json:"Health,omitempty"` + Volumes []tmdsresponse.VolumeResponse `json:"Volumes,omitempty"` + LogDriver string `json:"LogDriver,omitempty"` + LogOptions map[string]string `json:"LogOptions,omitempty"` + ContainerARN string `json:"ContainerARN,omitempty"` } // LimitsResponse defines the schema for task/cpu limits response @@ -272,7 +272,7 @@ func NewContainerResponse( } for _, binding := range container.GetKnownPortBindings() { - port := v1.PortResponse{ + port := tmdsresponse.PortResponse{ ContainerPort: binding.ContainerPort, Protocol: binding.Protocol.String(), } @@ -289,7 +289,7 @@ func NewContainerResponse( } if eni != nil { - resp.Networks = []containermetadata.Network{ + resp.Networks = []tmdsresponse.Network{ { NetworkMode: utils.NetworkModeAWSVPC, IPv4Addresses: eni.GetIPV4Addresses(), diff --git a/agent/handlers/v3/container_metadata_handler.go b/agent/handlers/v3/container_metadata_handler.go index 7860f57a199..a7c90281780 100644 --- a/agent/handlers/v3/container_metadata_handler.go +++ b/agent/handlers/v3/container_metadata_handler.go @@ -18,9 +18,9 @@ import ( "fmt" "net/http" - "github.com/aws/amazon-ecs-agent/agent/containermetadata" "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate" v2 "github.com/aws/amazon-ecs-agent/agent/handlers/v2" + tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response" "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils" "github.com/cihub/seelog" "github.com/pkg/errors" @@ -78,7 +78,7 @@ func GetContainerResponse(containerID string, state dockerstate.TaskEngineState) } // GetContainerNetworkMetadata returns the network metadata for the container -func GetContainerNetworkMetadata(containerID string, state dockerstate.TaskEngineState) ([]containermetadata.Network, error) { +func GetContainerNetworkMetadata(containerID string, state dockerstate.TaskEngineState) ([]tmdsresponse.Network, error) { dockerContainer, ok := state.ContainerByID(containerID) if !ok { return nil, errors.Errorf("Unable to find container '%s'", containerID) @@ -98,17 +98,17 @@ func GetContainerNetworkMetadata(containerID string, state dockerstate.TaskEngin // Extensive Network information is not available for Docker API versions 1.17-1.20 // Instead we only get the details of the first network - networks := make([]containermetadata.Network, 0) + networks := make([]tmdsresponse.Network, 0) if len(settings.Networks) > 0 { for modeFromSettings, containerNetwork := range settings.Networks { networkMode := modeFromSettings ipv4Addresses := []string{containerNetwork.IPAddress} - network := containermetadata.Network{NetworkMode: networkMode, IPv4Addresses: ipv4Addresses} + network := tmdsresponse.Network{NetworkMode: networkMode, IPv4Addresses: ipv4Addresses} networks = append(networks, network) } } else { ipv4Addresses := []string{ipv4AddressFromSettings} - network := containermetadata.Network{NetworkMode: networkModeFromHostConfig, IPv4Addresses: ipv4Addresses} + network := tmdsresponse.Network{NetworkMode: networkModeFromHostConfig, IPv4Addresses: ipv4Addresses} networks = append(networks, network) } return networks, nil diff --git a/agent/handlers/v4/container_metadata_handler.go b/agent/handlers/v4/container_metadata_handler.go index 529147c52bd..39a7756f2d9 100644 --- a/agent/handlers/v4/container_metadata_handler.go +++ b/agent/handlers/v4/container_metadata_handler.go @@ -18,9 +18,9 @@ import ( "fmt" "net/http" - "github.com/aws/amazon-ecs-agent/agent/containermetadata" "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate" v3 "github.com/aws/amazon-ecs-agent/agent/handlers/v3" + tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response" "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils" "github.com/cihub/seelog" "github.com/pkg/errors" @@ -103,12 +103,12 @@ func GetContainerNetworkMetadata(containerID string, state dockerstate.TaskEngin for modeFromSettings, containerNetwork := range settings.Networks { networkMode := modeFromSettings ipv4Addresses := []string{containerNetwork.IPAddress} - network := Network{Network: containermetadata.Network{NetworkMode: networkMode, IPv4Addresses: ipv4Addresses}} + network := Network{Network: tmdsresponse.Network{NetworkMode: networkMode, IPv4Addresses: ipv4Addresses}} networks = append(networks, network) } } else { ipv4Addresses := []string{ipv4AddressFromSettings} - network := Network{Network: containermetadata.Network{NetworkMode: networkModeFromHostConfig, IPv4Addresses: ipv4Addresses}} + network := Network{Network: tmdsresponse.Network{NetworkMode: networkModeFromHostConfig, IPv4Addresses: ipv4Addresses}} networks = append(networks, network) } return networks, nil diff --git a/agent/handlers/v4/response.go b/agent/handlers/v4/response.go index e0a2d4b17a8..043e9aa445b 100644 --- a/agent/handlers/v4/response.go +++ b/agent/handlers/v4/response.go @@ -17,10 +17,10 @@ import ( "github.com/aws/amazon-ecs-agent/agent/api" apicontainer "github.com/aws/amazon-ecs-agent/agent/api/container" apitask "github.com/aws/amazon-ecs-agent/agent/api/task" - "github.com/aws/amazon-ecs-agent/agent/containermetadata" "github.com/aws/amazon-ecs-agent/agent/engine/dockerstate" v2 "github.com/aws/amazon-ecs-agent/agent/handlers/v2" apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni" + tmdsresponse "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response" "github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils" "github.com/pkg/errors" ) @@ -45,7 +45,7 @@ type ContainerResponse struct { // interface(s) on top of what is supported by v4. // See `NetworkInterfaceProperties` for more details. type Network struct { - containermetadata.Network + tmdsresponse.Network // NetworkInterfaceProperties specifies additional properties of the network // of the network interface that are exposed via the metadata server. // We currently populate this only for the `awsvpc` networking mode. @@ -147,7 +147,7 @@ func NewContainerResponse( // look up the task information in the local state based on the id, which could be // either task arn or contianer id. func toV4NetworkResponse( - networks []containermetadata.Network, + networks []tmdsresponse.Network, lookup func() (*apitask.Task, bool), ) ([]Network, error) { var resp []Network diff --git a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response/response.go b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response/response.go new file mode 100644 index 00000000000..db94ab4cd81 --- /dev/null +++ b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response/response.go @@ -0,0 +1,38 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +// This package defines some common types used by all task metadata functions +package response + +// VolumeResponse is the schema for the volume response JSON object +type VolumeResponse struct { + DockerName string `json:"DockerName,omitempty"` + Source string `json:"Source,omitempty"` + Destination string `json:"Destination,omitempty"` +} + +// PortResponse defines the schema for portmapping response JSON +// object. +type PortResponse struct { + ContainerPort uint16 `json:"ContainerPort,omitempty"` + Protocol string `json:"Protocol,omitempty"` + HostPort uint16 `json:"HostPort,omitempty"` + HostIp string `json:"HostIp,omitempty"` +} + +// Network is a struct that keeps track of metadata of a network interface +type Network struct { + NetworkMode string `json:"NetworkMode,omitempty"` + IPv4Addresses []string `json:"IPv4Addresses,omitempty"` + IPv6Addresses []string `json:"IPv6Addresses,omitempty"` +} diff --git a/agent/vendor/modules.txt b/agent/vendor/modules.txt index 1ccf10cb54d..5832eccab9d 100644 --- a/agent/vendor/modules.txt +++ b/agent/vendor/modules.txt @@ -21,6 +21,7 @@ github.com/aws/amazon-ecs-agent/ecs-agent/logger/audit/mocks github.com/aws/amazon-ecs-agent/ecs-agent/logger/audit/request github.com/aws/amazon-ecs-agent/ecs-agent/logger/field github.com/aws/amazon-ecs-agent/ecs-agent/tmds +github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/response github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/utils github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v1 github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v2 diff --git a/ecs-agent/tmds/handlers/response/response.go b/ecs-agent/tmds/handlers/response/response.go new file mode 100644 index 00000000000..db94ab4cd81 --- /dev/null +++ b/ecs-agent/tmds/handlers/response/response.go @@ -0,0 +1,38 @@ +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +// This package defines some common types used by all task metadata functions +package response + +// VolumeResponse is the schema for the volume response JSON object +type VolumeResponse struct { + DockerName string `json:"DockerName,omitempty"` + Source string `json:"Source,omitempty"` + Destination string `json:"Destination,omitempty"` +} + +// PortResponse defines the schema for portmapping response JSON +// object. +type PortResponse struct { + ContainerPort uint16 `json:"ContainerPort,omitempty"` + Protocol string `json:"Protocol,omitempty"` + HostPort uint16 `json:"HostPort,omitempty"` + HostIp string `json:"HostIp,omitempty"` +} + +// Network is a struct that keeps track of metadata of a network interface +type Network struct { + NetworkMode string `json:"NetworkMode,omitempty"` + IPv4Addresses []string `json:"IPv4Addresses,omitempty"` + IPv6Addresses []string `json:"IPv6Addresses,omitempty"` +}