in local-container-endpoints/handlers/metadata.go [242:265]
func findContainer(dockerContainers []types.Container, identifier string, callerIP string) (*types.Container, error) {
var filteredList = dockerContainers
if identifier != "" {
filteredList = filterContainersByIdentifier(dockerContainers, identifier)
if len(filteredList) == 1 { // we found the container
return &filteredList[0], nil
}
}
if callerIP != "" {
filteredList = filterContainersByRequestIP(filteredList, callerIP)
if len(filteredList) == 1 { // we found the container
return &filteredList[0], nil
}
}
filteredList = filterContainersByMyNetworks(filteredList, dockerContainers, callerIP)
if len(filteredList) == 1 { // we found the container
return &filteredList[0], nil
}
return nil, fmt.Errorf("Failed to find the container which the request came from. Narrowed down search to %d containers", len(filteredList))
}