Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #850 from docker/fix_path_appending
Browse files Browse the repository at this point in the history
Fix path appending
  • Loading branch information
gtardif authored Oct 29, 2020
2 parents 2ff803b + a78cc47 commit 8104611
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
11 changes: 10 additions & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"os/signal"
"path/filepath"
"regexp"
"strings"
"syscall"
"time"

Expand Down Expand Up @@ -73,13 +74,21 @@ func init() {
if err != nil {
fatal(errors.Wrap(err, "unable to get absolute bin path"))
}
if err := os.Setenv("PATH", fmt.Sprintf("%s:%s", os.Getenv("PATH"), path)); err != nil {

if err := os.Setenv("PATH", appendPaths(os.Getenv("PATH"), path)); err != nil {
panic(err)
}
// Seed random
rand.Seed(time.Now().UnixNano())
}

func appendPaths(envPath string, path string) string {
if envPath == "" {
return path
}
return strings.Join([]string{envPath, path}, string(os.PathListSeparator))
}

func isContextAgnosticCommand(cmd *cobra.Command) bool {
if cmd == nil {
return false
Expand Down
5 changes: 5 additions & 0 deletions cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ func TestCheckOwnCommand(t *testing.T) {
assert.Assert(t, !isContextAgnosticCommand(cmd.LogsCommand()))
assert.Assert(t, !isContextAgnosticCommand(cmd.PsCommand()))
}

func TestAppendPaths(t *testing.T) {
assert.Equal(t, appendPaths("", "/bin/path"), "/bin/path")
assert.Equal(t, appendPaths("path1", "binaryPath"), "path1"+string(os.PathListSeparator)+"binaryPath")
}
9 changes: 1 addition & 8 deletions tests/aci-e2e/e2e-aci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,7 @@ func TestContainerRunAttached(t *testing.T) {
endpoint = fmt.Sprintf("http://%s:%d", fqdn, port.HostPort)

assert.Assert(t, !strings.Contains(followLogsProcess.Stdout(), "/test"))
checkRequest := func(t poll.LogT) poll.Result {
r, _ := http.Get(endpoint + "/test")
if r != nil && r.StatusCode == http.StatusNotFound {
return poll.Success()
}
return poll.Continue("waiting for container to serve request")
}
poll.WaitOn(t, checkRequest, poll.WithDelay(1*time.Second), poll.WithTimeout(60*time.Second))
HTTPGetWithRetry(t, endpoint+"/test", http.StatusNotFound, 2*time.Second, 60*time.Second)

checkLog := func(t poll.LogT) poll.Result {
if strings.Contains(followLogsProcess.Stdout(), "/test") {
Expand Down

0 comments on commit 8104611

Please sign in to comment.