Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 064a917

Browse files
Ulysses Souzachris-crone
authored andcommitted
Fix e2e binaries path and cli vendor override
- Update docker/cli is now pointing to chris-crone/cli. The change needs the merge of docker/cli#1718 and docker/cli#1690 - Fix issues relative paths in Jenkinsfile and Jenkinsfile.baguette - Avoid using '--config' in favor of env variable 'DOCKER_CONFIG' Signed-off-by: Ulysses Souza <ulysses.souza@docker.com>
1 parent 90010ff commit 064a917

16 files changed

Lines changed: 466 additions & 366 deletions

File tree

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ RUN apt-get install -y -q --no-install-recommends \
88

99
WORKDIR /go/src/github.com/docker/cli
1010

11-
RUN git clone https://github.com/docker/cli.git . && git checkout 8ddde26af67f9a76734a1676c635e48da4fe8584
11+
RUN git clone https://github.com/chris-crone/cli . && git checkout d6bfd7e5592dad85969516c131d33910fa5ebd58
12+
# FIXME(ulyssessouza): Go back to the line below when PRs https://github.com/docker/cli/pull/1718 and https://github.com/docker/cli/pull/1690 hits the cli
13+
#RUN git clone https://github.com/docker/cli.git . && git checkout 8ddde26af67f9a76734a1676c635e48da4fe8584
14+
1215
RUN make cross binary && \
1316
cp build/docker-linux-amd64 /usr/bin/docker
1417

Gopkg.lock

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ required = ["github.com/wadey/gocovmerge"]
3636
source = "github.com/simonferquel/containerd"
3737
revision = "a89234684e5884e51ba195bdb16b1c6952d17f11"
3838

39+
### Waiting on PR https://github.com/docker/cli/pull/1718 and https://github.com/docker/cli/pull/1690 to land on cli ###
3940
[[override]]
4041
name = "github.com/docker/cli"
41-
revision = "3ddb3133f5b5a74dd4e3f721ced21f4d0b9651b6"
42+
source = "https://github.com/chris-crone/cli"
43+
revision="d6bfd7e5592dad85969516c131d33910fa5ebd58"
4244

4345
[[override]]
4446
name = "github.com/deislabs/duffle"

