agent/handlers/v1/response.go
func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni *apieni.ENI) []PortResponse {
	container := dockerContainer.Container
	resp := []PortResponse{}

	bindings := container.GetKnownPortBindings()

	// if KnownPortBindings list is empty, then we use the port mapping
	// information that was passed down from ACS.
	if len(bindings) == 0 {
		bindings = container.Ports
	}

	for _, binding := range bindings {
		port := PortResponse{
			ContainerPort: binding.ContainerPort,
			Protocol:      binding.Protocol.String(),
		}

		if eni == nil {
			port.HostPort = binding.HostPort
		} else {
			port.HostPort = port.ContainerPort
		}

		resp = append(resp, port)
	}
	return resp
}
func NewPortBindingsResponse(dockerContainer *apicontainer.DockerContainer, eni *apieni.ENI) []PortResponse {
	container := dockerContainer.Container
	resp := []PortResponse{}

	bindings := container.GetKnownPortBindings()

	// if KnownPortBindings list is empty, then we use the port mapping
	// information that was passed down from ACS.
	if len(bindings) == 0 {
		bindings = container.Ports
	}

	for _, binding := range bindings {
		port := PortResponse{
			ContainerPort: binding.ContainerPort,
			Protocol:      binding.Protocol.String(),
		}

		if eni == nil {
			port.HostPort = binding.HostPort
		} else {
			port.HostPort = port.ContainerPort
		}

		resp = append(resp, port)
	}
	return resp
}
func NewPortBindingsResponse ( dockerContainer * apicontainer . DockerContainer , eni * apieni . ENI ) [ ] PortResponse { container := dockerContainer . Container resp := [ ] PortResponse { } bindings := container . GetKnownPortBindings ( ) // if KnownPortBindings list is empty, then we use the port mapping // information that was passed down from ACS. if len ( bindings ) == 0 { bindings = container . Ports } for _ , binding := range bindings { port := PortResponse { ContainerPort : binding . ContainerPort , Protocol : binding . Protocol . String ( ) , } if eni == nil { port . HostPort = binding . HostPort } else { port . HostPort = port . ContainerPort } resp = append ( resp , port ) } return resp }
// NewPortBindingsResponse creates PortResponse for a container.
NewPortBindingsResponse creates PortResponse for a container .