Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Fix issue in cm (#84)
Browse files Browse the repository at this point in the history
Excluding Windows variables breaking Docker container startup (related to #81)

* Add tests for validEnviron

* fixes #81
  • Loading branch information
Roman Orlov authored and vania-pooh committed Oct 10, 2017
1 parent 5b950d9 commit 779638f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion selenoid/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,19 @@ func (c *DockerConfigurator) StartUI() error {
return c.startContainer(selenoidUIContainerName, image, selenoidUIContainerPort, []string{}, links, cmd, overrideEnv)
}

func validateEnviron(envs []string) []string {
validEnv := []string{}
for _, e := range envs {
k := strings.Split(e, "=")
if len(k[0]) != 0 {
validEnv = append(validEnv, e)
}
}
return validEnv
}

func (c *DockerConfigurator) startContainer(name string, image *types.ImageSummary, forwardedPort int, volumes []string, links []string, cmd []string, envOverride []string) error {
env := os.Environ()
env := validateEnviron(os.Environ())
env = append(env, fmt.Sprintf("TZ=%s", time.Local))
if len(envOverride) > 0 {
env = envOverride
Expand Down
5 changes: 5 additions & 0 deletions selenoid/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,8 @@ func TestPostProcessPath(t *testing.T) {
AssertThat(t, postProcessPath("1"), EqualTo{"1"})
AssertThat(t, postProcessPath(""), EqualTo{""})
}

func TestValidEnviron(t *testing.T) {
AssertThat(t, validateEnviron([]string{"=::=::"}), EqualTo{[]string{}})
AssertThat(t, validateEnviron([]string{"HOMEDRIVE=C:", "DOCKER_HOST=192.168.0.1" , "=::=::"}), EqualTo{[]string{"HOMEDRIVE=C:", "DOCKER_HOST=192.168.0.1"}})
}

0 comments on commit 779638f

Please sign in to comment.