Jenkinsfile.baguette

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ pipeline {
7979
parallel {
8080
stage("Unit Coverage") {
8181
environment {
82+
DOCKERAPP_BINARY = '../e2e/coverage-bin'
83+
DOCKERCLI_BINARY = '../docker-linux'
8284
CODECOV_TOKEN = credentials('jenkins-codecov-token')
8385
}
8486
agent {

e2e/commands_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ maintainers:
103103
testAppName := "app-test"
104104
dirName := internal.DirNameFromAppName(testAppName)
105105

106-
cmd := icmd.Cmd{Dir: tmpDir.Path()}
106+
cmd := icmd.Cmd{Dir: tmpDir.Path(), Env: os.Environ()}
107107

108108
cmd.Command = dockerCli.Command("app",
109109
"init", testAppName,
@@ -214,7 +214,7 @@ func TestBundle(t *testing.T) {
214214
tmpDir := fs.NewDir(t, t.Name())
215215
defer tmpDir.Remove()
216216
// Using a custom DOCKER_CONFIG to store contexts in a temporary directory
217-
cmd := icmd.Cmd{Env: append(os.Environ(), "DOCKER_CONFIG="+tmpDir.Path())}
217+
cmd := icmd.Cmd{Env: os.Environ()}
218218

219219
// Running a docker in docker to bundle the application
220220
dind := NewContainer("docker:18.09-dind", 2375)
@@ -271,7 +271,6 @@ func TestDockerAppLifecycle(t *testing.T) {
271271
cmd := icmd.Cmd{
272272
Env: append(os.Environ(),
273273
fmt.Sprintf("DUFFLE_HOME=%s", tmpDir.Path()),
274-
fmt.Sprintf("DOCKER_CONFIG=%s", tmpDir.Path()),
275274
"DOCKER_TARGET_CONTEXT=swarm-target-context",
276275
),
277276
}

e2e/coverage-bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This script is a proxy that injects the required test flags and strips out test output
44
# It allows us to use a coverage-enabled binary for e2e tests
55

6-
BUILD_DIR=${BASH_SOURCE%/*}/../_build
6+
BUILD_DIR=${GOPATH}/src/github.com/docker/app/_build
77

88
$BUILD_DIR/docker-app.cov \
99
-test.coverprofile=$BUILD_DIR/cov/$(uuidgen).out \

e2e/main_test.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ package e2e
22

33
import (
44
"bytes"
5+
"encoding/json"
56
"flag"
6-
"fmt"
77
"io/ioutil"
88
"os"
99
"os/exec"
1010
"path/filepath"
11+
"runtime"
1112
"strings"
1213
"testing"
14+
15+
dockerConfigFile "github.com/docker/cli/cli/config/configfile"
1316
)
1417

1518
var (
@@ -20,17 +23,13 @@ var (
2023
dockerCli dockerCliCommand
2124
)
2225

23-
const config = `{
24-
"cliPluginsExtraDirs": ["%s"]
25-
}`
26-
2726
type dockerCliCommand struct {
2827
path string
2928
config string
3029
}
3130

3231
func (d dockerCliCommand) Command(args ...string) []string {
33-
return append([]string{d.path, "--config", d.config}, args...)
32+
return append([]string{d.path}, args...)
3433
}
3534

3635
func TestMain(m *testing.M) {
@@ -55,22 +54,45 @@ func TestMain(m *testing.M) {
5554
// - Create a symbolic link with the dockerApp binary to the plugin directory
5655
if dockerCliPath == "" {
5756
dockerCliPath = "docker"
57+
} else {
58+
dockerCliPath, err = filepath.Abs(dockerCliPath)
59+
if err != nil {
60+
panic(err)
61+
}
5862
}
5963
configDir, err := ioutil.TempDir("", "config")
6064
if err != nil {
6165
panic(err.Error())
6266
}
6367
defer os.RemoveAll(configDir)
68+
69+
err = os.Setenv("DOCKER_CONFIG", configDir)
70+
if err != nil {
71+
panic(err.Error())
72+
}
6473
dockerCli = dockerCliCommand{path: dockerCliPath, config: configDir}
65-
ioutil.WriteFile(filepath.Join(configDir, "config.json"), []byte(fmt.Sprintf(config, configDir)), 0644)
66-
if err := os.Symlink(dockerApp, filepath.Join(configDir, "docker-app")); err != nil {
74+
75+
config := dockerConfigFile.ConfigFile{CLIPluginsExtraDirs: []string{configDir}}
76+
configFile, err := os.Create(filepath.Join(configDir, "config.json"))
77+
if err != nil {
78+
panic(err.Error())
79+
}
80+
err = json.NewEncoder(configFile).Encode(config)
81+
if err != nil {
82+
panic(err.Error())
83+
}
84+
dockerAppExecName := "docker-app"
85+
if runtime.GOOS == "windows" {
86+
dockerAppExecName += ".exe"
87+
}
88+
if err := os.Symlink(dockerApp, filepath.Join(configDir, dockerAppExecName)); err != nil {
6789
panic(err.Error())
6890
}
6991

7092
cmd := exec.Command(dockerApp, "app", "version")
7193
output, err := cmd.CombinedOutput()
7294
if err != nil {
73-
panic(err)
95+
panic(err.Error())
7496
}
7597
hasExperimental = bytes.Contains(output, []byte("Experimental: on"))
7698
i := strings.Index(string(output), "Renderers")

vendor/github.com/docker/cli/cli-plugins/manager/cobra.go

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/cli/cli/cobra.go

Lines changed: 24 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/cli/cli/command/cli.go

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)