From d6ac88382723a083f9d3425e7b12e6bc05b34459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Fern=C3=A1ndez?= Date: Tue, 17 Nov 2015 07:05:11 +0100 Subject: [PATCH] revert previous commit --- client/driver/docker.go | 29 ++--------------------------- client/driver/docker_test.go | 36 ------------------------------------ 2 files changed, 2 insertions(+), 63 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index ac073cda2..862587dd2 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -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 -} diff --git a/client/driver/docker_test.go b/client/driver/docker_test.go index 246950333..872c2419b 100644 --- a/client/driver/docker_test.go +++ b/client/driver/docker_test.go @@ -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) - } - -}