Skip to content

Commit

Permalink
Workaround for fargate support.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidworkman9 committed Dec 28, 2017
1 parent 53f1e63 commit 00619b9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,18 @@ func (s *scanner) extractContainer(t *ecs.Task, cd *ecs.ContainerDefinition) (*c
if strings.ToLower(*cd.Name) == *taskName {
return nil, errors.New("container is own container. skipping")
}
if len(s.nameNetworkBindingsMap[*cd.Name]) == 0 {
return nil, errors.New("container has no network bindings. skipping")
}
virtualHost, virtualPort, envVariables := extractVars(cd.Environment, s.hostVar)
if virtualHost == "" {
return nil, errors.New("[" + *cd.Name + "] " + s.hostVar + " environment variable not found. skipping")
}
port := ""
if len(s.nameNetworkBindingsMap[*cd.Name]) == 1 {
address := ""
if len(s.nameNetworkBindingsMap[*cd.Name]) == 0 {
port = strconv.FormatInt(80, 10)
address = string(*t.Containers[0].NetworkInterfaces[0].PrivateIpv4Address)
} else if len(s.nameNetworkBindingsMap[*cd.Name]) == 1 {
port = strconv.FormatInt(*s.nameNetworkBindingsMap[*cd.Name][0].HostPort, 10)
address = s.idAddressMap[*t.ContainerInstanceArn]
} else if virtualPort != "" {
port = extractHostPort(virtualPort, s.nameNetworkBindingsMap[*cd.Name])
}
Expand All @@ -127,7 +129,7 @@ func (s *scanner) extractContainer(t *ecs.Task, cd *ecs.ContainerDefinition) (*c
Host: virtualHost,
Port: port,
Env: envVariables,
Address: s.idAddressMap[*t.ContainerInstanceArn],
Address: address,
}, nil
}

Expand Down

0 comments on commit 00619b9

Please sign in to comment.