revert previous commit

This commit is contained in:
Antonio Fernández 2015-11-17 07:05:11 +01:00
parent 669635778a
commit d6ac883827
2 changed files with 2 additions and 63 deletions

View file

@ -14,7 +14,6 @@ import (
"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/client/driver/args"
"github.com/hashicorp/nomad/client/driver/environment"
"github.com/hashicorp/nomad/client/fingerprint"
"github.com/hashicorp/nomad/nomad/structs"
)
@ -44,10 +43,6 @@ func NewDockerDriver(ctx *DriverContext) Driver {
return &DockerDriver{DriverContext: *ctx}
}
const (
labelPrefix = environment.MetaPrefix + "LABEL_"
)
// dockerClient creates *docker.Client. In test / dev mode we can use ENV vars
// to connect to the docker daemon. In production mode we will read
// docker.endpoint from the config file.
@ -271,12 +266,9 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task) (do
env.SetAllocDir(filepath.Join("/", allocdir.SharedAllocName))
env.SetTaskLocalDir(filepath.Join("/", allocdir.TaskLocal))
envVars, labels := splitEnvVarsLabels(env.List())
config := &docker.Config{
Env: envVars,
Labels: labels,
Image: task.Config["image"],
Env: env.List(),
Image: task.Config["image"],
}
rawArgs, hasArgs := task.Config["args"]
@ -565,20 +557,3 @@ func (h *dockerHandle) run() {
}
close(h.waitCh)
}
// splitEnvVarsLabels returns environment vars and labels to set on the container
func splitEnvVarsLabels(envVars []string) ([]string, map[string]string) {
var envs []string
labels := make(map[string]string)
for _, value := range envVars {
if strings.HasPrefix(value, labelPrefix) {
parts := strings.SplitN(value, "=", 2)
labels[strings.TrimPrefix(parts[0], labelPrefix)] = parts[1]
} else {
envs = append(envs, value)
}
}
return envs, labels
}

View file

@ -432,39 +432,3 @@ func TestDockerHostNet(t *testing.T) {
}
defer handle.Kill()
}
func TestsSlitEnvVarsLabels(t *testing.T) {
environment := []string{
"NOMAD_IP=1.1.1.1",
"NOMAD_CPU_LIMIT=500",
"NOMAD_META_TEST1=true_one",
"NOMAD_META_LABEL_LAB1=one",
"NOMAD_META_TEST2=test_two",
"NOMAD_META_LABEL_LAB2=two",
"NOMAD_META_TEST3=true_three",
"NOMAD_META_LABEL_LAB3=three",
"NOMAD_MEMORY_LIMIT=1024",
}
envVars, labels := splitEnvVarsLabels(environment)
if got, want := len(envVars), 6; got != want {
t.Errorf("Error on len. Got: %v. Expect %v items.", got, want)
}
if got, want := len(labels), 3; got != want {
t.Errorf("Error on len. Got: %v. Expect %v items.", got, want)
}
if got, want := envVars[3], environment[4]; got != want {
t.Errorf("Error. Got: '%v'. Expect '%v'.", got, want)
}
if got, want := envVars[4], environment[6]; got != want {
t.Errorf("Error. Got: '%v'. Expect '%v'.", got, want)
}
if got, want := labels["LAB2"], "two"; got != want {
t.Errorf("Error. Got: '%v'. Expect '%v'.", got, want)
}
if got, want := labels["LAB3"], "three"; got != want {
t.Errorf("Error. Got: '%v'. Expect '%v'.", got, want)
}
}