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

Commit

Permalink
Merge pull request #161 from vania-pooh/master
Browse files Browse the repository at this point in the history
Automatically linking Selenoid UI to Selenoid / GgrUI (fixes #156)
  • Loading branch information
vania-pooh authored May 31, 2018
2 parents 071658d + fce85f0 commit 5d882f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions selenoid/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ type PortAware struct {
}

const (
GgrUIDefaultPort = 8888
SelenoidDefaultPort = 4444
SelenoidUIDefaultPort = 8080
DefaultRegistryUrl = "https://registry.hub.docker.com"
Expand Down
22 changes: 18 additions & 4 deletions selenoid/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (
selenoidUIImage = "aerokube/selenoid-ui"
videoRecorderImage = "selenoid/video-recorder"
selenoidContainerName = "selenoid"
ggrUIContainerName = "ggr-ui"
selenoidUIContainerName = "selenoid-ui"
overrideHome = "OVERRIDE_HOME"
dockerApiVersion = "DOCKER_API_VERSION"
Expand Down Expand Up @@ -720,15 +721,28 @@ func (c *DockerConfigurator) StartUI() error {
return errors.New("Selenoid UI image is not downloaded: this is probably a bug")
}

links := []string{selenoidContainerName}

cmd := []string{}
var cmd, links []string
var selenoidUri string
for containerName, port := range map[string]int{
selenoidContainerName: SelenoidDefaultPort,
ggrUIContainerName: GgrUIDefaultPort,
} {
if c.getContainer(containerName, port) != nil {
selenoidUri = fmt.Sprintf("--selenoid-uri=http://%s:%d", containerName, port)
links = []string{containerName}
break
}
}
overrideCmd := strings.Fields(c.Args)
if len(overrideCmd) > 0 {
cmd = overrideCmd
}
if !contains(cmd, "--selenoid-uri") {
cmd = append(cmd, fmt.Sprintf("--selenoid-uri=http://%s:%d", selenoidContainerName, SelenoidDefaultPort))
cmd = append(cmd, selenoidUri)
}

if len(links) == 0 {
c.Errorf("Neither Selenoid nor Ggr UI is started. Selenoid UI may not work.")
}

overrideEnv := strings.Fields(c.Env)
Expand Down

0 comments on commit 5d882f4

Please sign in to comment.