Skip to content

Commit 8104611

Browse files
authored
Merge pull request docker-archive#850 from docker/fix_path_appending
Fix path appending
2 parents 2ff803b + a78cc47 commit 8104611

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

cli/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"os/signal"
2525
"path/filepath"
2626
"regexp"
27+
"strings"
2728
"syscall"
2829
"time"
2930

@@ -73,13 +74,21 @@ func init() {
7374
if err != nil {
7475
fatal(errors.Wrap(err, "unable to get absolute bin path"))
7576
}
76-
if err := os.Setenv("PATH", fmt.Sprintf("%s:%s", os.Getenv("PATH"), path)); err != nil {
77+
78+
if err := os.Setenv("PATH", appendPaths(os.Getenv("PATH"), path)); err != nil {
7779
panic(err)
7880
}
7981
// Seed random
8082
rand.Seed(time.Now().UnixNano())
8183
}
8284

85+
func appendPaths(envPath string, path string) string {
86+
if envPath == "" {
87+
return path
88+
}
89+
return strings.Join([]string{envPath, path}, string(os.PathListSeparator))
90+
}
91+
8392
func isContextAgnosticCommand(cmd *cobra.Command) bool {
8493
if cmd == nil {
8594
return false

cli/main_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ func TestCheckOwnCommand(t *testing.T) {
6969
assert.Assert(t, !isContextAgnosticCommand(cmd.LogsCommand()))
7070
assert.Assert(t, !isContextAgnosticCommand(cmd.PsCommand()))
7171
}
72+
73+
func TestAppendPaths(t *testing.T) {
74+
assert.Equal(t, appendPaths("", "/bin/path"), "/bin/path")
75+
assert.Equal(t, appendPaths("path1", "binaryPath"), "path1"+string(os.PathListSeparator)+"binaryPath")
76+
}

tests/aci-e2e/e2e-aci_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,7 @@ func TestContainerRunAttached(t *testing.T) {
434434
endpoint = fmt.Sprintf("http://%s:%d", fqdn, port.HostPort)
435435

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

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

0 commit comments

Comments
 (0)