<commit_before>package dockerproxy

import (
	"bufio"
	"errors"
	"os"
	"regexp"
	"strconv"
	"strings"

	"github.com/fsouza/go-dockerclient"
)

const (
	hostKey = "VIRTUAL_HOST"
	portKey = "VIRTUAL_PORT"
)

// Site represents a single containers' site, which consists
// of the container the site is running in, the IP/Port necessary
// to contact it, as well as 1+ virtual host to advertise.
type Site struct {
	ID      string
	Names   []string
	Contact Mapping
	Hosts   []string
	Env     map[string]string
}

// Mapping represents an IP/Port as well as optional network name
// to map the current container to the container we're representing
type Mapping struct {
	Address string
	Port    int64
	Network string
}

func mapContainers(client *docker.Client, containers []docker.APIContainers) ([]Site, error) {
	list := make([]Site, 0, len(containers))
	myNets, me, err := myInfo(client)
	if err != nil {
		return nil, err
	}

	for _, v := range containers {
		if v.ID == me {
			continue
		}

		info, err := client.InspectContainer(v.ID)
		if err != nil {
			return nil, err
		}
		env, err := parseKV(info.Config.Env)
		if err != nil {
			return nil, err
		}

		hosts, ok := findHosts(env)
		if !ok {
			continue<commit_msg>mapping: skip containers with bad environments<commit_after>package dockerproxy

import (
	"bufio"
	"errors"
	"os"
	"regexp"
	"strconv"
	"strings"

	"github.com/fsouza/go-dockerclient"
)

const (
	hostKey = "VIRTUAL_HOST"
	portKey = "VIRTUAL_PORT"
)

// Site represents a single containers' site, which consists
// of the container the site is running in, the IP/Port necessary
// to contact it, as well as 1+ virtual host to advertise.
type Site struct {
	ID      string
	Names   []string
	Contact Mapping
	Hosts   []string
	Env     map[string]string
}

// Mapping represents an IP/Port as well as optional network name
// to map the current container to the container we're representing
type Mapping struct {
	Address string
	Port    int64
	Network string
}

func mapContainers(client *docker.Client, containers []docker.APIContainers) ([]Site, error) {
	list := make([]Site, 0, len(containers))
	myNets, me, err := myInfo(client)
	if err != nil {
		return nil, err
	}

	for _, v := range containers {
		if v.ID == me {
			continue
		}

		info, err := client.InspectContainer(v.ID)
		if err != nil {
			return nil, err
		}
		env, err := parseKV(info.Config.Env)
		if err != nil {
			continue
		}

		hosts, ok := findHosts(env)
		if !ok {
			continue
{'fraction_non_alphanumeric': 0.10904684975767366, 'fraction_numerical': 0.0032310177705977385, 'mean_word_length': 3.3763250883392226, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4568873', 'n_tokens_mistral': 902, 'n_tokens_neox': 833, 'n_words': 282}