Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
|
| 14 | 14 |
"github.com/docker/docker/api/types/swarm" |
| 15 | 15 |
cliconfig "github.com/docker/docker/cli/config" |
| 16 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 16 | 17 |
"github.com/docker/docker/integration-cli/daemon" |
| 17 | 18 |
"github.com/docker/docker/integration-cli/environment" |
| 18 | 19 |
"github.com/docker/docker/integration-cli/registry" |
| ... | ... |
@@ -51,15 +52,7 @@ func init() {
|
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 | 53 |
func TestMain(m *testing.M) {
|
| 54 |
- var err error |
|
| 55 |
- if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
|
|
| 56 |
- dockerBinary = dockerBin |
|
| 57 |
- } |
|
| 58 |
- dockerBinary, err = exec.LookPath(dockerBinary) |
|
| 59 |
- if err != nil {
|
|
| 60 |
- fmt.Printf("ERROR: couldn't resolve full path to the Docker binary (%v)\n", err)
|
|
| 61 |
- os.Exit(1) |
|
| 62 |
- } |
|
| 54 |
+ dockerBinary = testEnv.DockerBinary() |
|
| 63 | 55 |
|
| 64 | 56 |
if testEnv.LocalDaemon() {
|
| 65 | 57 |
fmt.Println("INFO: Testing against a local daemon")
|
| ... | ... |
@@ -71,6 +64,7 @@ func TestMain(m *testing.M) {
|
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 | 73 |
func Test(t *testing.T) {
|
| 74 |
+ cli.EnsureTestEnvIsLoaded(t) |
|
| 74 | 75 |
cmd := exec.Command(dockerBinary, "images", "-f", "dangling=false", "--format", "{{.Repository}}:{{.Tag}}")
|
| 75 | 76 |
cmd.Env = appendBaseEnv(true) |
| 76 | 77 |
out, err := cmd.CombinedOutput() |
| 77 | 78 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,31 @@ |
| 0 |
+package build |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "strings" |
|
| 4 |
+ |
|
| 5 |
+ icmd "github.com/docker/docker/pkg/testutil/cmd" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+// WithDockerfile creates / returns a CmdOperator to set the Dockerfile for a build operation |
|
| 9 |
+func WithDockerfile(dockerfile string) func(*icmd.Cmd) func() {
|
|
| 10 |
+ return func(cmd *icmd.Cmd) func() {
|
|
| 11 |
+ cmd.Command = append(cmd.Command, "-") |
|
| 12 |
+ cmd.Stdin = strings.NewReader(dockerfile) |
|
| 13 |
+ return nil |
|
| 14 |
+ } |
|
| 15 |
+} |
|
| 16 |
+ |
|
| 17 |
+// WithoutCache makes the build ignore cache |
|
| 18 |
+func WithoutCache(cmd *icmd.Cmd) func() {
|
|
| 19 |
+ cmd.Command = append(cmd.Command, "--no-cache") |
|
| 20 |
+ return nil |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+// WithContextPath set the build context path |
|
| 24 |
+func WithContextPath(path string) func(*icmd.Cmd) func() {
|
|
| 25 |
+ // WithContextPath sets the build context path |
|
| 26 |
+ return func(cmd *icmd.Cmd) func() {
|
|
| 27 |
+ cmd.Command = append(cmd.Command, path) |
|
| 28 |
+ return nil |
|
| 29 |
+ } |
|
| 30 |
+} |
| 0 | 31 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,129 @@ |
| 0 |
+package cli |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "fmt" |
|
| 4 |
+ "sync" |
|
| 5 |
+ "time" |
|
| 6 |
+ |
|
| 7 |
+ "github.com/docker/docker/integration-cli/daemon" |
|
| 8 |
+ "github.com/docker/docker/integration-cli/environment" |
|
| 9 |
+ icmd "github.com/docker/docker/pkg/testutil/cmd" |
|
| 10 |
+) |
|
| 11 |
+ |
|
| 12 |
+var ( |
|
| 13 |
+ testEnv *environment.Execution |
|
| 14 |
+ onlyOnce sync.Once |
|
| 15 |
+) |
|
| 16 |
+ |
|
| 17 |
+// EnsureTestEnvIsLoaded make sure the test environment is loaded for this package |
|
| 18 |
+func EnsureTestEnvIsLoaded(t testingT) {
|
|
| 19 |
+ var doIt bool |
|
| 20 |
+ var err error |
|
| 21 |
+ onlyOnce.Do(func() {
|
|
| 22 |
+ doIt = true |
|
| 23 |
+ }) |
|
| 24 |
+ |
|
| 25 |
+ if !doIt {
|
|
| 26 |
+ return |
|
| 27 |
+ } |
|
| 28 |
+ testEnv, err = environment.New() |
|
| 29 |
+ if err != nil {
|
|
| 30 |
+ t.Fatalf("error loading testenv : %v", err)
|
|
| 31 |
+ } |
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+// CmdOperator defines functions that can modify a command |
|
| 35 |
+type CmdOperator func(*icmd.Cmd) func() |
|
| 36 |
+ |
|
| 37 |
+type testingT interface {
|
|
| 38 |
+ Fatalf(string, ...interface{})
|
|
| 39 |
+} |
|
| 40 |
+ |
|
| 41 |
+// DockerCmd executes the specified docker command and expect a success |
|
| 42 |
+func DockerCmd(t testingT, command string, args ...string) *icmd.Result {
|
|
| 43 |
+ return Docker(Cmd(command, args...)).Assert(t, icmd.Success) |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+// BuildCmd executes the specified docker build command and expect a success |
|
| 47 |
+func BuildCmd(t testingT, name string, cmdOperators ...CmdOperator) *icmd.Result {
|
|
| 48 |
+ return Docker(Build(name), cmdOperators...).Assert(t, icmd.Success) |
|
| 49 |
+} |
|
| 50 |
+ |
|
| 51 |
+// InspectCmd executes the specified docker inspect command and expect a success |
|
| 52 |
+func InspectCmd(t testingT, name string, cmdOperators ...CmdOperator) *icmd.Result {
|
|
| 53 |
+ return Docker(Inspect(name), cmdOperators...).Assert(t, icmd.Success) |
|
| 54 |
+} |
|
| 55 |
+ |
|
| 56 |
+// Docker executes the specified docker command |
|
| 57 |
+func Docker(cmd icmd.Cmd, cmdOperators ...CmdOperator) *icmd.Result {
|
|
| 58 |
+ for _, op := range cmdOperators {
|
|
| 59 |
+ deferFn := op(&cmd) |
|
| 60 |
+ if deferFn != nil {
|
|
| 61 |
+ defer deferFn() |
|
| 62 |
+ } |
|
| 63 |
+ } |
|
| 64 |
+ appendDocker(&cmd) |
|
| 65 |
+ return icmd.RunCmd(cmd) |
|
| 66 |
+} |
|
| 67 |
+ |
|
| 68 |
+// Build executes the specified docker build command |
|
| 69 |
+func Build(name string) icmd.Cmd {
|
|
| 70 |
+ return icmd.Command("build", "-t", name)
|
|
| 71 |
+} |
|
| 72 |
+ |
|
| 73 |
+// Inspect executes the specified docker inspect command |
|
| 74 |
+func Inspect(name string) icmd.Cmd {
|
|
| 75 |
+ return icmd.Command("inspect", name)
|
|
| 76 |
+} |
|
| 77 |
+ |
|
| 78 |
+// Format sets the specified format with --format flag |
|
| 79 |
+func Format(format string) func(*icmd.Cmd) func() {
|
|
| 80 |
+ return func(cmd *icmd.Cmd) func() {
|
|
| 81 |
+ cmd.Command = append( |
|
| 82 |
+ []string{cmd.Command[0]},
|
|
| 83 |
+ append([]string{"--format", fmt.Sprintf("{{%s}}", format)}, cmd.Command[1:]...)...,
|
|
| 84 |
+ ) |
|
| 85 |
+ return nil |
|
| 86 |
+ } |
|
| 87 |
+} |
|
| 88 |
+ |
|
| 89 |
+func appendDocker(cmd *icmd.Cmd) {
|
|
| 90 |
+ cmd.Command = append([]string{testEnv.DockerBinary()}, cmd.Command...)
|
|
| 91 |
+} |
|
| 92 |
+ |
|
| 93 |
+// Cmd build an icmd.Cmd struct from the specified command and arguments |
|
| 94 |
+func Cmd(command string, args ...string) icmd.Cmd {
|
|
| 95 |
+ return icmd.Command(command, args...) |
|
| 96 |
+} |
|
| 97 |
+ |
|
| 98 |
+// Daemon points to the specified daemon |
|
| 99 |
+func Daemon(d *daemon.Daemon) func(*icmd.Cmd) func() {
|
|
| 100 |
+ return func(cmd *icmd.Cmd) func() {
|
|
| 101 |
+ cmd.Command = append([]string{"--host", d.Sock()}, cmd.Command...)
|
|
| 102 |
+ return nil |
|
| 103 |
+ } |
|
| 104 |
+} |
|
| 105 |
+ |
|
| 106 |
+// WithTimeout sets the timeout for the command to run |
|
| 107 |
+func WithTimeout(timeout time.Duration) func(cmd *icmd.Cmd) func() {
|
|
| 108 |
+ return func(cmd *icmd.Cmd) func() {
|
|
| 109 |
+ cmd.Timeout = timeout |
|
| 110 |
+ return nil |
|
| 111 |
+ } |
|
| 112 |
+} |
|
| 113 |
+ |
|
| 114 |
+// WithEnvironmentVariables sets the specified environment variables for the command to run |
|
| 115 |
+func WithEnvironmentVariables(envs ...string) func(cmd *icmd.Cmd) func() {
|
|
| 116 |
+ return func(cmd *icmd.Cmd) func() {
|
|
| 117 |
+ cmd.Env = envs |
|
| 118 |
+ return nil |
|
| 119 |
+ } |
|
| 120 |
+} |
|
| 121 |
+ |
|
| 122 |
+// WithFlags sets the specified flags for the command to run |
|
| 123 |
+func WithFlags(flags ...string) func(*icmd.Cmd) func() {
|
|
| 124 |
+ return func(cmd *icmd.Cmd) func() {
|
|
| 125 |
+ cmd.Command = append(cmd.Command, flags...) |
|
| 126 |
+ return nil |
|
| 127 |
+ } |
|
| 128 |
+} |
| ... | ... |
@@ -21,6 +21,7 @@ import ( |
| 21 | 21 |
mounttypes "github.com/docker/docker/api/types/mount" |
| 22 | 22 |
networktypes "github.com/docker/docker/api/types/network" |
| 23 | 23 |
"github.com/docker/docker/integration-cli/checker" |
| 24 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 24 | 25 |
"github.com/docker/docker/integration-cli/request" |
| 25 | 26 |
"github.com/docker/docker/pkg/ioutils" |
| 26 | 27 |
"github.com/docker/docker/pkg/mount" |
| ... | ... |
@@ -1768,7 +1769,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) {
|
| 1768 | 1768 |
) |
| 1769 | 1769 |
if testEnv.DaemonPlatform() != "windows" {
|
| 1770 | 1770 |
testImg = "test-mount-config" |
| 1771 |
- buildImageSuccessfully(c, testImg, withDockerfile(` |
|
| 1771 |
+ buildImageSuccessfully(c, testImg, build.WithDockerfile(` |
|
| 1772 | 1772 |
FROM busybox |
| 1773 | 1773 |
RUN mkdir `+destPath+` && touch `+destPath+slash+`bar |
| 1774 | 1774 |
CMD cat `+destPath+slash+`bar |
| ... | ... |
@@ -9,6 +9,8 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 | 10 |
"github.com/docker/docker/api/types/image" |
| 11 | 11 |
"github.com/docker/docker/integration-cli/checker" |
| 12 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 13 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 12 | 14 |
"github.com/docker/docker/integration-cli/request" |
| 13 | 15 |
"github.com/go-check/check" |
| 14 | 16 |
) |
| ... | ... |
@@ -53,7 +55,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) {
|
| 53 | 53 |
// TODO Windows to Windows CI: Investigate further why this test fails. |
| 54 | 54 |
testRequires(c, Network) |
| 55 | 55 |
testRequires(c, DaemonIsLinux) |
| 56 |
- buildImageSuccessfully(c, "saveandload", withDockerfile("FROM busybox\nENV FOO bar"))
|
|
| 56 |
+ buildImageSuccessfully(c, "saveandload", build.WithDockerfile("FROM busybox\nENV FOO bar"))
|
|
| 57 | 57 |
id := getIDByName(c, "saveandload") |
| 58 | 58 |
|
| 59 | 59 |
res, body, err := request.Get("/images/" + id + "/get")
|
| ... | ... |
@@ -68,7 +70,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) {
|
| 68 | 68 |
defer loadBody.Close() |
| 69 | 69 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 70 | 70 |
|
| 71 |
- inspectOut := inspectField(c, id, "Id") |
|
| 71 |
+ inspectOut := cli.InspectCmd(c, id, cli.Format(".Id")).Combined()
|
|
| 72 | 72 |
c.Assert(strings.TrimSpace(string(inspectOut)), checker.Equals, id, check.Commentf("load did not work properly"))
|
| 73 | 73 |
} |
| 74 | 74 |
|
| ... | ... |
@@ -77,7 +79,7 @@ func (s *DockerSuite) TestAPIImagesDelete(c *check.C) {
|
| 77 | 77 |
testRequires(c, Network) |
| 78 | 78 |
} |
| 79 | 79 |
name := "test-api-images-delete" |
| 80 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nENV FOO bar"))
|
|
| 80 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nENV FOO bar"))
|
|
| 81 | 81 |
id := getIDByName(c, name) |
| 82 | 82 |
|
| 83 | 83 |
dockerCmd(c, "tag", name, "test:tag1") |
| ... | ... |
@@ -100,7 +102,7 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
|
| 100 | 100 |
testRequires(c, Network) |
| 101 | 101 |
} |
| 102 | 102 |
name := "test-api-images-history" |
| 103 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nENV FOO bar"))
|
|
| 103 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nENV FOO bar"))
|
|
| 104 | 104 |
id := getIDByName(c, name) |
| 105 | 105 |
|
| 106 | 106 |
status, body, err := request.SockRequest("GET", "/images/"+id+"/history", nil, daemonHost())
|
| ... | ... |
@@ -18,6 +18,8 @@ import ( |
| 18 | 18 |
|
| 19 | 19 |
"github.com/docker/docker/builder/dockerfile/command" |
| 20 | 20 |
"github.com/docker/docker/integration-cli/checker" |
| 21 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 22 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 21 | 23 |
"github.com/docker/docker/pkg/archive" |
| 22 | 24 |
"github.com/docker/docker/pkg/stringutils" |
| 23 | 25 |
"github.com/docker/docker/pkg/testutil" |
| ... | ... |
@@ -26,7 +28,7 @@ import ( |
| 26 | 26 |
) |
| 27 | 27 |
|
| 28 | 28 |
func (s *DockerSuite) TestBuildJSONEmptyRun(c *check.C) {
|
| 29 |
- buildImageSuccessfully(c, "testbuildjsonemptyrun", withDockerfile(` |
|
| 29 |
+ cli.BuildCmd(c, "testbuildjsonemptyrun", build.WithDockerfile(` |
|
| 30 | 30 |
FROM busybox |
| 31 | 31 |
RUN [] |
| 32 | 32 |
`)) |
| ... | ... |
@@ -39,7 +41,7 @@ func (s *DockerSuite) TestBuildShCmdJSONEntrypoint(c *check.C) {
|
| 39 | 39 |
expected = "cmd /S /C echo test" |
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 42 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 43 | 43 |
FROM busybox |
| 44 | 44 |
ENTRYPOINT ["echo"] |
| 45 | 45 |
CMD echo test |
| ... | ... |
@@ -56,7 +58,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementUser(c *check.C) {
|
| 56 | 56 |
testRequires(c, DaemonIsLinux) |
| 57 | 57 |
name := "testbuildenvironmentreplacement" |
| 58 | 58 |
|
| 59 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 59 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 60 | 60 |
FROM scratch |
| 61 | 61 |
ENV user foo |
| 62 | 62 |
USER ${user}
|
| ... | ... |
@@ -79,7 +81,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementVolume(c *check.C) {
|
| 79 | 79 |
volumePath = "/quux" |
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 82 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 83 | 83 |
FROM `+minimalBaseImage()+` |
| 84 | 84 |
ENV volume `+volumePath+` |
| 85 | 85 |
VOLUME ${volume}
|
| ... | ... |
@@ -98,7 +100,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementExpose(c *check.C) {
|
| 98 | 98 |
testRequires(c, DaemonIsLinux) |
| 99 | 99 |
name := "testbuildenvironmentreplacement" |
| 100 | 100 |
|
| 101 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 101 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 102 | 102 |
FROM scratch |
| 103 | 103 |
ENV port 80 |
| 104 | 104 |
EXPOSE ${port}
|
| ... | ... |
@@ -121,7 +123,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementExpose(c *check.C) {
|
| 121 | 121 |
func (s *DockerSuite) TestBuildEnvironmentReplacementWorkdir(c *check.C) {
|
| 122 | 122 |
name := "testbuildenvironmentreplacement" |
| 123 | 123 |
|
| 124 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 124 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 125 | 125 |
FROM busybox |
| 126 | 126 |
ENV MYWORKDIR /work |
| 127 | 127 |
RUN mkdir ${MYWORKDIR}
|
| ... | ... |
@@ -167,7 +169,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementEnv(c *check.C) {
|
| 167 | 167 |
testRequires(c, DaemonIsLinux) |
| 168 | 168 |
name := "testbuildenvironmentreplacement" |
| 169 | 169 |
|
| 170 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 170 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 171 | 171 |
FROM busybox |
| 172 | 172 |
ENV foo zzz |
| 173 | 173 |
ENV bar ${foo}
|
| ... | ... |
@@ -244,7 +246,7 @@ func (s *DockerSuite) TestBuildHandleEscapesInVolume(c *check.C) {
|
| 244 | 244 |
} |
| 245 | 245 |
|
| 246 | 246 |
for _, tc := range testCases {
|
| 247 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf(` |
|
| 247 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(` |
|
| 248 | 248 |
FROM scratch |
| 249 | 249 |
ENV FOO bar |
| 250 | 250 |
VOLUME %s |
| ... | ... |
@@ -265,12 +267,12 @@ func (s *DockerSuite) TestBuildOnBuildLowercase(c *check.C) {
|
| 265 | 265 |
name := "testbuildonbuildlowercase" |
| 266 | 266 |
name2 := "testbuildonbuildlowercase2" |
| 267 | 267 |
|
| 268 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 268 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 269 | 269 |
FROM busybox |
| 270 | 270 |
onbuild run echo quux |
| 271 | 271 |
`)) |
| 272 | 272 |
|
| 273 |
- result := buildImage(name2, withDockerfile(fmt.Sprintf(` |
|
| 273 |
+ result := buildImage(name2, build.WithDockerfile(fmt.Sprintf(` |
|
| 274 | 274 |
FROM %s |
| 275 | 275 |
`, name))) |
| 276 | 276 |
result.Assert(c, icmd.Success) |
| ... | ... |
@@ -289,7 +291,7 @@ func (s *DockerSuite) TestBuildEnvEscapes(c *check.C) {
|
| 289 | 289 |
// ENV expansions work differently in Windows |
| 290 | 290 |
testRequires(c, DaemonIsLinux) |
| 291 | 291 |
name := "testbuildenvescapes" |
| 292 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 292 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 293 | 293 |
FROM busybox |
| 294 | 294 |
ENV TEST foo |
| 295 | 295 |
CMD echo \$ |
| ... | ... |
@@ -306,7 +308,7 @@ func (s *DockerSuite) TestBuildEnvOverwrite(c *check.C) {
|
| 306 | 306 |
// ENV expansions work differently in Windows |
| 307 | 307 |
testRequires(c, DaemonIsLinux) |
| 308 | 308 |
name := "testbuildenvoverwrite" |
| 309 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 309 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 310 | 310 |
FROM busybox |
| 311 | 311 |
ENV TEST foo |
| 312 | 312 |
CMD echo ${TEST}
|
| ... | ... |
@@ -324,13 +326,13 @@ func (s *DockerSuite) TestBuildOnBuildCmdEntrypointJSON(c *check.C) {
|
| 324 | 324 |
name1 := "onbuildcmd" |
| 325 | 325 |
name2 := "onbuildgenerated" |
| 326 | 326 |
|
| 327 |
- buildImageSuccessfully(c, name1, withDockerfile(` |
|
| 327 |
+ buildImageSuccessfully(c, name1, build.WithDockerfile(` |
|
| 328 | 328 |
FROM busybox |
| 329 | 329 |
ONBUILD CMD ["hello world"] |
| 330 | 330 |
ONBUILD ENTRYPOINT ["echo"] |
| 331 | 331 |
ONBUILD RUN ["true"]`)) |
| 332 | 332 |
|
| 333 |
- buildImageSuccessfully(c, name2, withDockerfile(fmt.Sprintf(`FROM %s`, name1))) |
|
| 333 |
+ buildImageSuccessfully(c, name2, build.WithDockerfile(fmt.Sprintf(`FROM %s`, name1))) |
|
| 334 | 334 |
|
| 335 | 335 |
out, _ := dockerCmd(c, "run", name2) |
| 336 | 336 |
if !regexp.MustCompile(`(?m)^hello world`).MatchString(out) {
|
| ... | ... |
@@ -344,11 +346,11 @@ func (s *DockerSuite) TestBuildOnBuildEntrypointJSON(c *check.C) {
|
| 344 | 344 |
name1 := "onbuildcmd" |
| 345 | 345 |
name2 := "onbuildgenerated" |
| 346 | 346 |
|
| 347 |
- buildImageSuccessfully(c, name1, withDockerfile(` |
|
| 347 |
+ buildImageSuccessfully(c, name1, build.WithDockerfile(` |
|
| 348 | 348 |
FROM busybox |
| 349 | 349 |
ONBUILD ENTRYPOINT ["echo"]`)) |
| 350 | 350 |
|
| 351 |
- buildImageSuccessfully(c, name2, withDockerfile(fmt.Sprintf("FROM %s\nCMD [\"hello world\"]\n", name1)))
|
|
| 351 |
+ buildImageSuccessfully(c, name2, build.WithDockerfile(fmt.Sprintf("FROM %s\nCMD [\"hello world\"]\n", name1)))
|
|
| 352 | 352 |
|
| 353 | 353 |
out, _ := dockerCmd(c, "run", name2) |
| 354 | 354 |
if !regexp.MustCompile(`(?m)^hello world`).MatchString(out) {
|
| ... | ... |
@@ -366,10 +368,10 @@ func (s *DockerSuite) TestBuildCacheAdd(c *check.C) {
|
| 366 | 366 |
}) |
| 367 | 367 |
defer server.Close() |
| 368 | 368 |
|
| 369 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf(`FROM scratch |
|
| 369 |
+ cli.BuildCmd(c, name, build.WithDockerfile(fmt.Sprintf(`FROM scratch |
|
| 370 | 370 |
ADD %s/robots.txt /`, server.URL()))) |
| 371 | 371 |
|
| 372 |
- result := buildImage(name, withDockerfile(fmt.Sprintf(`FROM scratch |
|
| 372 |
+ result := cli.Docker(cli.Build(name), build.WithDockerfile(fmt.Sprintf(`FROM scratch |
|
| 373 | 373 |
ADD %s/index.html /`, server.URL()))) |
| 374 | 374 |
result.Assert(c, icmd.Success) |
| 375 | 375 |
if strings.Contains(result.Combined(), "Using cache") {
|
| ... | ... |
@@ -395,14 +397,14 @@ func (s *DockerSuite) TestBuildLastModified(c *check.C) {
|
| 395 | 395 |
ADD %s/file /` |
| 396 | 396 |
dockerfile := fmt.Sprintf(dFmt, server.URL()) |
| 397 | 397 |
|
| 398 |
- buildImageSuccessfully(c, name, withoutCache, withDockerfile(dockerfile)) |
|
| 398 |
+ buildImageSuccessfully(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
|
| 399 | 399 |
out, _ = dockerCmd(c, "run", name, "ls", "-le", "/file") |
| 400 | 400 |
|
| 401 | 401 |
// Build it again and make sure the mtime of the file didn't change. |
| 402 | 402 |
// Wait a few seconds to make sure the time changed enough to notice |
| 403 | 403 |
time.Sleep(2 * time.Second) |
| 404 | 404 |
|
| 405 |
- buildImageSuccessfully(c, name, withoutCache, withDockerfile(dockerfile)) |
|
| 405 |
+ buildImageSuccessfully(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
|
| 406 | 406 |
out2, _ = dockerCmd(c, "run", name, "ls", "-le", "/file") |
| 407 | 407 |
|
| 408 | 408 |
if out != out2 {
|
| ... | ... |
@@ -417,7 +419,7 @@ ADD %s/file /` |
| 417 | 417 |
defer server.Close() |
| 418 | 418 |
|
| 419 | 419 |
dockerfile = fmt.Sprintf(dFmt, server.URL()) |
| 420 |
- buildImageSuccessfully(c, name, withoutCache, withDockerfile(dockerfile)) |
|
| 420 |
+ buildImageSuccessfully(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
|
| 421 | 421 |
out2, _ = dockerCmd(c, "run", name, "ls", "-le", "/file") |
| 422 | 422 |
|
| 423 | 423 |
if out == out2 {
|
| ... | ... |
@@ -1155,7 +1157,7 @@ func (s *DockerSuite) TestBuildForceRm(c *check.C) {
|
| 1155 | 1155 |
containerCountBefore := getContainerCount(c) |
| 1156 | 1156 |
name := "testbuildforcerm" |
| 1157 | 1157 |
|
| 1158 |
- buildImage(name, withBuildFlags("--force-rm"), withBuildContext(c,
|
|
| 1158 |
+ buildImage(name, cli.WithFlags("--force-rm"), withBuildContext(c,
|
|
| 1159 | 1159 |
withFile("Dockerfile", `FROM `+minimalBaseImage()+`
|
| 1160 | 1160 |
RUN true |
| 1161 | 1161 |
RUN thiswillfail`))).Assert(c, icmd.Expected{
|
| ... | ... |
@@ -1194,7 +1196,7 @@ func (s *DockerSuite) TestBuildRm(c *check.C) {
|
| 1194 | 1194 |
for _, tc := range testCases {
|
| 1195 | 1195 |
containerCountBefore := getContainerCount(c) |
| 1196 | 1196 |
|
| 1197 |
- buildImageSuccessfully(c, name, withBuildFlags(tc.buildflags...), withDockerfile(`FROM busybox |
|
| 1197 |
+ buildImageSuccessfully(c, name, cli.WithFlags(tc.buildflags...), build.WithDockerfile(`FROM busybox |
|
| 1198 | 1198 |
RUN echo hello world`)) |
| 1199 | 1199 |
|
| 1200 | 1200 |
containerCountAfter := getContainerCount(c) |
| ... | ... |
@@ -1230,7 +1232,7 @@ func (s *DockerSuite) TestBuildWithVolumes(c *check.C) {
|
| 1230 | 1230 |
} |
| 1231 | 1231 |
) |
| 1232 | 1232 |
|
| 1233 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM scratch |
|
| 1233 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM scratch |
|
| 1234 | 1234 |
VOLUME /test1 |
| 1235 | 1235 |
VOLUME /test2 |
| 1236 | 1236 |
VOLUME /test3 /test4 |
| ... | ... |
@@ -1250,7 +1252,7 @@ func (s *DockerSuite) TestBuildWithVolumes(c *check.C) {
|
| 1250 | 1250 |
func (s *DockerSuite) TestBuildMaintainer(c *check.C) {
|
| 1251 | 1251 |
name := "testbuildmaintainer" |
| 1252 | 1252 |
|
| 1253 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1253 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1254 | 1254 |
MAINTAINER dockerio`)) |
| 1255 | 1255 |
|
| 1256 | 1256 |
expected := "dockerio" |
| ... | ... |
@@ -1264,7 +1266,7 @@ func (s *DockerSuite) TestBuildUser(c *check.C) {
|
| 1264 | 1264 |
testRequires(c, DaemonIsLinux) |
| 1265 | 1265 |
name := "testbuilduser" |
| 1266 | 1266 |
expected := "dockerio" |
| 1267 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1267 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1268 | 1268 |
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd |
| 1269 | 1269 |
USER dockerio |
| 1270 | 1270 |
RUN [ $(whoami) = 'dockerio' ]`)) |
| ... | ... |
@@ -1299,7 +1301,7 @@ func (s *DockerSuite) TestBuildRelativeWorkdir(c *check.C) {
|
| 1299 | 1299 |
expectedFinal = `/test2/test3` |
| 1300 | 1300 |
} |
| 1301 | 1301 |
|
| 1302 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1302 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1303 | 1303 |
RUN sh -c "[ "$PWD" = "`+expected1+`" ]" |
| 1304 | 1304 |
WORKDIR test1 |
| 1305 | 1305 |
RUN sh -c "[ "$PWD" = "`+expected2+`" ]" |
| ... | ... |
@@ -1318,7 +1320,7 @@ func (s *DockerSuite) TestBuildRelativeWorkdir(c *check.C) {
|
| 1318 | 1318 |
// Windows semantics. Most path handling verifications are in unit tests |
| 1319 | 1319 |
func (s *DockerSuite) TestBuildWindowsWorkdirProcessing(c *check.C) {
|
| 1320 | 1320 |
testRequires(c, DaemonIsWindows) |
| 1321 |
- buildImageSuccessfully(c, "testbuildwindowsworkdirprocessing", withDockerfile(`FROM busybox |
|
| 1321 |
+ buildImageSuccessfully(c, "testbuildwindowsworkdirprocessing", build.WithDockerfile(`FROM busybox |
|
| 1322 | 1322 |
WORKDIR C:\\foo |
| 1323 | 1323 |
WORKDIR bar |
| 1324 | 1324 |
RUN sh -c "[ "$PWD" = "C:/foo/bar" ]" |
| ... | ... |
@@ -1370,7 +1372,7 @@ func (s *DockerSuite) TestBuildWorkdirWithEnvVariables(c *check.C) {
|
| 1370 | 1370 |
expected = `/test1/test2` |
| 1371 | 1371 |
} |
| 1372 | 1372 |
|
| 1373 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1373 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1374 | 1374 |
ENV DIRPATH /test1 |
| 1375 | 1375 |
ENV SUBDIRNAME test2 |
| 1376 | 1376 |
WORKDIR $DIRPATH |
| ... | ... |
@@ -1440,7 +1442,7 @@ func (s *DockerSuite) TestBuildBlankName(c *check.C) {
|
| 1440 | 1440 |
} |
| 1441 | 1441 |
|
| 1442 | 1442 |
for _, tc := range testCases {
|
| 1443 |
- buildImage(name, withDockerfile(fmt.Sprintf(`FROM busybox |
|
| 1443 |
+ buildImage(name, build.WithDockerfile(fmt.Sprintf(`FROM busybox |
|
| 1444 | 1444 |
%s`, tc.expression))).Assert(c, icmd.Expected{
|
| 1445 | 1445 |
ExitCode: 1, |
| 1446 | 1446 |
Err: tc.expectedStderr, |
| ... | ... |
@@ -1452,7 +1454,7 @@ func (s *DockerSuite) TestBuildEnv(c *check.C) {
|
| 1452 | 1452 |
testRequires(c, DaemonIsLinux) // ENV expansion is different in Windows |
| 1453 | 1453 |
name := "testbuildenv" |
| 1454 | 1454 |
expected := "[PATH=/test:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PORT=2375]" |
| 1455 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1455 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1456 | 1456 |
ENV PATH /test:$PATH |
| 1457 | 1457 |
ENV PORT 2375 |
| 1458 | 1458 |
RUN [ $(env | grep PORT) = 'PORT=2375' ]`)) |
| ... | ... |
@@ -1468,7 +1470,7 @@ func (s *DockerSuite) TestBuildPATH(c *check.C) {
|
| 1468 | 1468 |
defPath := "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" |
| 1469 | 1469 |
|
| 1470 | 1470 |
fn := func(dockerfile string, expected string) {
|
| 1471 |
- buildImageSuccessfully(c, "testbldpath", withDockerfile(dockerfile)) |
|
| 1471 |
+ buildImageSuccessfully(c, "testbldpath", build.WithDockerfile(dockerfile)) |
|
| 1472 | 1472 |
res := inspectField(c, "testbldpath", "Config.Env") |
| 1473 | 1473 |
if res != expected {
|
| 1474 | 1474 |
c.Fatalf("Env %q, expected %q for dockerfile:%q", res, expected, dockerfile)
|
| ... | ... |
@@ -1500,7 +1502,7 @@ func (s *DockerSuite) TestBuildContextCleanup(c *check.C) {
|
| 1500 | 1500 |
c.Fatalf("failed to list contents of tmp dir: %s", err)
|
| 1501 | 1501 |
} |
| 1502 | 1502 |
|
| 1503 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1503 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1504 | 1504 |
ENTRYPOINT ["/bin/echo"]`)) |
| 1505 | 1505 |
|
| 1506 | 1506 |
entriesFinal, err := ioutil.ReadDir(filepath.Join(testEnv.DockerBasePath(), "tmp")) |
| ... | ... |
@@ -1522,7 +1524,7 @@ func (s *DockerSuite) TestBuildContextCleanupFailedBuild(c *check.C) {
|
| 1522 | 1522 |
c.Fatalf("failed to list contents of tmp dir: %s", err)
|
| 1523 | 1523 |
} |
| 1524 | 1524 |
|
| 1525 |
- buildImage(name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1525 |
+ buildImage(name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1526 | 1526 |
RUN /non/existing/command`)).Assert(c, icmd.Expected{
|
| 1527 | 1527 |
ExitCode: 1, |
| 1528 | 1528 |
}) |
| ... | ... |
@@ -1541,7 +1543,7 @@ func (s *DockerSuite) TestBuildCmd(c *check.C) {
|
| 1541 | 1541 |
name := "testbuildcmd" |
| 1542 | 1542 |
expected := "[/bin/echo Hello World]" |
| 1543 | 1543 |
|
| 1544 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1544 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1545 | 1545 |
CMD ["/bin/echo", "Hello World"]`)) |
| 1546 | 1546 |
|
| 1547 | 1547 |
res := inspectField(c, name, "Config.Cmd") |
| ... | ... |
@@ -1555,7 +1557,7 @@ func (s *DockerSuite) TestBuildExpose(c *check.C) {
|
| 1555 | 1555 |
name := "testbuildexpose" |
| 1556 | 1556 |
expected := "map[2375/tcp:{}]"
|
| 1557 | 1557 |
|
| 1558 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM scratch |
|
| 1558 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM scratch |
|
| 1559 | 1559 |
EXPOSE 2375`)) |
| 1560 | 1560 |
|
| 1561 | 1561 |
res := inspectField(c, name, "Config.ExposedPorts") |
| ... | ... |
@@ -1591,7 +1593,7 @@ func (s *DockerSuite) TestBuildExposeMorePorts(c *check.C) {
|
| 1591 | 1591 |
tmpl.Execute(buf, portList) |
| 1592 | 1592 |
|
| 1593 | 1593 |
name := "testbuildexpose" |
| 1594 |
- buildImageSuccessfully(c, name, withDockerfile(buf.String())) |
|
| 1594 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(buf.String())) |
|
| 1595 | 1595 |
|
| 1596 | 1596 |
// check if all the ports are saved inside Config.ExposedPorts |
| 1597 | 1597 |
res := inspectFieldJSON(c, name, "Config.ExposedPorts") |
| ... | ... |
@@ -1616,7 +1618,7 @@ func (s *DockerSuite) TestBuildExposeMorePorts(c *check.C) {
|
| 1616 | 1616 |
func (s *DockerSuite) TestBuildExposeOrder(c *check.C) {
|
| 1617 | 1617 |
testRequires(c, DaemonIsLinux) // Expose not implemented on Windows |
| 1618 | 1618 |
buildID := func(name, exposed string) string {
|
| 1619 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf(`FROM scratch |
|
| 1619 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(`FROM scratch |
|
| 1620 | 1620 |
EXPOSE %s`, exposed))) |
| 1621 | 1621 |
id := inspectField(c, name, "Id") |
| 1622 | 1622 |
return id |
| ... | ... |
@@ -1633,7 +1635,7 @@ func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *check.C) {
|
| 1633 | 1633 |
testRequires(c, DaemonIsLinux) // Expose not implemented on Windows |
| 1634 | 1634 |
name := "testbuildexposeuppercaseproto" |
| 1635 | 1635 |
expected := "map[5678/udp:{}]"
|
| 1636 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM scratch |
|
| 1636 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM scratch |
|
| 1637 | 1637 |
EXPOSE 5678/UDP`)) |
| 1638 | 1638 |
res := inspectField(c, name, "Config.ExposedPorts") |
| 1639 | 1639 |
if res != expected {
|
| ... | ... |
@@ -1645,7 +1647,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) {
|
| 1645 | 1645 |
name := "testbuildentrypointinheritance" |
| 1646 | 1646 |
name2 := "testbuildentrypointinheritance2" |
| 1647 | 1647 |
|
| 1648 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1648 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1649 | 1649 |
ENTRYPOINT ["/bin/echo"]`)) |
| 1650 | 1650 |
res := inspectField(c, name, "Config.Entrypoint") |
| 1651 | 1651 |
|
| ... | ... |
@@ -1654,7 +1656,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) {
|
| 1654 | 1654 |
c.Fatalf("Entrypoint %s, expected %s", res, expected)
|
| 1655 | 1655 |
} |
| 1656 | 1656 |
|
| 1657 |
- buildImageSuccessfully(c, name2, withDockerfile(fmt.Sprintf(`FROM %s |
|
| 1657 |
+ buildImageSuccessfully(c, name2, build.WithDockerfile(fmt.Sprintf(`FROM %s |
|
| 1658 | 1658 |
ENTRYPOINT []`, name))) |
| 1659 | 1659 |
res = inspectField(c, name2, "Config.Entrypoint") |
| 1660 | 1660 |
|
| ... | ... |
@@ -1668,7 +1670,7 @@ func (s *DockerSuite) TestBuildEmptyEntrypoint(c *check.C) {
|
| 1668 | 1668 |
name := "testbuildentrypoint" |
| 1669 | 1669 |
expected := "[]" |
| 1670 | 1670 |
|
| 1671 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1671 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1672 | 1672 |
ENTRYPOINT []`)) |
| 1673 | 1673 |
|
| 1674 | 1674 |
res := inspectField(c, name, "Config.Entrypoint") |
| ... | ... |
@@ -1682,7 +1684,7 @@ func (s *DockerSuite) TestBuildEntrypoint(c *check.C) {
|
| 1682 | 1682 |
name := "testbuildentrypoint" |
| 1683 | 1683 |
|
| 1684 | 1684 |
expected := "[/bin/echo]" |
| 1685 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1685 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 1686 | 1686 |
ENTRYPOINT ["/bin/echo"]`)) |
| 1687 | 1687 |
|
| 1688 | 1688 |
res := inspectField(c, name, "Config.Entrypoint") |
| ... | ... |
@@ -1694,17 +1696,17 @@ func (s *DockerSuite) TestBuildEntrypoint(c *check.C) {
|
| 1694 | 1694 |
|
| 1695 | 1695 |
// #6445 ensure ONBUILD triggers aren't committed to grandchildren |
| 1696 | 1696 |
func (s *DockerSuite) TestBuildOnBuildLimitedInheritence(c *check.C) {
|
| 1697 |
- buildImageSuccessfully(c, "testonbuildtrigger1", withDockerfile(` |
|
| 1697 |
+ buildImageSuccessfully(c, "testonbuildtrigger1", build.WithDockerfile(` |
|
| 1698 | 1698 |
FROM busybox |
| 1699 | 1699 |
RUN echo "GRANDPARENT" |
| 1700 | 1700 |
ONBUILD RUN echo "ONBUILD PARENT" |
| 1701 | 1701 |
`)) |
| 1702 | 1702 |
// ONBUILD should be run in second build. |
| 1703 |
- buildImage("testonbuildtrigger2", withDockerfile("FROM testonbuildtrigger1")).Assert(c, icmd.Expected{
|
|
| 1703 |
+ buildImage("testonbuildtrigger2", build.WithDockerfile("FROM testonbuildtrigger1")).Assert(c, icmd.Expected{
|
|
| 1704 | 1704 |
Out: "ONBUILD PARENT", |
| 1705 | 1705 |
}) |
| 1706 | 1706 |
// ONBUILD should *not* be run in third build. |
| 1707 |
- result := buildImage("testonbuildtrigger3", withDockerfile("FROM testonbuildtrigger2"))
|
|
| 1707 |
+ result := buildImage("testonbuildtrigger3", build.WithDockerfile("FROM testonbuildtrigger2"))
|
|
| 1708 | 1708 |
result.Assert(c, icmd.Success) |
| 1709 | 1709 |
if strings.Contains(result.Combined(), "ONBUILD PARENT") {
|
| 1710 | 1710 |
c.Fatalf("ONBUILD instruction ran in grandchild of ONBUILD parent")
|
| ... | ... |
@@ -1718,11 +1720,11 @@ func (s *DockerSuite) TestBuildSameDockerfileWithAndWithoutCache(c *check.C) {
|
| 1718 | 1718 |
MAINTAINER dockerio |
| 1719 | 1719 |
EXPOSE 5432 |
| 1720 | 1720 |
ENTRYPOINT ["/bin/echo"]` |
| 1721 |
- buildImageSuccessfully(c, name, withDockerfile(dockerfile)) |
|
| 1721 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerfile)) |
|
| 1722 | 1722 |
id1 := getIDByName(c, name) |
| 1723 |
- buildImageSuccessfully(c, name, withDockerfile(dockerfile)) |
|
| 1723 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerfile)) |
|
| 1724 | 1724 |
id2 := getIDByName(c, name) |
| 1725 |
- buildImageSuccessfully(c, name, withoutCache, withDockerfile(dockerfile)) |
|
| 1725 |
+ buildImageSuccessfully(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
|
| 1726 | 1726 |
id3 := getIDByName(c, name) |
| 1727 | 1727 |
if id1 != id2 {
|
| 1728 | 1728 |
c.Fatal("The cache should have been used but hasn't.")
|
| ... | ... |
@@ -1781,7 +1783,7 @@ func (s *DockerSuite) TestBuildAddMultipleLocalFileWithAndWithoutCache(c *check. |
| 1781 | 1781 |
id1 := getIDByName(c, name) |
| 1782 | 1782 |
buildImageSuccessfully(c, name, withExternalBuildContext(ctx)) |
| 1783 | 1783 |
id2 := getIDByName(c, name) |
| 1784 |
- buildImageSuccessfully(c, name, withoutCache, withExternalBuildContext(ctx)) |
|
| 1784 |
+ buildImageSuccessfully(c, name, build.WithoutCache, withExternalBuildContext(ctx)) |
|
| 1785 | 1785 |
id3 := getIDByName(c, name) |
| 1786 | 1786 |
if id1 != id2 {
|
| 1787 | 1787 |
c.Fatal("The cache should have been used but hasn't.")
|
| ... | ... |
@@ -1874,7 +1876,7 @@ func (s *DockerSuite) TestBuildAddCurrentDirWithoutCache(c *check.C) {
|
| 1874 | 1874 |
defer ctx.Close() |
| 1875 | 1875 |
buildImageSuccessfully(c, name, withExternalBuildContext(ctx)) |
| 1876 | 1876 |
id1 := getIDByName(c, name) |
| 1877 |
- buildImageSuccessfully(c, name, withoutCache, withExternalBuildContext(ctx)) |
|
| 1877 |
+ buildImageSuccessfully(c, name, build.WithoutCache, withExternalBuildContext(ctx)) |
|
| 1878 | 1878 |
id2 := getIDByName(c, name) |
| 1879 | 1879 |
if id1 == id2 {
|
| 1880 | 1880 |
c.Fatal("The cache should have been invalided but hasn't.")
|
| ... | ... |
@@ -1891,11 +1893,11 @@ func (s *DockerSuite) TestBuildAddRemoteFileWithAndWithoutCache(c *check.C) {
|
| 1891 | 1891 |
dockerfile := fmt.Sprintf(`FROM `+minimalBaseImage()+` |
| 1892 | 1892 |
MAINTAINER dockerio |
| 1893 | 1893 |
ADD %s/baz /usr/lib/baz/quux`, server.URL()) |
| 1894 |
- buildImageSuccessfully(c, name, withDockerfile(dockerfile)) |
|
| 1894 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerfile)) |
|
| 1895 | 1895 |
id1 := getIDByName(c, name) |
| 1896 |
- buildImageSuccessfully(c, name, withDockerfile(dockerfile)) |
|
| 1896 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerfile)) |
|
| 1897 | 1897 |
id2 := getIDByName(c, name) |
| 1898 |
- buildImageSuccessfully(c, name, withoutCache, withDockerfile(dockerfile)) |
|
| 1898 |
+ buildImageSuccessfully(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
|
| 1899 | 1899 |
id3 := getIDByName(c, name) |
| 1900 | 1900 |
|
| 1901 | 1901 |
if id1 != id2 {
|
| ... | ... |
@@ -1968,7 +1970,7 @@ func (s *DockerSuite) TestBuildAddLocalAndRemoteFilesWithAndWithoutCache(c *chec |
| 1968 | 1968 |
id1 := getIDByName(c, name) |
| 1969 | 1969 |
buildImageSuccessfully(c, name, withExternalBuildContext(ctx)) |
| 1970 | 1970 |
id2 := getIDByName(c, name) |
| 1971 |
- buildImageSuccessfully(c, name, withoutCache, withExternalBuildContext(ctx)) |
|
| 1971 |
+ buildImageSuccessfully(c, name, build.WithoutCache, withExternalBuildContext(ctx)) |
|
| 1972 | 1972 |
id3 := getIDByName(c, name) |
| 1973 | 1973 |
if id1 != id2 {
|
| 1974 | 1974 |
c.Fatal("The cache should have been used but hasn't.")
|
| ... | ... |
@@ -2026,7 +2028,7 @@ func (s *DockerSuite) TestBuildWithVolumeOwnership(c *check.C) {
|
| 2026 | 2026 |
testRequires(c, DaemonIsLinux) |
| 2027 | 2027 |
name := "testbuildimg" |
| 2028 | 2028 |
|
| 2029 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox:latest |
|
| 2029 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox:latest |
|
| 2030 | 2030 |
RUN mkdir /test && chown daemon:daemon /test && chmod 0600 /test |
| 2031 | 2031 |
VOLUME /test`)) |
| 2032 | 2032 |
|
| ... | ... |
@@ -2044,7 +2046,7 @@ func (s *DockerSuite) TestBuildWithVolumeOwnership(c *check.C) {
|
| 2044 | 2044 |
// utilizing cache |
| 2045 | 2045 |
func (s *DockerSuite) TestBuildEntrypointRunCleanup(c *check.C) {
|
| 2046 | 2046 |
name := "testbuildcmdcleanup" |
| 2047 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 2047 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 2048 | 2048 |
RUN echo "hello"`)) |
| 2049 | 2049 |
|
| 2050 | 2050 |
buildImageSuccessfully(c, name, withBuildContext(c, |
| ... | ... |
@@ -2082,11 +2084,11 @@ func (s *DockerSuite) TestBuildInheritance(c *check.C) {
|
| 2082 | 2082 |
testRequires(c, DaemonIsLinux) |
| 2083 | 2083 |
name := "testbuildinheritance" |
| 2084 | 2084 |
|
| 2085 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM scratch |
|
| 2085 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM scratch |
|
| 2086 | 2086 |
EXPOSE 2375`)) |
| 2087 | 2087 |
ports1 := inspectField(c, name, "Config.ExposedPorts") |
| 2088 | 2088 |
|
| 2089 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf(`FROM %s |
|
| 2089 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(`FROM %s |
|
| 2090 | 2090 |
ENTRYPOINT ["/bin/echo"]`, name))) |
| 2091 | 2091 |
|
| 2092 | 2092 |
res := inspectField(c, name, "Config.Entrypoint") |
| ... | ... |
@@ -2101,7 +2103,7 @@ func (s *DockerSuite) TestBuildInheritance(c *check.C) {
|
| 2101 | 2101 |
|
| 2102 | 2102 |
func (s *DockerSuite) TestBuildFails(c *check.C) {
|
| 2103 | 2103 |
name := "testbuildfails" |
| 2104 |
- buildImage(name, withDockerfile(`FROM busybox |
|
| 2104 |
+ buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 2105 | 2105 |
RUN sh -c "exit 23"`)).Assert(c, icmd.Expected{
|
| 2106 | 2106 |
ExitCode: 23, |
| 2107 | 2107 |
Err: "returned a non-zero code: 23", |
| ... | ... |
@@ -2110,9 +2112,9 @@ func (s *DockerSuite) TestBuildFails(c *check.C) {
|
| 2110 | 2110 |
|
| 2111 | 2111 |
func (s *DockerSuite) TestBuildOnBuild(c *check.C) {
|
| 2112 | 2112 |
name := "testbuildonbuild" |
| 2113 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 2113 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 2114 | 2114 |
ONBUILD RUN touch foobar`)) |
| 2115 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf(`FROM %s |
|
| 2115 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(`FROM %s |
|
| 2116 | 2116 |
RUN [ -f foobar ]`, name))) |
| 2117 | 2117 |
} |
| 2118 | 2118 |
|
| ... | ... |
@@ -2138,7 +2140,7 @@ func (s *DockerSuite) TestBuildAddToSymlinkDest(c *check.C) {
|
| 2138 | 2138 |
func (s *DockerSuite) TestBuildEscapeWhitespace(c *check.C) {
|
| 2139 | 2139 |
name := "testbuildescapewhitespace" |
| 2140 | 2140 |
|
| 2141 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 2141 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 2142 | 2142 |
# ESCAPE=\ |
| 2143 | 2143 |
FROM busybox |
| 2144 | 2144 |
MAINTAINER "Docker \ |
| ... | ... |
@@ -2157,7 +2159,7 @@ func (s *DockerSuite) TestBuildVerifyIntString(c *check.C) {
|
| 2157 | 2157 |
// Verify that strings that look like ints are still passed as strings |
| 2158 | 2158 |
name := "testbuildstringing" |
| 2159 | 2159 |
|
| 2160 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 2160 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 2161 | 2161 |
FROM busybox |
| 2162 | 2162 |
MAINTAINER 123`)) |
| 2163 | 2163 |
|
| ... | ... |
@@ -2290,12 +2292,12 @@ func (s *DockerSuite) TestBuildDockerignoringRenamedDockerfile(c *check.C) {
|
| 2290 | 2290 |
RUN ls /tmp/Dockerfile |
| 2291 | 2291 |
RUN sh -c "! ls /tmp/MyDockerfile" |
| 2292 | 2292 |
RUN ls /tmp/.dockerignore` |
| 2293 |
- buildImageSuccessfully(c, name, withBuildFlags("-f", "MyDockerfile"), withBuildContext(c,
|
|
| 2293 |
+ buildImageSuccessfully(c, name, cli.WithFlags("-f", "MyDockerfile"), withBuildContext(c,
|
|
| 2294 | 2294 |
withFile("Dockerfile", "Should not use me"),
|
| 2295 | 2295 |
withFile("MyDockerfile", dockerfile),
|
| 2296 | 2296 |
withFile(".dockerignore", "MyDockerfile\n"),
|
| 2297 | 2297 |
)) |
| 2298 |
- buildImageSuccessfully(c, name, withBuildFlags("-f", "MyDockerfile"), withBuildContext(c,
|
|
| 2298 |
+ buildImageSuccessfully(c, name, cli.WithFlags("-f", "MyDockerfile"), withBuildContext(c,
|
|
| 2299 | 2299 |
withFile("Dockerfile", "Should not use me"),
|
| 2300 | 2300 |
withFile("MyDockerfile", dockerfile),
|
| 2301 | 2301 |
withFile(".dockerignore", "./MyDockerfile\n"),
|
| ... | ... |
@@ -2495,7 +2497,7 @@ dir1/dir3/** |
| 2495 | 2495 |
func (s *DockerSuite) TestBuildLineBreak(c *check.C) {
|
| 2496 | 2496 |
testRequires(c, DaemonIsLinux) |
| 2497 | 2497 |
name := "testbuildlinebreak" |
| 2498 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 2498 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 2499 | 2499 |
RUN sh -c 'echo root:testpass \ |
| 2500 | 2500 |
> /tmp/passwd' |
| 2501 | 2501 |
RUN mkdir -p /var/run/sshd |
| ... | ... |
@@ -2506,7 +2508,7 @@ RUN sh -c "[ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]"`)) |
| 2506 | 2506 |
func (s *DockerSuite) TestBuildEOLInLine(c *check.C) {
|
| 2507 | 2507 |
testRequires(c, DaemonIsLinux) |
| 2508 | 2508 |
name := "testbuildeolinline" |
| 2509 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 2509 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 2510 | 2510 |
RUN sh -c 'echo root:testpass > /tmp/passwd' |
| 2511 | 2511 |
RUN echo "foo \n bar"; echo "baz" |
| 2512 | 2512 |
RUN mkdir -p /var/run/sshd |
| ... | ... |
@@ -2517,7 +2519,7 @@ RUN sh -c "[ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]"`)) |
| 2517 | 2517 |
func (s *DockerSuite) TestBuildCommentsShebangs(c *check.C) {
|
| 2518 | 2518 |
testRequires(c, DaemonIsLinux) |
| 2519 | 2519 |
name := "testbuildcomments" |
| 2520 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 2520 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 2521 | 2521 |
# This is an ordinary comment. |
| 2522 | 2522 |
RUN { echo '#!/bin/sh'; echo 'echo hello world'; } > /hello.sh
|
| 2523 | 2523 |
RUN [ ! -x /hello.sh ] |
| ... | ... |
@@ -2531,7 +2533,7 @@ RUN [ "$(/hello.sh)" = "hello world" ]`)) |
| 2531 | 2531 |
func (s *DockerSuite) TestBuildUsersAndGroups(c *check.C) {
|
| 2532 | 2532 |
testRequires(c, DaemonIsLinux) |
| 2533 | 2533 |
name := "testbuildusers" |
| 2534 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 2534 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 2535 | 2535 |
|
| 2536 | 2536 |
# Make sure our defaults work |
| 2537 | 2537 |
RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)" = '0:0/root:root' ] |
| ... | ... |
@@ -2930,7 +2932,7 @@ func (s *DockerSuite) TestBuildFromGit(c *check.C) {
|
| 2930 | 2930 |
}, true) |
| 2931 | 2931 |
defer git.Close() |
| 2932 | 2932 |
|
| 2933 |
- buildImageSuccessfully(c, name, withBuildContextPath(git.RepoURL)) |
|
| 2933 |
+ buildImageSuccessfully(c, name, build.WithContextPath(git.RepoURL)) |
|
| 2934 | 2934 |
|
| 2935 | 2935 |
res := inspectField(c, name, "Author") |
| 2936 | 2936 |
if res != "docker" {
|
| ... | ... |
@@ -2949,7 +2951,7 @@ func (s *DockerSuite) TestBuildFromGitWithContext(c *check.C) {
|
| 2949 | 2949 |
}, true) |
| 2950 | 2950 |
defer git.Close() |
| 2951 | 2951 |
|
| 2952 |
- buildImageSuccessfully(c, name, withBuildContextPath(fmt.Sprintf("%s#master:docker", git.RepoURL)))
|
|
| 2952 |
+ buildImageSuccessfully(c, name, build.WithContextPath(fmt.Sprintf("%s#master:docker", git.RepoURL)))
|
|
| 2953 | 2953 |
|
| 2954 | 2954 |
res := inspectField(c, name, "Author") |
| 2955 | 2955 |
if res != "docker" {
|
| ... | ... |
@@ -2965,7 +2967,7 @@ func (s *DockerSuite) TestBuildFromGitwithF(c *check.C) {
|
| 2965 | 2965 |
}, true) |
| 2966 | 2966 |
defer git.Close() |
| 2967 | 2967 |
|
| 2968 |
- buildImage(name, withBuildFlags("-f", "myApp/myDockerfile"), withBuildContextPath(git.RepoURL)).Assert(c, icmd.Expected{
|
|
| 2968 |
+ buildImage(name, cli.WithFlags("-f", "myApp/myDockerfile"), build.WithContextPath(git.RepoURL)).Assert(c, icmd.Expected{
|
|
| 2969 | 2969 |
Out: "hi from Dockerfile", |
| 2970 | 2970 |
}) |
| 2971 | 2971 |
} |
| ... | ... |
@@ -2997,7 +2999,7 @@ func (s *DockerSuite) TestBuildFromRemoteTarball(c *check.C) {
|
| 2997 | 2997 |
}) |
| 2998 | 2998 |
defer server.Close() |
| 2999 | 2999 |
|
| 3000 |
- buildImageSuccessfully(c, name, withBuildContextPath(server.URL()+"/testT.tar")) |
|
| 3000 |
+ buildImageSuccessfully(c, name, build.WithContextPath(server.URL()+"/testT.tar")) |
|
| 3001 | 3001 |
|
| 3002 | 3002 |
res := inspectField(c, name, "Author") |
| 3003 | 3003 |
if res != "docker" {
|
| ... | ... |
@@ -3008,10 +3010,10 @@ func (s *DockerSuite) TestBuildFromRemoteTarball(c *check.C) {
|
| 3008 | 3008 |
func (s *DockerSuite) TestBuildCleanupCmdOnEntrypoint(c *check.C) {
|
| 3009 | 3009 |
name := "testbuildcmdcleanuponentrypoint" |
| 3010 | 3010 |
|
| 3011 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 3011 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 3012 | 3012 |
CMD ["test"] |
| 3013 | 3013 |
ENTRYPOINT ["echo"]`)) |
| 3014 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf(`FROM %s |
|
| 3014 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(`FROM %s |
|
| 3015 | 3015 |
ENTRYPOINT ["cat"]`, name))) |
| 3016 | 3016 |
|
| 3017 | 3017 |
res := inspectField(c, name, "Config.Cmd") |
| ... | ... |
@@ -3026,7 +3028,7 @@ func (s *DockerSuite) TestBuildCleanupCmdOnEntrypoint(c *check.C) {
|
| 3026 | 3026 |
|
| 3027 | 3027 |
func (s *DockerSuite) TestBuildClearCmd(c *check.C) {
|
| 3028 | 3028 |
name := "testbuildclearcmd" |
| 3029 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 3029 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 3030 | 3030 |
ENTRYPOINT ["/bin/bash"] |
| 3031 | 3031 |
CMD []`)) |
| 3032 | 3032 |
|
| ... | ... |
@@ -3041,7 +3043,7 @@ func (s *DockerSuite) TestBuildEmptyCmd(c *check.C) {
|
| 3041 | 3041 |
testRequires(c, DaemonIsLinux) |
| 3042 | 3042 |
|
| 3043 | 3043 |
name := "testbuildemptycmd" |
| 3044 |
- buildImageSuccessfully(c, name, withDockerfile("FROM "+minimalBaseImage()+"\nMAINTAINER quux\n"))
|
|
| 3044 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM "+minimalBaseImage()+"\nMAINTAINER quux\n"))
|
|
| 3045 | 3045 |
|
| 3046 | 3046 |
res := inspectFieldJSON(c, name, "Config.Cmd") |
| 3047 | 3047 |
if res != "null" {
|
| ... | ... |
@@ -3051,9 +3053,9 @@ func (s *DockerSuite) TestBuildEmptyCmd(c *check.C) {
|
| 3051 | 3051 |
|
| 3052 | 3052 |
func (s *DockerSuite) TestBuildOnBuildOutput(c *check.C) {
|
| 3053 | 3053 |
name := "testbuildonbuildparent" |
| 3054 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nONBUILD RUN echo foo\n"))
|
|
| 3054 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nONBUILD RUN echo foo\n"))
|
|
| 3055 | 3055 |
|
| 3056 |
- buildImage(name, withDockerfile("FROM "+name+"\nMAINTAINER quux\n")).Assert(c, icmd.Expected{
|
|
| 3056 |
+ buildImage(name, build.WithDockerfile("FROM "+name+"\nMAINTAINER quux\n")).Assert(c, icmd.Expected{
|
|
| 3057 | 3057 |
Out: "# Executing 1 build trigger", |
| 3058 | 3058 |
}) |
| 3059 | 3059 |
} |
| ... | ... |
@@ -3061,7 +3063,7 @@ func (s *DockerSuite) TestBuildOnBuildOutput(c *check.C) {
|
| 3061 | 3061 |
// FIXME(vdemeester) should be a unit test |
| 3062 | 3062 |
func (s *DockerSuite) TestBuildInvalidTag(c *check.C) {
|
| 3063 | 3063 |
name := "abcd:" + stringutils.GenerateRandomAlphaOnlyString(200) |
| 3064 |
- buildImage(name, withDockerfile("FROM "+minimalBaseImage()+"\nMAINTAINER quux\n")).Assert(c, icmd.Expected{
|
|
| 3064 |
+ buildImage(name, build.WithDockerfile("FROM "+minimalBaseImage()+"\nMAINTAINER quux\n")).Assert(c, icmd.Expected{
|
|
| 3065 | 3065 |
ExitCode: 125, |
| 3066 | 3066 |
Err: "invalid reference format", |
| 3067 | 3067 |
}) |
| ... | ... |
@@ -3069,7 +3071,7 @@ func (s *DockerSuite) TestBuildInvalidTag(c *check.C) {
|
| 3069 | 3069 |
|
| 3070 | 3070 |
func (s *DockerSuite) TestBuildCmdShDashC(c *check.C) {
|
| 3071 | 3071 |
name := "testbuildcmdshc" |
| 3072 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nCMD echo cmd\n"))
|
|
| 3072 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nCMD echo cmd\n"))
|
|
| 3073 | 3073 |
|
| 3074 | 3074 |
res := inspectFieldJSON(c, name, "Config.Cmd") |
| 3075 | 3075 |
expected := `["/bin/sh","-c","echo cmd"]` |
| ... | ... |
@@ -3088,9 +3090,9 @@ func (s *DockerSuite) TestBuildCmdSpaces(c *check.C) {
|
| 3088 | 3088 |
// look the same |
| 3089 | 3089 |
name := "testbuildcmdspaces" |
| 3090 | 3090 |
|
| 3091 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nCMD [\"echo hi\"]\n"))
|
|
| 3091 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nCMD [\"echo hi\"]\n"))
|
|
| 3092 | 3092 |
id1 := getIDByName(c, name) |
| 3093 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nCMD [\"echo\", \"hi\"]\n"))
|
|
| 3093 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nCMD [\"echo\", \"hi\"]\n"))
|
|
| 3094 | 3094 |
id2 := getIDByName(c, name) |
| 3095 | 3095 |
|
| 3096 | 3096 |
if id1 == id2 {
|
| ... | ... |
@@ -3098,9 +3100,9 @@ func (s *DockerSuite) TestBuildCmdSpaces(c *check.C) {
|
| 3098 | 3098 |
} |
| 3099 | 3099 |
|
| 3100 | 3100 |
// Now do the same with ENTRYPOINT |
| 3101 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nENTRYPOINT [\"echo hi\"]\n"))
|
|
| 3101 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nENTRYPOINT [\"echo hi\"]\n"))
|
|
| 3102 | 3102 |
id1 = getIDByName(c, name) |
| 3103 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nENTRYPOINT [\"echo\", \"hi\"]\n"))
|
|
| 3103 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nENTRYPOINT [\"echo\", \"hi\"]\n"))
|
|
| 3104 | 3104 |
id2 = getIDByName(c, name) |
| 3105 | 3105 |
|
| 3106 | 3106 |
if id1 == id2 {
|
| ... | ... |
@@ -3110,7 +3112,7 @@ func (s *DockerSuite) TestBuildCmdSpaces(c *check.C) {
|
| 3110 | 3110 |
|
| 3111 | 3111 |
func (s *DockerSuite) TestBuildCmdJSONNoShDashC(c *check.C) {
|
| 3112 | 3112 |
name := "testbuildcmdjson" |
| 3113 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nCMD [\"echo\", \"cmd\"]"))
|
|
| 3113 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nCMD [\"echo\", \"cmd\"]"))
|
|
| 3114 | 3114 |
|
| 3115 | 3115 |
res := inspectFieldJSON(c, name, "Config.Cmd") |
| 3116 | 3116 |
expected := `["echo","cmd"]` |
| ... | ... |
@@ -3120,7 +3122,7 @@ func (s *DockerSuite) TestBuildCmdJSONNoShDashC(c *check.C) {
|
| 3120 | 3120 |
} |
| 3121 | 3121 |
|
| 3122 | 3122 |
func (s *DockerSuite) TestBuildEntrypointCanBeOverridenByChild(c *check.C) {
|
| 3123 |
- buildImageSuccessfully(c, "parent", withDockerfile(` |
|
| 3123 |
+ buildImageSuccessfully(c, "parent", build.WithDockerfile(` |
|
| 3124 | 3124 |
FROM busybox |
| 3125 | 3125 |
ENTRYPOINT exit 130 |
| 3126 | 3126 |
`)) |
| ... | ... |
@@ -3129,7 +3131,7 @@ func (s *DockerSuite) TestBuildEntrypointCanBeOverridenByChild(c *check.C) {
|
| 3129 | 3129 |
ExitCode: 130, |
| 3130 | 3130 |
}) |
| 3131 | 3131 |
|
| 3132 |
- buildImageSuccessfully(c, "child", withDockerfile(` |
|
| 3132 |
+ buildImageSuccessfully(c, "child", build.WithDockerfile(` |
|
| 3133 | 3133 |
FROM parent |
| 3134 | 3134 |
ENTRYPOINT exit 5 |
| 3135 | 3135 |
`)) |
| ... | ... |
@@ -3150,8 +3152,8 @@ func (s *DockerSuite) TestBuildEntrypointCanBeOverridenByChildInspect(c *check.C |
| 3150 | 3150 |
expected = `["cmd","/S","/C","echo quux"]` |
| 3151 | 3151 |
} |
| 3152 | 3152 |
|
| 3153 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nENTRYPOINT /foo/bar"))
|
|
| 3154 |
- buildImageSuccessfully(c, name2, withDockerfile(fmt.Sprintf("FROM %s\nENTRYPOINT echo quux", name)))
|
|
| 3153 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nENTRYPOINT /foo/bar"))
|
|
| 3154 |
+ buildImageSuccessfully(c, name2, build.WithDockerfile(fmt.Sprintf("FROM %s\nENTRYPOINT echo quux", name)))
|
|
| 3155 | 3155 |
|
| 3156 | 3156 |
res := inspectFieldJSON(c, name2, "Config.Entrypoint") |
| 3157 | 3157 |
if res != expected {
|
| ... | ... |
@@ -3165,7 +3167,7 @@ func (s *DockerSuite) TestBuildEntrypointCanBeOverridenByChildInspect(c *check.C |
| 3165 | 3165 |
|
| 3166 | 3166 |
func (s *DockerSuite) TestBuildRunShEntrypoint(c *check.C) {
|
| 3167 | 3167 |
name := "testbuildentrypoint" |
| 3168 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3168 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3169 | 3169 |
ENTRYPOINT echo`)) |
| 3170 | 3170 |
dockerCmd(c, "run", "--rm", name) |
| 3171 | 3171 |
} |
| ... | ... |
@@ -3174,7 +3176,7 @@ func (s *DockerSuite) TestBuildExoticShellInterpolation(c *check.C) {
|
| 3174 | 3174 |
testRequires(c, DaemonIsLinux) |
| 3175 | 3175 |
name := "testbuildexoticshellinterpolation" |
| 3176 | 3176 |
|
| 3177 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 3177 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 3178 | 3178 |
FROM busybox |
| 3179 | 3179 |
|
| 3180 | 3180 |
ENV SOME_VAR a.b.c |
| ... | ... |
@@ -3207,7 +3209,7 @@ func (s *DockerSuite) TestBuildVerifySingleQuoteFails(c *check.C) {
|
| 3207 | 3207 |
expectedExitCode = 127 |
| 3208 | 3208 |
} |
| 3209 | 3209 |
|
| 3210 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3210 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3211 | 3211 |
CMD [ '/bin/sh', '-c', 'echo hi' ]`)) |
| 3212 | 3212 |
|
| 3213 | 3213 |
icmd.RunCommand(dockerBinary, "run", "--rm", name).Assert(c, icmd.Expected{
|
| ... | ... |
@@ -3223,7 +3225,7 @@ func (s *DockerSuite) TestBuildVerboseOut(c *check.C) {
|
| 3223 | 3223 |
expected = "\n123\r\n" |
| 3224 | 3224 |
} |
| 3225 | 3225 |
|
| 3226 |
- buildImage(name, withDockerfile(`FROM busybox |
|
| 3226 |
+ buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 3227 | 3227 |
RUN echo 123`)).Assert(c, icmd.Expected{
|
| 3228 | 3228 |
Out: expected, |
| 3229 | 3229 |
}) |
| ... | ... |
@@ -3231,7 +3233,7 @@ RUN echo 123`)).Assert(c, icmd.Expected{
|
| 3231 | 3231 |
|
| 3232 | 3232 |
func (s *DockerSuite) TestBuildWithTabs(c *check.C) {
|
| 3233 | 3233 |
name := "testbuildwithtabs" |
| 3234 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nRUN echo\tone\t\ttwo"))
|
|
| 3234 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nRUN echo\tone\t\ttwo"))
|
|
| 3235 | 3235 |
res := inspectFieldJSON(c, name, "ContainerConfig.Cmd") |
| 3236 | 3236 |
expected1 := `["/bin/sh","-c","echo\tone\t\ttwo"]` |
| 3237 | 3237 |
expected2 := `["/bin/sh","-c","echo\u0009one\u0009\u0009two"]` // syntactically equivalent, and what Go 1.3 generates |
| ... | ... |
@@ -3247,7 +3249,7 @@ func (s *DockerSuite) TestBuildWithTabs(c *check.C) {
|
| 3247 | 3247 |
func (s *DockerSuite) TestBuildLabels(c *check.C) {
|
| 3248 | 3248 |
name := "testbuildlabel" |
| 3249 | 3249 |
expected := `{"License":"GPL","Vendor":"Acme"}`
|
| 3250 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3250 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3251 | 3251 |
LABEL Vendor=Acme |
| 3252 | 3252 |
LABEL License GPL`)) |
| 3253 | 3253 |
res := inspectFieldJSON(c, name, "Config.Labels") |
| ... | ... |
@@ -3259,24 +3261,24 @@ func (s *DockerSuite) TestBuildLabels(c *check.C) {
|
| 3259 | 3259 |
func (s *DockerSuite) TestBuildLabelsCache(c *check.C) {
|
| 3260 | 3260 |
name := "testbuildlabelcache" |
| 3261 | 3261 |
|
| 3262 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3262 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3263 | 3263 |
LABEL Vendor=Acme`)) |
| 3264 | 3264 |
id1 := getIDByName(c, name) |
| 3265 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3265 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3266 | 3266 |
LABEL Vendor=Acme`)) |
| 3267 | 3267 |
id2 := getIDByName(c, name) |
| 3268 | 3268 |
if id1 != id2 {
|
| 3269 | 3269 |
c.Fatalf("Build 2 should have worked & used cache(%s,%s)", id1, id2)
|
| 3270 | 3270 |
} |
| 3271 | 3271 |
|
| 3272 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3272 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3273 | 3273 |
LABEL Vendor=Acme1`)) |
| 3274 | 3274 |
id2 = getIDByName(c, name) |
| 3275 | 3275 |
if id1 == id2 {
|
| 3276 | 3276 |
c.Fatalf("Build 3 should have worked & NOT used cache(%s,%s)", id1, id2)
|
| 3277 | 3277 |
} |
| 3278 | 3278 |
|
| 3279 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3279 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3280 | 3280 |
LABEL Vendor Acme`)) |
| 3281 | 3281 |
id2 = getIDByName(c, name) |
| 3282 | 3282 |
if id1 != id2 {
|
| ... | ... |
@@ -3284,10 +3286,10 @@ func (s *DockerSuite) TestBuildLabelsCache(c *check.C) {
|
| 3284 | 3284 |
} |
| 3285 | 3285 |
|
| 3286 | 3286 |
// Now make sure the cache isn't used by mistake |
| 3287 |
- buildImageSuccessfully(c, name, withoutCache, withDockerfile(`FROM busybox |
|
| 3287 |
+ buildImageSuccessfully(c, name, build.WithoutCache, build.WithDockerfile(`FROM busybox |
|
| 3288 | 3288 |
LABEL f1=b1 f2=b2`)) |
| 3289 | 3289 |
|
| 3290 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3290 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3291 | 3291 |
LABEL f1=b1 f2=b2`)) |
| 3292 | 3292 |
id2 = getIDByName(c, name) |
| 3293 | 3293 |
if id1 == id2 {
|
| ... | ... |
@@ -3300,7 +3302,7 @@ func (s *DockerSuite) TestBuildNotVerboseSuccess(c *check.C) {
|
| 3300 | 3300 |
// This test makes sure that -q works correctly when build is successful: |
| 3301 | 3301 |
// stdout has only the image ID (long image ID) and stderr is empty. |
| 3302 | 3302 |
outRegexp := regexp.MustCompile("^(sha256:|)[a-z0-9]{64}\\n$")
|
| 3303 |
- buildFlags := withBuildFlags("-q")
|
|
| 3303 |
+ buildFlags := cli.WithFlags("-q")
|
|
| 3304 | 3304 |
|
| 3305 | 3305 |
tt := []struct {
|
| 3306 | 3306 |
Name string |
| ... | ... |
@@ -3309,7 +3311,7 @@ func (s *DockerSuite) TestBuildNotVerboseSuccess(c *check.C) {
|
| 3309 | 3309 |
{
|
| 3310 | 3310 |
Name: "quiet_build_stdin_success", |
| 3311 | 3311 |
BuildFunc: func(name string) *icmd.Result {
|
| 3312 |
- return buildImage(name, buildFlags, withDockerfile("FROM busybox"))
|
|
| 3312 |
+ return buildImage(name, buildFlags, build.WithDockerfile("FROM busybox"))
|
|
| 3313 | 3313 |
}, |
| 3314 | 3314 |
}, |
| 3315 | 3315 |
{
|
| ... | ... |
@@ -3327,7 +3329,7 @@ func (s *DockerSuite) TestBuildNotVerboseSuccess(c *check.C) {
|
| 3327 | 3327 |
git := newFakeGit(c, "repo", map[string]string{
|
| 3328 | 3328 |
"Dockerfile": "FROM busybox", |
| 3329 | 3329 |
}, true) |
| 3330 |
- return buildImage(name, buildFlags, withBuildContextPath(git.RepoURL)) |
|
| 3330 |
+ return buildImage(name, buildFlags, build.WithContextPath(git.RepoURL)) |
|
| 3331 | 3331 |
}, |
| 3332 | 3332 |
}, |
| 3333 | 3333 |
} |
| ... | ... |
@@ -3353,11 +3355,11 @@ func (s *DockerSuite) TestBuildNotVerboseFailureWithNonExistImage(c *check.C) {
|
| 3353 | 3353 |
testRequires(c, Network) |
| 3354 | 3354 |
testName := "quiet_build_not_exists_image" |
| 3355 | 3355 |
dockerfile := "FROM busybox11" |
| 3356 |
- quietResult := buildImage(testName, withBuildFlags("-q"), withDockerfile(dockerfile))
|
|
| 3356 |
+ quietResult := buildImage(testName, cli.WithFlags("-q"), build.WithDockerfile(dockerfile))
|
|
| 3357 | 3357 |
quietResult.Assert(c, icmd.Expected{
|
| 3358 | 3358 |
ExitCode: 1, |
| 3359 | 3359 |
}) |
| 3360 |
- result := buildImage(testName, withDockerfile(dockerfile)) |
|
| 3360 |
+ result := buildImage(testName, build.WithDockerfile(dockerfile)) |
|
| 3361 | 3361 |
result.Assert(c, icmd.Expected{
|
| 3362 | 3362 |
ExitCode: 1, |
| 3363 | 3363 |
}) |
| ... | ... |
@@ -3379,11 +3381,11 @@ func (s *DockerSuite) TestBuildNotVerboseFailure(c *check.C) {
|
| 3379 | 3379 |
} |
| 3380 | 3380 |
|
| 3381 | 3381 |
for _, tc := range testCases {
|
| 3382 |
- quietResult := buildImage(tc.testName, withBuildFlags("-q"), withDockerfile(tc.dockerfile))
|
|
| 3382 |
+ quietResult := buildImage(tc.testName, cli.WithFlags("-q"), build.WithDockerfile(tc.dockerfile))
|
|
| 3383 | 3383 |
quietResult.Assert(c, icmd.Expected{
|
| 3384 | 3384 |
ExitCode: 1, |
| 3385 | 3385 |
}) |
| 3386 |
- result := buildImage(tc.testName, withDockerfile(tc.dockerfile)) |
|
| 3386 |
+ result := buildImage(tc.testName, build.WithDockerfile(tc.dockerfile)) |
|
| 3387 | 3387 |
result.Assert(c, icmd.Expected{
|
| 3388 | 3388 |
ExitCode: 1, |
| 3389 | 3389 |
}) |
| ... | ... |
@@ -3399,11 +3401,11 @@ func (s *DockerSuite) TestBuildNotVerboseFailureRemote(c *check.C) {
|
| 3399 | 3399 |
// TODO(vdemeester) with cobra, stdout has a carriage return too much so this test should not check stdout |
| 3400 | 3400 |
URL := "http://something.invalid" |
| 3401 | 3401 |
name := "quiet_build_wrong_remote" |
| 3402 |
- quietResult := buildImage(name, withBuildFlags("-q"), withBuildContextPath(URL))
|
|
| 3402 |
+ quietResult := buildImage(name, cli.WithFlags("-q"), build.WithContextPath(URL))
|
|
| 3403 | 3403 |
quietResult.Assert(c, icmd.Expected{
|
| 3404 | 3404 |
ExitCode: 1, |
| 3405 | 3405 |
}) |
| 3406 |
- result := buildImage(name, withBuildContextPath(URL)) |
|
| 3406 |
+ result := buildImage(name, build.WithContextPath(URL)) |
|
| 3407 | 3407 |
result.Assert(c, icmd.Expected{
|
| 3408 | 3408 |
ExitCode: 1, |
| 3409 | 3409 |
}) |
| ... | ... |
@@ -3416,7 +3418,7 @@ func (s *DockerSuite) TestBuildStderr(c *check.C) {
|
| 3416 | 3416 |
// This test just makes sure that no non-error output goes |
| 3417 | 3417 |
// to stderr |
| 3418 | 3418 |
name := "testbuildstderr" |
| 3419 |
- result := buildImage(name, withDockerfile("FROM busybox\nRUN echo one"))
|
|
| 3419 |
+ result := buildImage(name, build.WithDockerfile("FROM busybox\nRUN echo one"))
|
|
| 3420 | 3420 |
result.Assert(c, icmd.Success) |
| 3421 | 3421 |
|
| 3422 | 3422 |
// Windows to non-Windows should have a security warning |
| ... | ... |
@@ -3494,7 +3496,7 @@ func (s *DockerSuite) TestBuildSymlinkBreakout(c *check.C) {
|
| 3494 | 3494 |
w.Close() |
| 3495 | 3495 |
f.Close() |
| 3496 | 3496 |
|
| 3497 |
- buildImageSuccessfully(c, name, withoutCache, withExternalBuildContext(fakeContextFromDir(ctx))) |
|
| 3497 |
+ buildImageSuccessfully(c, name, build.WithoutCache, withExternalBuildContext(fakeContextFromDir(ctx))) |
|
| 3498 | 3498 |
if _, err := os.Lstat(filepath.Join(tmpdir, "inject")); err == nil {
|
| 3499 | 3499 |
c.Fatal("symlink breakout - inject")
|
| 3500 | 3500 |
} else if !os.IsNotExist(err) {
|
| ... | ... |
@@ -3515,9 +3517,7 @@ ADD xz /usr/local/sbin/ |
| 3515 | 3515 |
RUN chmod 755 /usr/local/sbin/xz |
| 3516 | 3516 |
ADD test.xz / |
| 3517 | 3517 |
RUN [ ! -e /injected ]`), |
| 3518 |
- withFile("test.xz", "\xfd\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x02\x00"+
|
|
| 3519 |
- "\x21\x01\x16\x00\x00\x00\x74\x2f\xe5\xa3\x01\x00\x3f\xfd"+ |
|
| 3520 |
- "\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x02\x00\x21"), |
|
| 3518 |
+ withFile("test.xz", "\xfd\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x02\x00"+"\x21\x01\x16\x00\x00\x00\x74\x2f\xe5\xa3\x01\x00\x3f\xfd"+"\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x02\x00\x21"),
|
|
| 3521 | 3519 |
withFile("xz", "#!/bin/sh\ntouch /injected"),
|
| 3522 | 3520 |
)) |
| 3523 | 3521 |
} |
| ... | ... |
@@ -3690,7 +3690,7 @@ RUN echo from Dockerfile`, |
| 3690 | 3690 |
|
| 3691 | 3691 |
// Make sure that -f is ignored and that we don't use the Dockerfile |
| 3692 | 3692 |
// that's in the current dir |
| 3693 |
- result := buildImage("test1", withBuildFlags("-f", "baz", server.URL()+"/baz"), func(cmd *icmd.Cmd) func() {
|
|
| 3693 |
+ result := buildImage("test1", cli.WithFlags("-f", "baz", server.URL()+"/baz"), func(cmd *icmd.Cmd) func() {
|
|
| 3694 | 3694 |
cmd.Dir = ctx.Dir |
| 3695 | 3695 |
return nil |
| 3696 | 3696 |
}) |
| ... | ... |
@@ -3713,7 +3713,7 @@ RUN echo "from Dockerfile"`, |
| 3713 | 3713 |
|
| 3714 | 3714 |
// Make sure that -f is ignored and that we don't use the Dockerfile |
| 3715 | 3715 |
// that's in the current dir |
| 3716 |
- result := buildImage("test1", withBuildFlags("-f", "baz", "-"), func(cmd *icmd.Cmd) func() {
|
|
| 3716 |
+ result := buildImage("test1", cli.WithFlags("-f", "baz", "-"), func(cmd *icmd.Cmd) func() {
|
|
| 3717 | 3717 |
cmd.Dir = ctx.Dir |
| 3718 | 3718 |
cmd.Stdin = strings.NewReader(`FROM busybox |
| 3719 | 3719 |
RUN echo "from baz" |
| ... | ... |
@@ -3743,7 +3743,7 @@ func (s *DockerSuite) TestBuildFromOfficialNames(c *check.C) {
|
| 3743 | 3743 |
} |
| 3744 | 3744 |
for idx, fromName := range fromNames {
|
| 3745 | 3745 |
imgName := fmt.Sprintf("%s%d", name, idx)
|
| 3746 |
- buildImageSuccessfully(c, imgName, withDockerfile("FROM "+fromName))
|
|
| 3746 |
+ buildImageSuccessfully(c, imgName, build.WithDockerfile("FROM "+fromName))
|
|
| 3747 | 3747 |
dockerCmd(c, "rmi", imgName) |
| 3748 | 3748 |
} |
| 3749 | 3749 |
} |
| ... | ... |
@@ -3839,7 +3839,7 @@ func (s *DockerSuite) TestBuildSpaces(c *check.C) {
|
| 3839 | 3839 |
} |
| 3840 | 3840 |
|
| 3841 | 3841 |
ctx.Add("Dockerfile", "FROM busybox\n COPY")
|
| 3842 |
- result2 = buildImage(name, withoutCache, withExternalBuildContext(ctx)) |
|
| 3842 |
+ result2 = buildImage(name, build.WithoutCache, withExternalBuildContext(ctx)) |
|
| 3843 | 3843 |
result2.Assert(c, icmd.Expected{
|
| 3844 | 3844 |
ExitCode: 1, |
| 3845 | 3845 |
}) |
| ... | ... |
@@ -3854,7 +3854,7 @@ func (s *DockerSuite) TestBuildSpaces(c *check.C) {
|
| 3854 | 3854 |
} |
| 3855 | 3855 |
|
| 3856 | 3856 |
ctx.Add("Dockerfile", "FROM busybox\n COPY ")
|
| 3857 |
- result2 = buildImage(name, withoutCache, withExternalBuildContext(ctx)) |
|
| 3857 |
+ result2 = buildImage(name, build.WithoutCache, withExternalBuildContext(ctx)) |
|
| 3858 | 3858 |
result2.Assert(c, icmd.Expected{
|
| 3859 | 3859 |
ExitCode: 1, |
| 3860 | 3860 |
}) |
| ... | ... |
@@ -3884,7 +3884,7 @@ RUN echo " \ |
| 3884 | 3884 |
expected = "\" foo \"" |
| 3885 | 3885 |
} |
| 3886 | 3886 |
|
| 3887 |
- buildImage(name, withDockerfile(dockerfile)).Assert(c, icmd.Expected{
|
|
| 3887 |
+ buildImage(name, build.WithDockerfile(dockerfile)).Assert(c, icmd.Expected{
|
|
| 3888 | 3888 |
Out: expected, |
| 3889 | 3889 |
}) |
| 3890 | 3890 |
} |
| ... | ... |
@@ -3892,7 +3892,7 @@ RUN echo " \ |
| 3892 | 3892 |
// #4393 |
| 3893 | 3893 |
func (s *DockerSuite) TestBuildVolumeFileExistsinContainer(c *check.C) {
|
| 3894 | 3894 |
testRequires(c, DaemonIsLinux) // TODO Windows: This should error out |
| 3895 |
- buildImage("docker-test-errcreatevolumewithfile", withDockerfile(`
|
|
| 3895 |
+ buildImage("docker-test-errcreatevolumewithfile", build.WithDockerfile(`
|
|
| 3896 | 3896 |
FROM busybox |
| 3897 | 3897 |
RUN touch /foo |
| 3898 | 3898 |
VOLUME /foo |
| ... | ... |
@@ -3940,7 +3940,7 @@ func (s *DockerSuite) TestBuildMissingArgs(c *check.C) {
|
| 3940 | 3940 |
dockerfile = "FROM busybox\n" + cmd |
| 3941 | 3941 |
} |
| 3942 | 3942 |
|
| 3943 |
- buildImage("args", withDockerfile(dockerfile)).Assert(c, icmd.Expected{
|
|
| 3943 |
+ buildImage("args", build.WithDockerfile(dockerfile)).Assert(c, icmd.Expected{
|
|
| 3944 | 3944 |
ExitCode: 1, |
| 3945 | 3945 |
Err: cmd + " requires", |
| 3946 | 3946 |
}) |
| ... | ... |
@@ -3950,7 +3950,7 @@ func (s *DockerSuite) TestBuildMissingArgs(c *check.C) {
|
| 3950 | 3950 |
|
| 3951 | 3951 |
func (s *DockerSuite) TestBuildEmptyScratch(c *check.C) {
|
| 3952 | 3952 |
testRequires(c, DaemonIsLinux) |
| 3953 |
- buildImage("sc", withDockerfile("FROM scratch")).Assert(c, icmd.Expected{
|
|
| 3953 |
+ buildImage("sc", build.WithDockerfile("FROM scratch")).Assert(c, icmd.Expected{
|
|
| 3954 | 3954 |
ExitCode: 1, |
| 3955 | 3955 |
Err: "No image was generated", |
| 3956 | 3956 |
}) |
| ... | ... |
@@ -3967,7 +3967,7 @@ func (s *DockerSuite) TestBuildRUNoneJSON(c *check.C) {
|
| 3967 | 3967 |
testRequires(c, DaemonIsLinux) // No hello-world Windows image |
| 3968 | 3968 |
name := "testbuildrunonejson" |
| 3969 | 3969 |
|
| 3970 |
- buildImage(name, withDockerfile(`FROM hello-world:frozen |
|
| 3970 |
+ buildImage(name, build.WithDockerfile(`FROM hello-world:frozen |
|
| 3971 | 3971 |
RUN [ "/hello" ]`)).Assert(c, icmd.Expected{
|
| 3972 | 3972 |
Out: "Hello from Docker", |
| 3973 | 3973 |
}) |
| ... | ... |
@@ -3976,7 +3976,7 @@ RUN [ "/hello" ]`)).Assert(c, icmd.Expected{
|
| 3976 | 3976 |
func (s *DockerSuite) TestBuildEmptyStringVolume(c *check.C) {
|
| 3977 | 3977 |
name := "testbuildemptystringvolume" |
| 3978 | 3978 |
|
| 3979 |
- buildImage(name, withDockerfile(` |
|
| 3979 |
+ buildImage(name, build.WithDockerfile(` |
|
| 3980 | 3980 |
FROM busybox |
| 3981 | 3981 |
ENV foo="" |
| 3982 | 3982 |
VOLUME $foo |
| ... | ... |
@@ -3999,8 +3999,8 @@ func (s *DockerSuite) TestBuildContainerWithCgroupParent(c *check.C) {
|
| 3999 | 3999 |
c.Fatalf("unable to find self memory cgroup path. CgroupsPath: %v", selfCgroupPaths)
|
| 4000 | 4000 |
} |
| 4001 | 4001 |
result := buildImage("buildcgroupparent",
|
| 4002 |
- withBuildFlags("--cgroup-parent", cgroupParent),
|
|
| 4003 |
- withDockerfile(` |
|
| 4002 |
+ cli.WithFlags("--cgroup-parent", cgroupParent),
|
|
| 4003 |
+ build.WithDockerfile(` |
|
| 4004 | 4004 |
FROM busybox |
| 4005 | 4005 |
RUN cat /proc/self/cgroup |
| 4006 | 4006 |
`)) |
| ... | ... |
@@ -4018,7 +4018,7 @@ func (s *DockerSuite) TestBuildNoDupOutput(c *check.C) {
|
| 4018 | 4018 |
// property - there was a bug that caused it to be duplicated on the |
| 4019 | 4019 |
// Step X line |
| 4020 | 4020 |
name := "testbuildnodupoutput" |
| 4021 |
- result := buildImage(name, withDockerfile(` |
|
| 4021 |
+ result := buildImage(name, build.WithDockerfile(` |
|
| 4022 | 4022 |
FROM busybox |
| 4023 | 4023 |
RUN env`)) |
| 4024 | 4024 |
result.Assert(c, icmd.Success) |
| ... | ... |
@@ -4033,7 +4033,7 @@ func (s *DockerSuite) TestBuildNoDupOutput(c *check.C) {
|
| 4033 | 4033 |
func (s *DockerSuite) TestBuildStartsFromOne(c *check.C) {
|
| 4034 | 4034 |
// Explicit check to ensure that build starts from step 1 rather than 0 |
| 4035 | 4035 |
name := "testbuildstartsfromone" |
| 4036 |
- result := buildImage(name, withDockerfile(`FROM busybox`)) |
|
| 4036 |
+ result := buildImage(name, build.WithDockerfile(`FROM busybox`)) |
|
| 4037 | 4037 |
result.Assert(c, icmd.Success) |
| 4038 | 4038 |
exp := "\nStep 1/1 : FROM busybox\n" |
| 4039 | 4039 |
if !strings.Contains(result.Combined(), exp) {
|
| ... | ... |
@@ -4054,7 +4054,7 @@ func (s *DockerSuite) TestBuildRUNErrMsg(c *check.C) {
|
| 4054 | 4054 |
} |
| 4055 | 4055 |
exp := fmt.Sprintf(`The command '%s badEXE a1 \& a2 a3' returned a non-zero code: %d`, shell, exitCode) |
| 4056 | 4056 |
|
| 4057 |
- buildImage(name, withDockerfile(` |
|
| 4057 |
+ buildImage(name, build.WithDockerfile(` |
|
| 4058 | 4058 |
FROM busybox |
| 4059 | 4059 |
RUN badEXE a1 \& a2 a3`)).Assert(c, icmd.Expected{
|
| 4060 | 4060 |
ExitCode: exitCode, |
| ... | ... |
@@ -4071,7 +4071,7 @@ func (s *DockerTrustSuite) TestTrustedBuild(c *check.C) {
|
| 4071 | 4071 |
|
| 4072 | 4072 |
name := "testtrustedbuild" |
| 4073 | 4073 |
|
| 4074 |
- buildImage(name, trustedBuild, withDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4074 |
+ buildImage(name, trustedBuild, build.WithDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4075 | 4075 |
Out: fmt.Sprintf("FROM %s@sha", repoName[:len(repoName)-7]),
|
| 4076 | 4076 |
}) |
| 4077 | 4077 |
|
| ... | ... |
@@ -4091,7 +4091,7 @@ func (s *DockerTrustSuite) TestTrustedBuildUntrustedTag(c *check.C) {
|
| 4091 | 4091 |
|
| 4092 | 4092 |
name := "testtrustedbuilduntrustedtag" |
| 4093 | 4093 |
|
| 4094 |
- buildImage(name, trustedBuild, withDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4094 |
+ buildImage(name, trustedBuild, build.WithDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4095 | 4095 |
ExitCode: 1, |
| 4096 | 4096 |
Err: "does not have trust data for", |
| 4097 | 4097 |
}) |
| ... | ... |
@@ -4159,7 +4159,7 @@ func (s *DockerTrustSuite) TestTrustedBuildTagFromReleasesRole(c *check.C) {
|
| 4159 | 4159 |
RUN [] |
| 4160 | 4160 |
`, otherTag) |
| 4161 | 4161 |
name := "testtrustedbuildreleasesrole" |
| 4162 |
- buildImage(name, trustedBuild, withDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4162 |
+ buildImage(name, trustedBuild, build.WithDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4163 | 4163 |
Out: fmt.Sprintf("FROM %s@sha", repoName),
|
| 4164 | 4164 |
}) |
| 4165 | 4165 |
} |
| ... | ... |
@@ -4192,7 +4192,7 @@ func (s *DockerTrustSuite) TestTrustedBuildTagIgnoresOtherDelegationRoles(c *che |
| 4192 | 4192 |
`, otherTag) |
| 4193 | 4193 |
|
| 4194 | 4194 |
name := "testtrustedbuildotherrole" |
| 4195 |
- buildImage(name, trustedBuild, withDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4195 |
+ buildImage(name, trustedBuild, build.WithDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4196 | 4196 |
ExitCode: 1, |
| 4197 | 4197 |
}) |
| 4198 | 4198 |
} |
| ... | ... |
@@ -4221,7 +4221,7 @@ func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) {
|
| 4221 | 4221 |
func (s *DockerSuite) TestBuildStopSignal(c *check.C) {
|
| 4222 | 4222 |
testRequires(c, DaemonIsLinux) // Windows does not support STOPSIGNAL yet |
| 4223 | 4223 |
imgName := "test_build_stop_signal" |
| 4224 |
- buildImageSuccessfully(c, imgName, withDockerfile(`FROM busybox |
|
| 4224 |
+ buildImageSuccessfully(c, imgName, build.WithDockerfile(`FROM busybox |
|
| 4225 | 4225 |
STOPSIGNAL SIGKILL`)) |
| 4226 | 4226 |
res := inspectFieldJSON(c, imgName, "Config.StopSignal") |
| 4227 | 4227 |
if res != `"SIGKILL"` {
|
| ... | ... |
@@ -4255,8 +4255,8 @@ func (s *DockerSuite) TestBuildBuildTimeArg(c *check.C) {
|
| 4255 | 4255 |
|
| 4256 | 4256 |
} |
| 4257 | 4257 |
buildImage(imgName, |
| 4258 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4259 |
- withDockerfile(dockerfile), |
|
| 4258 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4259 |
+ build.WithDockerfile(dockerfile), |
|
| 4260 | 4260 |
).Assert(c, icmd.Expected{
|
| 4261 | 4261 |
Out: envVal, |
| 4262 | 4262 |
}) |
| ... | ... |
@@ -4277,8 +4277,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgHistory(c *check.C) {
|
| 4277 | 4277 |
dockerfile := fmt.Sprintf(`FROM busybox |
| 4278 | 4278 |
ARG %s=%s`, envKey, envDef) |
| 4279 | 4279 |
buildImage(imgName, |
| 4280 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4281 |
- withDockerfile(dockerfile), |
|
| 4280 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4281 |
+ build.WithDockerfile(dockerfile), |
|
| 4282 | 4282 |
).Assert(c, icmd.Expected{
|
| 4283 | 4283 |
Out: envVal, |
| 4284 | 4284 |
}) |
| ... | ... |
@@ -4302,10 +4302,10 @@ func (s *DockerSuite) TestBuildTimeArgHistoryExclusions(c *check.C) {
|
| 4302 | 4302 |
ARG %s |
| 4303 | 4303 |
RUN echo "Testing Build Args!"`, envKey, explicitProxyKey) |
| 4304 | 4304 |
buildImage(imgName, |
| 4305 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal),
|
|
| 4305 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal),
|
|
| 4306 | 4306 |
"--build-arg", fmt.Sprintf("%s=%s", explicitProxyKey, explicitProxyVal),
|
| 4307 | 4307 |
"--build-arg", proxy), |
| 4308 |
- withDockerfile(dockerfile), |
|
| 4308 |
+ build.WithDockerfile(dockerfile), |
|
| 4309 | 4309 |
).Assert(c, icmd.Success) |
| 4310 | 4310 |
|
| 4311 | 4311 |
out, _ := dockerCmd(c, "history", "--no-trunc", imgName) |
| ... | ... |
@@ -4328,15 +4328,15 @@ func (s *DockerSuite) TestBuildBuildTimeArgCacheHit(c *check.C) {
|
| 4328 | 4328 |
ARG %s |
| 4329 | 4329 |
RUN echo $%s`, envKey, envKey) |
| 4330 | 4330 |
buildImageSuccessfully(c, imgName, |
| 4331 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4332 |
- withDockerfile(dockerfile), |
|
| 4331 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4332 |
+ build.WithDockerfile(dockerfile), |
|
| 4333 | 4333 |
) |
| 4334 | 4334 |
origImgID := getIDByName(c, imgName) |
| 4335 | 4335 |
|
| 4336 | 4336 |
imgNameCache := "bldargtestcachehit" |
| 4337 | 4337 |
buildImageSuccessfully(c, imgNameCache, |
| 4338 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4339 |
- withDockerfile(dockerfile), |
|
| 4338 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4339 |
+ build.WithDockerfile(dockerfile), |
|
| 4340 | 4340 |
) |
| 4341 | 4341 |
newImgID := getIDByName(c, imgName) |
| 4342 | 4342 |
if newImgID != origImgID {
|
| ... | ... |
@@ -4355,18 +4355,18 @@ func (s *DockerSuite) TestBuildBuildTimeArgCacheMissExtraArg(c *check.C) {
|
| 4355 | 4355 |
ARG %s |
| 4356 | 4356 |
RUN echo $%s`, envKey, extraEnvKey, envKey) |
| 4357 | 4357 |
buildImageSuccessfully(c, imgName, |
| 4358 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4359 |
- withDockerfile(dockerfile), |
|
| 4358 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4359 |
+ build.WithDockerfile(dockerfile), |
|
| 4360 | 4360 |
) |
| 4361 | 4361 |
origImgID := getIDByName(c, imgName) |
| 4362 | 4362 |
|
| 4363 | 4363 |
imgNameCache := "bldargtestcachemiss" |
| 4364 | 4364 |
buildImageSuccessfully(c, imgNameCache, |
| 4365 |
- withBuildFlags( |
|
| 4365 |
+ cli.WithFlags( |
|
| 4366 | 4366 |
"--build-arg", fmt.Sprintf("%s=%s", envKey, envVal),
|
| 4367 | 4367 |
"--build-arg", fmt.Sprintf("%s=%s", extraEnvKey, extraEnvVal),
|
| 4368 | 4368 |
), |
| 4369 |
- withDockerfile(dockerfile), |
|
| 4369 |
+ build.WithDockerfile(dockerfile), |
|
| 4370 | 4370 |
) |
| 4371 | 4371 |
newImgID := getIDByName(c, imgNameCache) |
| 4372 | 4372 |
|
| ... | ... |
@@ -4384,15 +4384,15 @@ func (s *DockerSuite) TestBuildBuildTimeArgCacheMissSameArgDiffVal(c *check.C) {
|
| 4384 | 4384 |
ARG %s |
| 4385 | 4385 |
RUN echo $%s`, envKey, envKey) |
| 4386 | 4386 |
buildImageSuccessfully(c, imgName, |
| 4387 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4388 |
- withDockerfile(dockerfile), |
|
| 4387 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4388 |
+ build.WithDockerfile(dockerfile), |
|
| 4389 | 4389 |
) |
| 4390 | 4390 |
origImgID := getIDByName(c, imgName) |
| 4391 | 4391 |
|
| 4392 | 4392 |
imgNameCache := "bldargtestcachemiss" |
| 4393 | 4393 |
buildImageSuccessfully(c, imgNameCache, |
| 4394 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, newEnvVal)),
|
|
| 4395 |
- withDockerfile(dockerfile), |
|
| 4394 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, newEnvVal)),
|
|
| 4395 |
+ build.WithDockerfile(dockerfile), |
|
| 4396 | 4396 |
) |
| 4397 | 4397 |
newImgID := getIDByName(c, imgNameCache) |
| 4398 | 4398 |
if newImgID == origImgID {
|
| ... | ... |
@@ -4414,8 +4414,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgOverrideArgDefinedBeforeEnv(c *check. |
| 4414 | 4414 |
`, envKey, envKey, envValOveride, envKey, envKey) |
| 4415 | 4415 |
|
| 4416 | 4416 |
result := buildImage(imgName, |
| 4417 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4418 |
- withDockerfile(dockerfile), |
|
| 4417 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4418 |
+ build.WithDockerfile(dockerfile), |
|
| 4419 | 4419 |
) |
| 4420 | 4420 |
result.Assert(c, icmd.Success) |
| 4421 | 4421 |
if strings.Count(result.Combined(), envValOveride) != 2 {
|
| ... | ... |
@@ -4442,8 +4442,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgOverrideEnvDefinedBeforeArg(c *check. |
| 4442 | 4442 |
CMD echo $%s |
| 4443 | 4443 |
`, envKey, envValOveride, envKey, envKey, envKey) |
| 4444 | 4444 |
result := buildImage(imgName, |
| 4445 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4446 |
- withDockerfile(dockerfile), |
|
| 4445 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4446 |
+ build.WithDockerfile(dockerfile), |
|
| 4447 | 4447 |
) |
| 4448 | 4448 |
result.Assert(c, icmd.Success) |
| 4449 | 4449 |
if strings.Count(result.Combined(), envValOveride) != 2 {
|
| ... | ... |
@@ -4476,7 +4476,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *check.C) {
|
| 4476 | 4476 |
volVal := "/testVol/" |
| 4477 | 4477 |
|
| 4478 | 4478 |
buildImageSuccessfully(c, imgName, |
| 4479 |
- withBuildFlags( |
|
| 4479 |
+ cli.WithFlags( |
|
| 4480 | 4480 |
"--build-arg", fmt.Sprintf("%s=%s", wdVar, wdVal),
|
| 4481 | 4481 |
"--build-arg", fmt.Sprintf("%s=%s", addVar, addVal),
|
| 4482 | 4482 |
"--build-arg", fmt.Sprintf("%s=%s", copyVar, copyVal),
|
| ... | ... |
@@ -4559,8 +4559,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansionOverride(c *check.C) {
|
| 4559 | 4559 |
RUN echo $%s |
| 4560 | 4560 |
CMD echo $%s`, envKey, envKey, envValOveride, envKey1, envKey, envKey1, envKey1) |
| 4561 | 4561 |
result := buildImage(imgName, |
| 4562 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4563 |
- withDockerfile(dockerfile), |
|
| 4562 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4563 |
+ build.WithDockerfile(dockerfile), |
|
| 4564 | 4564 |
) |
| 4565 | 4565 |
result.Assert(c, icmd.Success) |
| 4566 | 4566 |
if strings.Count(result.Combined(), envValOveride) != 2 {
|
| ... | ... |
@@ -4583,8 +4583,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgUntrustedDefinedAfterUse(c *check.C) |
| 4583 | 4583 |
ARG %s |
| 4584 | 4584 |
CMD echo $%s`, envKey, envKey, envKey) |
| 4585 | 4585 |
result := buildImage(imgName, |
| 4586 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4587 |
- withDockerfile(dockerfile), |
|
| 4586 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4587 |
+ build.WithDockerfile(dockerfile), |
|
| 4588 | 4588 |
) |
| 4589 | 4589 |
result.Assert(c, icmd.Success) |
| 4590 | 4590 |
if strings.Contains(result.Combined(), envVal) {
|
| ... | ... |
@@ -4607,8 +4607,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgBuiltinArg(c *check.C) {
|
| 4607 | 4607 |
CMD echo $%s`, envKey, envKey) |
| 4608 | 4608 |
|
| 4609 | 4609 |
result := buildImage(imgName, |
| 4610 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4611 |
- withDockerfile(dockerfile), |
|
| 4610 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4611 |
+ build.WithDockerfile(dockerfile), |
|
| 4612 | 4612 |
) |
| 4613 | 4613 |
result.Assert(c, icmd.Success) |
| 4614 | 4614 |
if !strings.Contains(result.Combined(), envVal) {
|
| ... | ... |
@@ -4632,8 +4632,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgDefaultOverride(c *check.C) {
|
| 4632 | 4632 |
RUN echo $%s |
| 4633 | 4633 |
CMD echo $%s`, envKey, envVal, envKey, envKey, envKey, envKey) |
| 4634 | 4634 |
result := buildImage(imgName, |
| 4635 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envValOveride)),
|
|
| 4636 |
- withDockerfile(dockerfile), |
|
| 4635 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envValOveride)),
|
|
| 4636 |
+ build.WithDockerfile(dockerfile), |
|
| 4637 | 4637 |
) |
| 4638 | 4638 |
result.Assert(c, icmd.Success) |
| 4639 | 4639 |
if strings.Count(result.Combined(), envValOveride) != 1 {
|
| ... | ... |
@@ -4655,8 +4655,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgUnconsumedArg(c *check.C) {
|
| 4655 | 4655 |
CMD echo $%s`, envKey, envKey) |
| 4656 | 4656 |
warnStr := "[Warning] One or more build-args" |
| 4657 | 4657 |
buildImage(imgName, |
| 4658 |
- withBuildFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4659 |
- withDockerfile(dockerfile), |
|
| 4658 |
+ cli.WithFlags("--build-arg", fmt.Sprintf("%s=%s", envKey, envVal)),
|
|
| 4659 |
+ build.WithDockerfile(dockerfile), |
|
| 4660 | 4660 |
).Assert(c, icmd.Expected{
|
| 4661 | 4661 |
Out: warnStr, |
| 4662 | 4662 |
}) |
| ... | ... |
@@ -4686,7 +4686,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgEnv(c *check.C) {
|
| 4686 | 4686 |
RUN [ "$FO10" == "" ] |
| 4687 | 4687 |
` |
| 4688 | 4688 |
result := buildImage("testbuildtimeargenv",
|
| 4689 |
- withBuildFlags( |
|
| 4689 |
+ cli.WithFlags( |
|
| 4690 | 4690 |
"--build-arg", fmt.Sprintf("FOO1=fromcmd"),
|
| 4691 | 4691 |
"--build-arg", fmt.Sprintf("FOO2="),
|
| 4692 | 4692 |
"--build-arg", fmt.Sprintf("FOO3"), // set in env
|
| ... | ... |
@@ -4698,7 +4698,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgEnv(c *check.C) {
|
| 4698 | 4698 |
"--build-arg", fmt.Sprintf("FOO9"), // should produce a warning
|
| 4699 | 4699 |
"--build-arg", fmt.Sprintf("FO10"), // not set in env, empty value
|
| 4700 | 4700 |
), |
| 4701 |
- withEnvironmentVariales(append(os.Environ(), |
|
| 4701 |
+ cli.WithEnvironmentVariables(append(os.Environ(), |
|
| 4702 | 4702 |
"FOO1=fromenv", |
| 4703 | 4703 |
"FOO2=fromenv", |
| 4704 | 4704 |
"FOO3=fromenv")...), |
| ... | ... |
@@ -4740,7 +4740,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgQuotedValVariants(c *check.C) {
|
| 4740 | 4740 |
RUN [ "$%s" != "$%s" ]`, envKey, envKey1, envKey2, envKey3, |
| 4741 | 4741 |
envKey, envKey2, envKey, envKey3, envKey1, envKey2, envKey1, envKey3, |
| 4742 | 4742 |
envKey2, envKey3) |
| 4743 |
- buildImageSuccessfully(c, imgName, withDockerfile(dockerfile)) |
|
| 4743 |
+ buildImageSuccessfully(c, imgName, build.WithDockerfile(dockerfile)) |
|
| 4744 | 4744 |
} |
| 4745 | 4745 |
|
| 4746 | 4746 |
func (s *DockerSuite) TestBuildBuildTimeArgEmptyValVariants(c *check.C) {
|
| ... | ... |
@@ -4756,7 +4756,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgEmptyValVariants(c *check.C) {
|
| 4756 | 4756 |
RUN [ "$%s" == "$%s" ] |
| 4757 | 4757 |
RUN [ "$%s" == "$%s" ] |
| 4758 | 4758 |
RUN [ "$%s" == "$%s" ]`, envKey, envKey1, envKey2, envKey, envKey1, envKey1, envKey2, envKey, envKey2) |
| 4759 |
- buildImageSuccessfully(c, imgName, withDockerfile(dockerfile)) |
|
| 4759 |
+ buildImageSuccessfully(c, imgName, build.WithDockerfile(dockerfile)) |
|
| 4760 | 4760 |
} |
| 4761 | 4761 |
|
| 4762 | 4762 |
func (s *DockerSuite) TestBuildBuildTimeArgDefintionWithNoEnvInjection(c *check.C) {
|
| ... | ... |
@@ -4766,7 +4766,7 @@ func (s *DockerSuite) TestBuildBuildTimeArgDefintionWithNoEnvInjection(c *check. |
| 4766 | 4766 |
ARG %s |
| 4767 | 4767 |
RUN env`, envKey) |
| 4768 | 4768 |
|
| 4769 |
- result := buildImage(imgName, withDockerfile(dockerfile)) |
|
| 4769 |
+ result := buildImage(imgName, build.WithDockerfile(dockerfile)) |
|
| 4770 | 4770 |
result.Assert(c, icmd.Success) |
| 4771 | 4771 |
if strings.Count(result.Combined(), envKey) != 1 {
|
| 4772 | 4772 |
c.Fatalf("unexpected number of occurrences of the arg in output: %q expected: 1", result.Combined())
|
| ... | ... |
@@ -4785,7 +4785,7 @@ func (s *DockerSuite) TestBuildNoNamedVolume(c *check.C) {
|
| 4785 | 4785 |
VOLUME ` + volName + ` |
| 4786 | 4786 |
RUN ls /foo/oops |
| 4787 | 4787 |
` |
| 4788 |
- buildImage("test", withDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4788 |
+ buildImage("test", build.WithDockerfile(dockerFile)).Assert(c, icmd.Expected{
|
|
| 4789 | 4789 |
ExitCode: 1, |
| 4790 | 4790 |
}) |
| 4791 | 4791 |
} |
| ... | ... |
@@ -4796,7 +4796,7 @@ func (s *DockerSuite) TestBuildTagEvent(c *check.C) {
|
| 4796 | 4796 |
dockerFile := `FROM busybox |
| 4797 | 4797 |
RUN echo events |
| 4798 | 4798 |
` |
| 4799 |
- buildImageSuccessfully(c, "test", withDockerfile(dockerFile)) |
|
| 4799 |
+ buildImageSuccessfully(c, "test", build.WithDockerfile(dockerFile)) |
|
| 4800 | 4800 |
|
| 4801 | 4801 |
until := daemonUnixTime(c) |
| 4802 | 4802 |
out, _ := dockerCmd(c, "events", "--since", since, "--until", until, "--filter", "type=image") |
| ... | ... |
@@ -4819,7 +4819,7 @@ func (s *DockerSuite) TestBuildMultipleTags(c *check.C) {
|
| 4819 | 4819 |
FROM busybox |
| 4820 | 4820 |
MAINTAINER test-15780 |
| 4821 | 4821 |
` |
| 4822 |
- buildImageSuccessfully(c, "tag1", withBuildFlags("-t", "tag2:v2", "-t", "tag1:latest", "-t", "tag1"), withDockerfile(dockerfile))
|
|
| 4822 |
+ buildImageSuccessfully(c, "tag1", cli.WithFlags("-t", "tag2:v2", "-t", "tag1:latest", "-t", "tag1"), build.WithDockerfile(dockerfile))
|
|
| 4823 | 4823 |
|
| 4824 | 4824 |
id1 := getIDByName(c, "tag1") |
| 4825 | 4825 |
id2 := getIDByName(c, "tag2:v2") |
| ... | ... |
@@ -4963,14 +4963,14 @@ func (s *DockerSuite) TestBuildCacheRootSource(c *check.C) {
|
| 4963 | 4963 |
|
| 4964 | 4964 |
// #19375 |
| 4965 | 4965 |
func (s *DockerSuite) TestBuildFailsGitNotCallable(c *check.C) {
|
| 4966 |
- buildImage("gitnotcallable", withEnvironmentVariales("PATH="),
|
|
| 4967 |
- withBuildContextPath("github.com/docker/v1.10-migrator.git")).Assert(c, icmd.Expected{
|
|
| 4966 |
+ buildImage("gitnotcallable", cli.WithEnvironmentVariables("PATH="),
|
|
| 4967 |
+ build.WithContextPath("github.com/docker/v1.10-migrator.git")).Assert(c, icmd.Expected{
|
|
| 4968 | 4968 |
ExitCode: 1, |
| 4969 | 4969 |
Err: "unable to prepare context: unable to find 'git': ", |
| 4970 | 4970 |
}) |
| 4971 | 4971 |
|
| 4972 |
- buildImage("gitnotcallable", withEnvironmentVariales("PATH="),
|
|
| 4973 |
- withBuildContextPath("https://github.com/docker/v1.10-migrator.git")).Assert(c, icmd.Expected{
|
|
| 4972 |
+ buildImage("gitnotcallable", cli.WithEnvironmentVariables("PATH="),
|
|
| 4973 |
+ build.WithContextPath("https://github.com/docker/v1.10-migrator.git")).Assert(c, icmd.Expected{
|
|
| 4974 | 4974 |
ExitCode: 1, |
| 4975 | 4975 |
Err: "unable to prepare context: unable to find 'git': ", |
| 4976 | 4976 |
}) |
| ... | ... |
@@ -4980,7 +4980,7 @@ func (s *DockerSuite) TestBuildFailsGitNotCallable(c *check.C) {
|
| 4980 | 4980 |
func (s *DockerSuite) TestBuildWorkdirWindowsPath(c *check.C) {
|
| 4981 | 4981 |
testRequires(c, DaemonIsWindows) |
| 4982 | 4982 |
name := "testbuildworkdirwindowspath" |
| 4983 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 4983 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 4984 | 4984 |
FROM `+testEnv.MinimalBaseImage()+` |
| 4985 | 4985 |
RUN mkdir C:\\work |
| 4986 | 4986 |
WORKDIR C:\\work |
| ... | ... |
@@ -4992,8 +4992,8 @@ func (s *DockerSuite) TestBuildLabel(c *check.C) {
|
| 4992 | 4992 |
name := "testbuildlabel" |
| 4993 | 4993 |
testLabel := "foo" |
| 4994 | 4994 |
|
| 4995 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", testLabel),
|
|
| 4996 |
- withDockerfile(` |
|
| 4995 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", testLabel),
|
|
| 4996 |
+ build.WithDockerfile(` |
|
| 4997 | 4997 |
FROM `+minimalBaseImage()+` |
| 4998 | 4998 |
LABEL default foo |
| 4999 | 4999 |
`)) |
| ... | ... |
@@ -5007,8 +5007,8 @@ func (s *DockerSuite) TestBuildLabel(c *check.C) {
|
| 5007 | 5007 |
|
| 5008 | 5008 |
func (s *DockerSuite) TestBuildLabelOneNode(c *check.C) {
|
| 5009 | 5009 |
name := "testbuildlabel" |
| 5010 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", "foo=bar"),
|
|
| 5011 |
- withDockerfile("FROM busybox"))
|
|
| 5010 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", "foo=bar"),
|
|
| 5011 |
+ build.WithDockerfile("FROM busybox"))
|
|
| 5012 | 5012 |
|
| 5013 | 5013 |
var labels map[string]string |
| 5014 | 5014 |
inspectFieldAndUnmarshall(c, name, "Config.Labels", &labels) |
| ... | ... |
@@ -5023,12 +5023,12 @@ func (s *DockerSuite) TestBuildLabelCacheCommit(c *check.C) {
|
| 5023 | 5023 |
name := "testbuildlabelcachecommit" |
| 5024 | 5024 |
testLabel := "foo" |
| 5025 | 5025 |
|
| 5026 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 5026 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 5027 | 5027 |
FROM `+minimalBaseImage()+` |
| 5028 | 5028 |
LABEL default foo |
| 5029 | 5029 |
`)) |
| 5030 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", testLabel),
|
|
| 5031 |
- withDockerfile(` |
|
| 5030 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", testLabel),
|
|
| 5031 |
+ build.WithDockerfile(` |
|
| 5032 | 5032 |
FROM `+minimalBaseImage()+` |
| 5033 | 5033 |
LABEL default foo |
| 5034 | 5034 |
`)) |
| ... | ... |
@@ -5051,8 +5051,8 @@ func (s *DockerSuite) TestBuildLabelMultiple(c *check.C) {
|
| 5051 | 5051 |
labelArgs = append(labelArgs, "--label", k+"="+v) |
| 5052 | 5052 |
} |
| 5053 | 5053 |
|
| 5054 |
- buildImageSuccessfully(c, name, withBuildFlags(labelArgs...), |
|
| 5055 |
- withDockerfile(` |
|
| 5054 |
+ buildImageSuccessfully(c, name, cli.WithFlags(labelArgs...), |
|
| 5055 |
+ build.WithDockerfile(` |
|
| 5056 | 5056 |
FROM `+minimalBaseImage()+` |
| 5057 | 5057 |
LABEL default foo |
| 5058 | 5058 |
`)) |
| ... | ... |
@@ -5070,7 +5070,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestBuildFromAuthenticatedRegistry(c * |
| 5070 | 5070 |
dockerCmd(c, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL) |
| 5071 | 5071 |
baseImage := privateRegistryURL + "/baseimage" |
| 5072 | 5072 |
|
| 5073 |
- buildImageSuccessfully(c, baseImage, withDockerfile(` |
|
| 5073 |
+ buildImageSuccessfully(c, baseImage, build.WithDockerfile(` |
|
| 5074 | 5074 |
FROM busybox |
| 5075 | 5075 |
ENV env1 val1 |
| 5076 | 5076 |
`)) |
| ... | ... |
@@ -5078,7 +5078,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestBuildFromAuthenticatedRegistry(c * |
| 5078 | 5078 |
dockerCmd(c, "push", baseImage) |
| 5079 | 5079 |
dockerCmd(c, "rmi", baseImage) |
| 5080 | 5080 |
|
| 5081 |
- buildImageSuccessfully(c, baseImage, withDockerfile(fmt.Sprintf(` |
|
| 5081 |
+ buildImageSuccessfully(c, baseImage, build.WithDockerfile(fmt.Sprintf(` |
|
| 5082 | 5082 |
FROM %s |
| 5083 | 5083 |
ENV env2 val2 |
| 5084 | 5084 |
`, baseImage))) |
| ... | ... |
@@ -5130,8 +5130,8 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
|
| 5130 | 5130 |
// Command line option labels will always override |
| 5131 | 5131 |
name := "scratchy" |
| 5132 | 5132 |
expected := `{"bar":"from-flag","foo":"from-flag"}`
|
| 5133 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", "foo=from-flag", "--label", "bar=from-flag"),
|
|
| 5134 |
- withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5133 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", "foo=from-flag", "--label", "bar=from-flag"),
|
|
| 5134 |
+ build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5135 | 5135 |
LABEL foo=from-dockerfile`)) |
| 5136 | 5136 |
res := inspectFieldJSON(c, name, "Config.Labels") |
| 5137 | 5137 |
if res != expected {
|
| ... | ... |
@@ -5140,7 +5140,7 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
|
| 5140 | 5140 |
|
| 5141 | 5141 |
name = "from" |
| 5142 | 5142 |
expected = `{"foo":"from-dockerfile"}`
|
| 5143 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5143 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5144 | 5144 |
LABEL foo from-dockerfile`)) |
| 5145 | 5145 |
res = inspectFieldJSON(c, name, "Config.Labels") |
| 5146 | 5146 |
if res != expected {
|
| ... | ... |
@@ -5150,8 +5150,8 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
|
| 5150 | 5150 |
// Command line option label will override even via `FROM` |
| 5151 | 5151 |
name = "new" |
| 5152 | 5152 |
expected = `{"bar":"from-dockerfile2","foo":"new"}`
|
| 5153 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", "foo=new"),
|
|
| 5154 |
- withDockerfile(`FROM from |
|
| 5153 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", "foo=new"),
|
|
| 5154 |
+ build.WithDockerfile(`FROM from |
|
| 5155 | 5155 |
LABEL bar from-dockerfile2`)) |
| 5156 | 5156 |
res = inspectFieldJSON(c, name, "Config.Labels") |
| 5157 | 5157 |
if res != expected {
|
| ... | ... |
@@ -5162,8 +5162,8 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
|
| 5162 | 5162 |
// will be treated as --label foo="", --label bar="" |
| 5163 | 5163 |
name = "scratchy2" |
| 5164 | 5164 |
expected = `{"bar":"","foo":""}`
|
| 5165 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", "foo", "--label", "bar="),
|
|
| 5166 |
- withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5165 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", "foo", "--label", "bar="),
|
|
| 5166 |
+ build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5167 | 5167 |
LABEL foo=from-dockerfile`)) |
| 5168 | 5168 |
res = inspectFieldJSON(c, name, "Config.Labels") |
| 5169 | 5169 |
if res != expected {
|
| ... | ... |
@@ -5175,8 +5175,8 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
|
| 5175 | 5175 |
// This time is for inherited images |
| 5176 | 5176 |
name = "new2" |
| 5177 | 5177 |
expected = `{"bar":"","foo":""}`
|
| 5178 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", "foo=", "--label", "bar"),
|
|
| 5179 |
- withDockerfile(`FROM from |
|
| 5178 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", "foo=", "--label", "bar"),
|
|
| 5179 |
+ build.WithDockerfile(`FROM from |
|
| 5180 | 5180 |
LABEL bar from-dockerfile2`)) |
| 5181 | 5181 |
res = inspectFieldJSON(c, name, "Config.Labels") |
| 5182 | 5182 |
if res != expected {
|
| ... | ... |
@@ -5186,8 +5186,8 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
|
| 5186 | 5186 |
// Command line option labels with only `FROM` |
| 5187 | 5187 |
name = "scratchy" |
| 5188 | 5188 |
expected = `{"bar":"from-flag","foo":"from-flag"}`
|
| 5189 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", "foo=from-flag", "--label", "bar=from-flag"),
|
|
| 5190 |
- withDockerfile(`FROM `+minimalBaseImage())) |
|
| 5189 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", "foo=from-flag", "--label", "bar=from-flag"),
|
|
| 5190 |
+ build.WithDockerfile(`FROM `+minimalBaseImage())) |
|
| 5191 | 5191 |
res = inspectFieldJSON(c, name, "Config.Labels") |
| 5192 | 5192 |
if res != expected {
|
| 5193 | 5193 |
c.Fatalf("Labels %s, expected %s", res, expected)
|
| ... | ... |
@@ -5196,8 +5196,8 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
|
| 5196 | 5196 |
// Command line option labels with env var |
| 5197 | 5197 |
name = "scratchz" |
| 5198 | 5198 |
expected = `{"bar":"$PATH"}`
|
| 5199 |
- buildImageSuccessfully(c, name, withBuildFlags("--label", "bar=$PATH"),
|
|
| 5200 |
- withDockerfile(`FROM `+minimalBaseImage())) |
|
| 5199 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--label", "bar=$PATH"),
|
|
| 5200 |
+ build.WithDockerfile(`FROM `+minimalBaseImage())) |
|
| 5201 | 5201 |
res = inspectFieldJSON(c, name, "Config.Labels") |
| 5202 | 5202 |
if res != expected {
|
| 5203 | 5203 |
c.Fatalf("Labels %s, expected %s", res, expected)
|
| ... | ... |
@@ -5207,7 +5207,7 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
|
| 5207 | 5207 |
// Test case for #22855 |
| 5208 | 5208 |
func (s *DockerSuite) TestBuildDeleteCommittedFile(c *check.C) {
|
| 5209 | 5209 |
name := "test-delete-committed-file" |
| 5210 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 5210 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 5211 | 5211 |
RUN echo test > file |
| 5212 | 5212 |
RUN test -e file |
| 5213 | 5213 |
RUN rm file |
| ... | ... |
@@ -5279,7 +5279,7 @@ func (s *DockerSuite) TestBuildWithUTF8BOMDockerignore(c *check.C) {
|
| 5279 | 5279 |
func (s *DockerSuite) TestBuildShellUpdatesConfig(c *check.C) {
|
| 5280 | 5280 |
name := "testbuildshellupdatesconfig" |
| 5281 | 5281 |
|
| 5282 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5282 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5283 | 5283 |
SHELL ["foo", "-bar"]`)) |
| 5284 | 5284 |
expected := `["foo","-bar","#(nop) ","SHELL [foo -bar]"]` |
| 5285 | 5285 |
res := inspectFieldJSON(c, name, "ContainerConfig.Cmd") |
| ... | ... |
@@ -5296,7 +5296,7 @@ func (s *DockerSuite) TestBuildShellUpdatesConfig(c *check.C) {
|
| 5296 | 5296 |
func (s *DockerSuite) TestBuildShellMultiple(c *check.C) {
|
| 5297 | 5297 |
name := "testbuildshellmultiple" |
| 5298 | 5298 |
|
| 5299 |
- result := buildImage(name, withDockerfile(`FROM busybox |
|
| 5299 |
+ result := buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 5300 | 5300 |
RUN echo defaultshell |
| 5301 | 5301 |
SHELL ["echo"] |
| 5302 | 5302 |
RUN echoshell |
| ... | ... |
@@ -5332,7 +5332,7 @@ func (s *DockerSuite) TestBuildShellMultiple(c *check.C) {
|
| 5332 | 5332 |
func (s *DockerSuite) TestBuildShellEntrypoint(c *check.C) {
|
| 5333 | 5333 |
name := "testbuildshellentrypoint" |
| 5334 | 5334 |
|
| 5335 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 5335 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 5336 | 5336 |
SHELL ["ls"] |
| 5337 | 5337 |
ENTRYPOINT -l`)) |
| 5338 | 5338 |
// A container started from the image uses the shell-form ENTRYPOINT. |
| ... | ... |
@@ -5346,10 +5346,10 @@ func (s *DockerSuite) TestBuildShellEntrypoint(c *check.C) {
|
| 5346 | 5346 |
// #22489 Shell test to confirm shell is inherited in a subsequent build |
| 5347 | 5347 |
func (s *DockerSuite) TestBuildShellInherited(c *check.C) {
|
| 5348 | 5348 |
name1 := "testbuildshellinherited1" |
| 5349 |
- buildImageSuccessfully(c, name1, withDockerfile(`FROM busybox |
|
| 5349 |
+ buildImageSuccessfully(c, name1, build.WithDockerfile(`FROM busybox |
|
| 5350 | 5350 |
SHELL ["ls"]`)) |
| 5351 | 5351 |
name2 := "testbuildshellinherited2" |
| 5352 |
- buildImage(name2, withDockerfile(`FROM `+name1+` |
|
| 5352 |
+ buildImage(name2, build.WithDockerfile(`FROM `+name1+` |
|
| 5353 | 5353 |
RUN -l`)).Assert(c, icmd.Expected{
|
| 5354 | 5354 |
// ls -l has "total " followed by some number in it, ls without -l does not. |
| 5355 | 5355 |
Out: "total ", |
| ... | ... |
@@ -5360,7 +5360,7 @@ func (s *DockerSuite) TestBuildShellInherited(c *check.C) {
|
| 5360 | 5360 |
func (s *DockerSuite) TestBuildShellNotJSON(c *check.C) {
|
| 5361 | 5361 |
name := "testbuildshellnotjson" |
| 5362 | 5362 |
|
| 5363 |
- buildImage(name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5363 |
+ buildImage(name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5364 | 5364 |
sHeLl exec -form`, // Casing explicit to ensure error is upper-cased. |
| 5365 | 5365 |
)).Assert(c, icmd.Expected{
|
| 5366 | 5366 |
ExitCode: 1, |
| ... | ... |
@@ -5373,7 +5373,7 @@ func (s *DockerSuite) TestBuildShellNotJSON(c *check.C) {
|
| 5373 | 5373 |
func (s *DockerSuite) TestBuildShellWindowsPowershell(c *check.C) {
|
| 5374 | 5374 |
testRequires(c, DaemonIsWindows) |
| 5375 | 5375 |
name := "testbuildshellpowershell" |
| 5376 |
- buildImage(name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5376 |
+ buildImage(name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 5377 | 5377 |
SHELL ["powershell", "-command"] |
| 5378 | 5378 |
RUN Write-Host John`)).Assert(c, icmd.Expected{
|
| 5379 | 5379 |
Out: "\nJohn\n", |
| ... | ... |
@@ -5385,7 +5385,7 @@ func (s *DockerSuite) TestBuildShellWindowsPowershell(c *check.C) {
|
| 5385 | 5385 |
func (s *DockerSuite) TestBuildEscapeNotBackslashWordTest(c *check.C) {
|
| 5386 | 5386 |
testRequires(c, DaemonIsWindows) |
| 5387 | 5387 |
name := "testbuildescapenotbackslashwordtesta" |
| 5388 |
- buildImage(name, withDockerfile(`# escape= `+"`"+` |
|
| 5388 |
+ buildImage(name, build.WithDockerfile(`# escape= `+"`"+` |
|
| 5389 | 5389 |
FROM `+minimalBaseImage()+` |
| 5390 | 5390 |
WORKDIR c:\windows |
| 5391 | 5391 |
RUN dir /w`)).Assert(c, icmd.Expected{
|
| ... | ... |
@@ -5393,7 +5393,7 @@ func (s *DockerSuite) TestBuildEscapeNotBackslashWordTest(c *check.C) {
|
| 5393 | 5393 |
}) |
| 5394 | 5394 |
|
| 5395 | 5395 |
name = "testbuildescapenotbackslashwordtestb" |
| 5396 |
- buildImage(name, withDockerfile(`# escape= `+"`"+` |
|
| 5396 |
+ buildImage(name, build.WithDockerfile(`# escape= `+"`"+` |
|
| 5397 | 5397 |
FROM `+minimalBaseImage()+` |
| 5398 | 5398 |
SHELL ["powershell.exe"] |
| 5399 | 5399 |
WORKDIR c:\foo |
| ... | ... |
@@ -5407,7 +5407,7 @@ func (s *DockerSuite) TestBuildEscapeNotBackslashWordTest(c *check.C) {
|
| 5407 | 5407 |
func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *check.C) {
|
| 5408 | 5408 |
testRequires(c, DaemonIsWindows) |
| 5409 | 5409 |
name := "testbuildcmdshellescaped" |
| 5410 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 5410 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 5411 | 5411 |
FROM `+minimalBaseImage()+` |
| 5412 | 5412 |
CMD "ipconfig" |
| 5413 | 5413 |
`)) |
| ... | ... |
@@ -5428,7 +5428,7 @@ func (s *DockerSuite) TestBuildCmdShellArgsEscaped(c *check.C) {
|
| 5428 | 5428 |
func (s *DockerSuite) TestBuildStepsWithProgress(c *check.C) {
|
| 5429 | 5429 |
name := "testbuildstepswithprogress" |
| 5430 | 5430 |
totalRun := 5 |
| 5431 |
- result := buildImage(name, withDockerfile("FROM busybox\n"+strings.Repeat("RUN echo foo\n", totalRun)))
|
|
| 5431 |
+ result := buildImage(name, build.WithDockerfile("FROM busybox\n"+strings.Repeat("RUN echo foo\n", totalRun)))
|
|
| 5432 | 5432 |
result.Assert(c, icmd.Success) |
| 5433 | 5433 |
c.Assert(result.Combined(), checker.Contains, fmt.Sprintf("Step 1/%d : FROM busybox", 1+totalRun))
|
| 5434 | 5434 |
for i := 2; i <= 1+totalRun; i++ {
|
| ... | ... |
@@ -5441,14 +5441,14 @@ func (s *DockerSuite) TestBuildWithFailure(c *check.C) {
|
| 5441 | 5441 |
|
| 5442 | 5442 |
// First test case can only detect `nobody` in runtime so all steps will show up |
| 5443 | 5443 |
dockerfile := "FROM busybox\nRUN nobody" |
| 5444 |
- result := buildImage(name, withDockerfile(dockerfile)) |
|
| 5444 |
+ result := buildImage(name, build.WithDockerfile(dockerfile)) |
|
| 5445 | 5445 |
c.Assert(result.Error, checker.NotNil) |
| 5446 | 5446 |
c.Assert(result.Stdout(), checker.Contains, "Step 1/2 : FROM busybox") |
| 5447 | 5447 |
c.Assert(result.Stdout(), checker.Contains, "Step 2/2 : RUN nobody") |
| 5448 | 5448 |
|
| 5449 | 5449 |
// Second test case `FFOM` should have been detected before build runs so no steps |
| 5450 | 5450 |
dockerfile = "FFOM nobody\nRUN nobody" |
| 5451 |
- result = buildImage(name, withDockerfile(dockerfile)) |
|
| 5451 |
+ result = buildImage(name, build.WithDockerfile(dockerfile)) |
|
| 5452 | 5452 |
c.Assert(result.Error, checker.NotNil) |
| 5453 | 5453 |
c.Assert(result.Stdout(), checker.Not(checker.Contains), "Step 1/2 : FROM busybox") |
| 5454 | 5454 |
c.Assert(result.Stdout(), checker.Not(checker.Contains), "Step 2/2 : RUN nobody") |
| ... | ... |
@@ -5468,7 +5468,7 @@ func (s *DockerSuite) TestBuildCacheFromEqualDiffIDsLength(c *check.C) {
|
| 5468 | 5468 |
id1 := getIDByName(c, "build1") |
| 5469 | 5469 |
|
| 5470 | 5470 |
// rebuild with cache-from |
| 5471 |
- result := buildImage("build2", withBuildFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5471 |
+ result := buildImage("build2", cli.WithFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5472 | 5472 |
result.Assert(c, icmd.Success) |
| 5473 | 5473 |
id2 := getIDByName(c, "build2") |
| 5474 | 5474 |
c.Assert(id1, checker.Equals, id2) |
| ... | ... |
@@ -5492,7 +5492,7 @@ func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
|
| 5492 | 5492 |
id1 := getIDByName(c, "build1") |
| 5493 | 5493 |
|
| 5494 | 5494 |
// rebuild with cache-from |
| 5495 |
- result := buildImage("build2", withBuildFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5495 |
+ result := buildImage("build2", cli.WithFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5496 | 5496 |
result.Assert(c, icmd.Success) |
| 5497 | 5497 |
id2 := getIDByName(c, "build2") |
| 5498 | 5498 |
c.Assert(id1, checker.Equals, id2) |
| ... | ... |
@@ -5500,7 +5500,7 @@ func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
|
| 5500 | 5500 |
dockerCmd(c, "rmi", "build2") |
| 5501 | 5501 |
|
| 5502 | 5502 |
// no cache match with unknown source |
| 5503 |
- result = buildImage("build2", withBuildFlags("--cache-from=nosuchtag"), withExternalBuildContext(ctx))
|
|
| 5503 |
+ result = buildImage("build2", cli.WithFlags("--cache-from=nosuchtag"), withExternalBuildContext(ctx))
|
|
| 5504 | 5504 |
result.Assert(c, icmd.Success) |
| 5505 | 5505 |
id2 = getIDByName(c, "build2") |
| 5506 | 5506 |
c.Assert(id1, checker.Not(checker.Equals), id2) |
| ... | ... |
@@ -5521,7 +5521,7 @@ func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
|
| 5521 | 5521 |
c.Assert(strings.TrimSpace(parentID), checker.Equals, "") |
| 5522 | 5522 |
|
| 5523 | 5523 |
// cache still applies without parents |
| 5524 |
- result = buildImage("build2", withBuildFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5524 |
+ result = buildImage("build2", cli.WithFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5525 | 5525 |
result.Assert(c, icmd.Success) |
| 5526 | 5526 |
id2 = getIDByName(c, "build2") |
| 5527 | 5527 |
c.Assert(id1, checker.Equals, id2) |
| ... | ... |
@@ -5529,7 +5529,7 @@ func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
|
| 5529 | 5529 |
history1, _ := dockerCmd(c, "history", "-q", "build2") |
| 5530 | 5530 |
|
| 5531 | 5531 |
// Retry, no new intermediate images |
| 5532 |
- result = buildImage("build3", withBuildFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5532 |
+ result = buildImage("build3", cli.WithFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5533 | 5533 |
result.Assert(c, icmd.Success) |
| 5534 | 5534 |
id3 := getIDByName(c, "build3") |
| 5535 | 5535 |
c.Assert(id1, checker.Equals, id3) |
| ... | ... |
@@ -5551,7 +5551,7 @@ func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
|
| 5551 | 5551 |
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(dockerfile), 0644) |
| 5552 | 5552 |
c.Assert(err, checker.IsNil) |
| 5553 | 5553 |
|
| 5554 |
- result = buildImage("build2", withBuildFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5554 |
+ result = buildImage("build2", cli.WithFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
|
| 5555 | 5555 |
result.Assert(c, icmd.Success) |
| 5556 | 5556 |
id2 = getIDByName(c, "build2") |
| 5557 | 5557 |
c.Assert(id1, checker.Not(checker.Equals), id2) |
| ... | ... |
@@ -5575,7 +5575,7 @@ func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
|
| 5575 | 5575 |
func (s *DockerSuite) TestBuildNetNone(c *check.C) {
|
| 5576 | 5576 |
testRequires(c, DaemonIsLinux) |
| 5577 | 5577 |
name := "testbuildnetnone" |
| 5578 |
- buildImage(name, withBuildFlags("--network=none"), withDockerfile(`
|
|
| 5578 |
+ buildImage(name, cli.WithFlags("--network=none"), build.WithDockerfile(`
|
|
| 5579 | 5579 |
FROM busybox |
| 5580 | 5580 |
RUN ping -c 1 8.8.8.8 |
| 5581 | 5581 |
`)).Assert(c, icmd.Expected{
|
| ... | ... |
@@ -5590,8 +5590,8 @@ func (s *DockerSuite) TestBuildNetContainer(c *check.C) {
|
| 5590 | 5590 |
id, _ := dockerCmd(c, "run", "--hostname", "foobar", "-d", "busybox", "nc", "-ll", "-p", "1234", "-e", "hostname") |
| 5591 | 5591 |
|
| 5592 | 5592 |
name := "testbuildnetcontainer" |
| 5593 |
- buildImageSuccessfully(c, name, withBuildFlags("--network=container:"+strings.TrimSpace(id)),
|
|
| 5594 |
- withDockerfile(` |
|
| 5593 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--network=container:"+strings.TrimSpace(id)),
|
|
| 5594 |
+ build.WithDockerfile(` |
|
| 5595 | 5595 |
FROM busybox |
| 5596 | 5596 |
RUN nc localhost 1234 > /otherhost |
| 5597 | 5597 |
`)) |
| ... | ... |
@@ -5605,11 +5605,11 @@ func (s *DockerSuite) TestBuildWithExtraHost(c *check.C) {
|
| 5605 | 5605 |
|
| 5606 | 5606 |
name := "testbuildwithextrahost" |
| 5607 | 5607 |
buildImageSuccessfully(c, name, |
| 5608 |
- withBuildFlags( |
|
| 5608 |
+ cli.WithFlags( |
|
| 5609 | 5609 |
"--add-host", "foo:127.0.0.1", |
| 5610 | 5610 |
"--add-host", "bar:127.0.0.1", |
| 5611 | 5611 |
), |
| 5612 |
- withDockerfile(` |
|
| 5612 |
+ build.WithDockerfile(` |
|
| 5613 | 5613 |
FROM busybox |
| 5614 | 5614 |
RUN ping -c 1 foo |
| 5615 | 5615 |
RUN ping -c 1 bar |
| ... | ... |
@@ -5635,7 +5635,7 @@ func (s *DockerSuite) TestBuildWithExtraHostInvalidFormat(c *check.C) {
|
| 5635 | 5635 |
} |
| 5636 | 5636 |
|
| 5637 | 5637 |
for _, tc := range testCases {
|
| 5638 |
- result := buildImage(tc.testName, withBuildFlags(tc.buildFlag), withDockerfile(tc.dockerfile)) |
|
| 5638 |
+ result := buildImage(tc.testName, cli.WithFlags(tc.buildFlag), build.WithDockerfile(tc.dockerfile)) |
|
| 5639 | 5639 |
result.Assert(c, icmd.Expected{
|
| 5640 | 5640 |
ExitCode: 125, |
| 5641 | 5641 |
}) |
| ... | ... |
@@ -5655,11 +5655,11 @@ func (s *DockerSuite) TestBuildSquashParent(c *check.C) {
|
| 5655 | 5655 |
` |
| 5656 | 5656 |
// build and get the ID that we can use later for history comparison |
| 5657 | 5657 |
name := "test" |
| 5658 |
- buildImageSuccessfully(c, name, withDockerfile(dockerFile)) |
|
| 5658 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerFile)) |
|
| 5659 | 5659 |
origID := getIDByName(c, name) |
| 5660 | 5660 |
|
| 5661 | 5661 |
// build with squash |
| 5662 |
- buildImageSuccessfully(c, name, withBuildFlags("--squash"), withDockerfile(dockerFile))
|
|
| 5662 |
+ buildImageSuccessfully(c, name, cli.WithFlags("--squash"), build.WithDockerfile(dockerFile))
|
|
| 5663 | 5663 |
id := getIDByName(c, name) |
| 5664 | 5664 |
|
| 5665 | 5665 |
out, _ := dockerCmd(c, "run", "--rm", id, "/bin/sh", "-c", "cat /hello") |
| ... | ... |
@@ -5686,23 +5686,23 @@ func (s *DockerSuite) TestBuildSquashParent(c *check.C) {
|
| 5686 | 5686 |
func (s *DockerSuite) TestBuildContChar(c *check.C) {
|
| 5687 | 5687 |
name := "testbuildcontchar" |
| 5688 | 5688 |
|
| 5689 |
- buildImage(name, withDockerfile(`FROM busybox\`)).Assert(c, icmd.Expected{
|
|
| 5689 |
+ buildImage(name, build.WithDockerfile(`FROM busybox\`)).Assert(c, icmd.Expected{
|
|
| 5690 | 5690 |
Out: "Step 1/1 : FROM busybox", |
| 5691 | 5691 |
}) |
| 5692 | 5692 |
|
| 5693 |
- result := buildImage(name, withDockerfile(`FROM busybox |
|
| 5693 |
+ result := buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 5694 | 5694 |
RUN echo hi \`)) |
| 5695 | 5695 |
result.Assert(c, icmd.Success) |
| 5696 | 5696 |
c.Assert(result.Combined(), checker.Contains, "Step 1/2 : FROM busybox") |
| 5697 | 5697 |
c.Assert(result.Combined(), checker.Contains, "Step 2/2 : RUN echo hi\n") |
| 5698 | 5698 |
|
| 5699 |
- result = buildImage(name, withDockerfile(`FROM busybox |
|
| 5699 |
+ result = buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 5700 | 5700 |
RUN echo hi \\`)) |
| 5701 | 5701 |
result.Assert(c, icmd.Success) |
| 5702 | 5702 |
c.Assert(result.Combined(), checker.Contains, "Step 1/2 : FROM busybox") |
| 5703 | 5703 |
c.Assert(result.Combined(), checker.Contains, "Step 2/2 : RUN echo hi \\\n") |
| 5704 | 5704 |
|
| 5705 |
- result = buildImage(name, withDockerfile(`FROM busybox |
|
| 5705 |
+ result = buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 5706 | 5706 |
RUN echo hi \\\`)) |
| 5707 | 5707 |
result.Assert(c, icmd.Success) |
| 5708 | 5708 |
c.Assert(result.Combined(), checker.Contains, "Step 1/2 : FROM busybox") |
| ... | ... |
@@ -5723,14 +5723,14 @@ func (s *DockerSuite) TestBuildOpaqueDirectory(c *check.C) {
|
| 5723 | 5723 |
` |
| 5724 | 5724 |
// Test that build succeeds, last command fails if opaque directory |
| 5725 | 5725 |
// was not handled correctly |
| 5726 |
- buildImageSuccessfully(c, "testopaquedirectory", withDockerfile(dockerFile)) |
|
| 5726 |
+ buildImageSuccessfully(c, "testopaquedirectory", build.WithDockerfile(dockerFile)) |
|
| 5727 | 5727 |
} |
| 5728 | 5728 |
|
| 5729 | 5729 |
// Windows test for USER in dockerfile |
| 5730 | 5730 |
func (s *DockerSuite) TestBuildWindowsUser(c *check.C) {
|
| 5731 | 5731 |
testRequires(c, DaemonIsWindows) |
| 5732 | 5732 |
name := "testbuildwindowsuser" |
| 5733 |
- buildImage(name, withDockerfile(`FROM `+testEnv.MinimalBaseImage()+` |
|
| 5733 |
+ buildImage(name, build.WithDockerfile(`FROM `+testEnv.MinimalBaseImage()+` |
|
| 5734 | 5734 |
RUN net user user /add |
| 5735 | 5735 |
USER user |
| 5736 | 5736 |
RUN set username |
| ... | ... |
@@ -5760,7 +5760,7 @@ RUN ["cat", "/foo/file"] |
| 5760 | 5760 |
func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *check.C) {
|
| 5761 | 5761 |
testRequires(c, DaemonIsWindows) |
| 5762 | 5762 |
name := "testbuildwindowsenvcaseinsensitive" |
| 5763 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 5763 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 5764 | 5764 |
FROM `+testEnv.MinimalBaseImage()+` |
| 5765 | 5765 |
ENV FOO=bar foo=baz |
| 5766 | 5766 |
`)) |
| ... | ... |
@@ -5773,7 +5773,7 @@ func (s *DockerSuite) TestBuildWindowsEnvCaseInsensitive(c *check.C) {
|
| 5773 | 5773 |
// Test case for 29667 |
| 5774 | 5774 |
func (s *DockerSuite) TestBuildWorkdirImageCmd(c *check.C) {
|
| 5775 | 5775 |
image := "testworkdirimagecmd" |
| 5776 |
- buildImageSuccessfully(c, image, withDockerfile(` |
|
| 5776 |
+ buildImageSuccessfully(c, image, build.WithDockerfile(` |
|
| 5777 | 5777 |
FROM busybox |
| 5778 | 5778 |
WORKDIR /foo/bar |
| 5779 | 5779 |
`)) |
| ... | ... |
@@ -5787,7 +5787,7 @@ WORKDIR /foo/bar |
| 5787 | 5787 |
c.Assert(strings.TrimSpace(out), checker.Equals, lookingFor) |
| 5788 | 5788 |
|
| 5789 | 5789 |
image = "testworkdirlabelimagecmd" |
| 5790 |
- buildImageSuccessfully(c, image, withDockerfile(` |
|
| 5790 |
+ buildImageSuccessfully(c, image, build.WithDockerfile(` |
|
| 5791 | 5791 |
FROM busybox |
| 5792 | 5792 |
WORKDIR /foo/bar |
| 5793 | 5793 |
LABEL a=b |
| ... | ... |
@@ -5805,8 +5805,8 @@ func (s *DockerSuite) TestBuildWorkdirCmd(c *check.C) {
|
| 5805 | 5805 |
FROM busybox |
| 5806 | 5806 |
WORKDIR / |
| 5807 | 5807 |
` |
| 5808 |
- buildImageSuccessfully(c, name, withDockerfile(dockerFile)) |
|
| 5809 |
- result := buildImage(name, withDockerfile(dockerFile)) |
|
| 5808 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerFile)) |
|
| 5809 |
+ result := buildImage(name, build.WithDockerfile(dockerFile)) |
|
| 5810 | 5810 |
result.Assert(c, icmd.Success) |
| 5811 | 5811 |
c.Assert(strings.Count(result.Combined(), "Using cache"), checker.Equals, 1) |
| 5812 | 5812 |
} |
| ... | ... |
@@ -5814,7 +5814,7 @@ func (s *DockerSuite) TestBuildWorkdirCmd(c *check.C) {
|
| 5814 | 5814 |
// FIXME(vdemeester) should be a unit test |
| 5815 | 5815 |
func (s *DockerSuite) TestBuildLineErrorOnBuild(c *check.C) {
|
| 5816 | 5816 |
name := "test_build_line_error_onbuild" |
| 5817 |
- buildImage(name, withDockerfile(`FROM busybox |
|
| 5817 |
+ buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 5818 | 5818 |
ONBUILD |
| 5819 | 5819 |
`)).Assert(c, icmd.Expected{
|
| 5820 | 5820 |
ExitCode: 1, |
| ... | ... |
@@ -5825,7 +5825,7 @@ func (s *DockerSuite) TestBuildLineErrorOnBuild(c *check.C) {
|
| 5825 | 5825 |
// FIXME(vdemeester) should be a unit test |
| 5826 | 5826 |
func (s *DockerSuite) TestBuildLineErrorUknownInstruction(c *check.C) {
|
| 5827 | 5827 |
name := "test_build_line_error_unknown_instruction" |
| 5828 |
- buildImage(name, withDockerfile(`FROM busybox |
|
| 5828 |
+ buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 5829 | 5829 |
RUN echo hello world |
| 5830 | 5830 |
NOINSTRUCTION echo ba |
| 5831 | 5831 |
RUN echo hello |
| ... | ... |
@@ -5839,7 +5839,7 @@ func (s *DockerSuite) TestBuildLineErrorUknownInstruction(c *check.C) {
|
| 5839 | 5839 |
// FIXME(vdemeester) should be a unit test |
| 5840 | 5840 |
func (s *DockerSuite) TestBuildLineErrorWithEmptyLines(c *check.C) {
|
| 5841 | 5841 |
name := "test_build_line_error_with_empty_lines" |
| 5842 |
- buildImage(name, withDockerfile(` |
|
| 5842 |
+ buildImage(name, build.WithDockerfile(` |
|
| 5843 | 5843 |
FROM busybox |
| 5844 | 5844 |
|
| 5845 | 5845 |
RUN echo hello world |
| ... | ... |
@@ -5856,7 +5856,7 @@ func (s *DockerSuite) TestBuildLineErrorWithEmptyLines(c *check.C) {
|
| 5856 | 5856 |
// FIXME(vdemeester) should be a unit test |
| 5857 | 5857 |
func (s *DockerSuite) TestBuildLineErrorWithComments(c *check.C) {
|
| 5858 | 5858 |
name := "test_build_line_error_with_comments" |
| 5859 |
- buildImage(name, withDockerfile(`FROM busybox |
|
| 5859 |
+ buildImage(name, build.WithDockerfile(`FROM busybox |
|
| 5860 | 5860 |
# This will print hello world |
| 5861 | 5861 |
# and then ba |
| 5862 | 5862 |
RUN echo hello world |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"github.com/docker/distribution/manifest/schema2" |
| 13 | 13 |
"github.com/docker/docker/api/types" |
| 14 | 14 |
"github.com/docker/docker/integration-cli/checker" |
| 15 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 15 | 16 |
"github.com/docker/docker/pkg/stringutils" |
| 16 | 17 |
"github.com/go-check/check" |
| 17 | 18 |
"github.com/opencontainers/go-digest" |
| ... | ... |
@@ -196,7 +197,7 @@ func (s *DockerRegistrySuite) TestBuildByDigest(c *check.C) {
|
| 196 | 196 |
|
| 197 | 197 |
// do the build |
| 198 | 198 |
name := "buildbydigest" |
| 199 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf( |
|
| 199 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf( |
|
| 200 | 200 |
`FROM %s |
| 201 | 201 |
CMD ["/bin/echo", "Hello World"]`, imageReference))) |
| 202 | 202 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -419,7 +420,7 @@ func (s *DockerRegistrySuite) TestPsListContainersFilterAncestorImageByDigest(c |
| 419 | 419 |
|
| 420 | 420 |
// build an image from it |
| 421 | 421 |
imageName1 := "images_ps_filter_test" |
| 422 |
- buildImageSuccessfully(c, imageName1, withDockerfile(fmt.Sprintf( |
|
| 422 |
+ buildImageSuccessfully(c, imageName1, build.WithDockerfile(fmt.Sprintf( |
|
| 423 | 423 |
`FROM %s |
| 424 | 424 |
LABEL match me 1`, imageReference))) |
| 425 | 425 |
|
| ... | ... |
@@ -4,21 +4,22 @@ import ( |
| 4 | 4 |
"strings" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/docker/docker/integration-cli/checker" |
| 7 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 7 | 8 |
"github.com/go-check/check" |
| 8 | 9 |
) |
| 9 | 10 |
|
| 10 | 11 |
func (s *DockerSuite) TestCommitAfterContainerIsDone(c *check.C) {
|
| 11 |
- out, _ := dockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo") |
|
| 12 |
+ out := cli.DockerCmd(c, "run", "-i", "-a", "stdin", "busybox", "echo", "foo").Combined() |
|
| 12 | 13 |
|
| 13 | 14 |
cleanedContainerID := strings.TrimSpace(out) |
| 14 | 15 |
|
| 15 |
- dockerCmd(c, "wait", cleanedContainerID) |
|
| 16 |
+ cli.DockerCmd(c, "wait", cleanedContainerID) |
|
| 16 | 17 |
|
| 17 |
- out, _ = dockerCmd(c, "commit", cleanedContainerID) |
|
| 18 |
+ out = cli.DockerCmd(c, "commit", cleanedContainerID).Combined() |
|
| 18 | 19 |
|
| 19 | 20 |
cleanedImageID := strings.TrimSpace(out) |
| 20 | 21 |
|
| 21 |
- dockerCmd(c, "inspect", cleanedImageID) |
|
| 22 |
+ cli.DockerCmd(c, "inspect", cleanedImageID) |
|
| 22 | 23 |
} |
| 23 | 24 |
|
| 24 | 25 |
func (s *DockerSuite) TestCommitWithoutPause(c *check.C) {
|
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/docker/docker/integration-cli/checker" |
| 13 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 13 | 14 |
"github.com/docker/docker/pkg/stringid" |
| 14 | 15 |
"github.com/docker/docker/pkg/testutil" |
| 15 | 16 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| ... | ... |
@@ -204,7 +205,7 @@ func (s *DockerSuite) TestCreateLabels(c *check.C) {
|
| 204 | 204 |
|
| 205 | 205 |
func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) {
|
| 206 | 206 |
imageName := "testcreatebuildlabel" |
| 207 |
- buildImageSuccessfully(c, imageName, withDockerfile(`FROM busybox |
|
| 207 |
+ buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox |
|
| 208 | 208 |
LABEL k1=v1 k2=v2`)) |
| 209 | 209 |
|
| 210 | 210 |
name := "test_create_labels_from_image" |
| ... | ... |
@@ -259,7 +260,7 @@ func (s *DockerSuite) TestCreateModeIpcContainer(c *check.C) {
|
| 259 | 259 |
|
| 260 | 260 |
func (s *DockerSuite) TestCreateByImageID(c *check.C) {
|
| 261 | 261 |
imageName := "testcreatebyimageid" |
| 262 |
- buildImageSuccessfully(c, imageName, withDockerfile(`FROM busybox |
|
| 262 |
+ buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox |
|
| 263 | 263 |
MAINTAINER dockerio`)) |
| 264 | 264 |
imageID := getIDByName(c, imageName) |
| 265 | 265 |
truncatedImageID := stringid.TruncateID(imageID) |
| ... | ... |
@@ -22,6 +22,7 @@ import ( |
| 22 | 22 |
"time" |
| 23 | 23 |
|
| 24 | 24 |
"github.com/docker/docker/integration-cli/checker" |
| 25 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 25 | 26 |
"github.com/docker/docker/integration-cli/daemon" |
| 26 | 27 |
"github.com/docker/docker/pkg/mount" |
| 27 | 28 |
"github.com/docker/docker/pkg/stringid" |
| ... | ... |
@@ -47,21 +48,20 @@ func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) {
|
| 47 | 47 |
func (s *DockerDaemonSuite) TestDaemonRestartWithRunningContainersPorts(c *check.C) {
|
| 48 | 48 |
s.d.StartWithBusybox(c) |
| 49 | 49 |
|
| 50 |
- if out, err := s.d.Cmd("run", "-d", "--name", "top1", "-p", "1234:80", "--restart", "always", "busybox:latest", "top"); err != nil {
|
|
| 51 |
- c.Fatalf("Could not run top1: err=%v\n%s", err, out)
|
|
| 52 |
- } |
|
| 53 |
- // --restart=no by default |
|
| 54 |
- if out, err := s.d.Cmd("run", "-d", "--name", "top2", "-p", "80", "busybox:latest", "top"); err != nil {
|
|
| 55 |
- c.Fatalf("Could not run top2: err=%v\n%s", err, out)
|
|
| 56 |
- } |
|
| 50 |
+ cli.Docker( |
|
| 51 |
+ cli.Cmd("run", "-d", "--name", "top1", "-p", "1234:80", "--restart", "always", "busybox:latest", "top"),
|
|
| 52 |
+ cli.Daemon(s.d), |
|
| 53 |
+ ).Assert(c, icmd.Success) |
|
| 54 |
+ |
|
| 55 |
+ cli.Docker( |
|
| 56 |
+ cli.Cmd("run", "-d", "--name", "top2", "-p", "80", "busybox:latest", "top"),
|
|
| 57 |
+ cli.Daemon(s.d), |
|
| 58 |
+ ).Assert(c, icmd.Success) |
|
| 57 | 59 |
|
| 58 | 60 |
testRun := func(m map[string]bool, prefix string) {
|
| 59 | 61 |
var format string |
| 60 | 62 |
for cont, shouldRun := range m {
|
| 61 |
- out, err := s.d.Cmd("ps")
|
|
| 62 |
- if err != nil {
|
|
| 63 |
- c.Fatalf("Could not run ps: err=%v\n%q", err, out)
|
|
| 64 |
- } |
|
| 63 |
+ out := cli.Docker(cli.Cmd("ps"), cli.Daemon(s.d)).Assert(c, icmd.Success).Combined()
|
|
| 65 | 64 |
if shouldRun {
|
| 66 | 65 |
format = "%scontainer %q is not running" |
| 67 | 66 |
} else {
|
| ... | ... |
@@ -15,6 +15,7 @@ import ( |
| 15 | 15 |
eventtypes "github.com/docker/docker/api/types/events" |
| 16 | 16 |
eventstestutils "github.com/docker/docker/daemon/events/testutils" |
| 17 | 17 |
"github.com/docker/docker/integration-cli/checker" |
| 18 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 18 | 19 |
"github.com/docker/docker/integration-cli/request" |
| 19 | 20 |
"github.com/docker/docker/pkg/testutil" |
| 20 | 21 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| ... | ... |
@@ -384,7 +385,7 @@ func (s *DockerSuite) TestEventsFilterImageLabels(c *check.C) {
|
| 384 | 384 |
label := "io.docker.testing=image" |
| 385 | 385 |
|
| 386 | 386 |
// Build a test image. |
| 387 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf(` |
|
| 387 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(` |
|
| 388 | 388 |
FROM busybox:latest |
| 389 | 389 |
LABEL %s`, label))) |
| 390 | 390 |
dockerCmd(c, "tag", name, "labelfiltertest:tag1") |
| ... | ... |
@@ -465,7 +466,7 @@ func (s *DockerSuite) TestEventsCommit(c *check.C) {
|
| 465 | 465 |
|
| 466 | 466 |
func (s *DockerSuite) TestEventsCopy(c *check.C) {
|
| 467 | 467 |
// Build a test image. |
| 468 |
- buildImageSuccessfully(c, "cpimg", withDockerfile(` |
|
| 468 |
+ buildImageSuccessfully(c, "cpimg", build.WithDockerfile(` |
|
| 469 | 469 |
FROM busybox |
| 470 | 470 |
RUN echo HI > /file`)) |
| 471 | 471 |
id := getIDByName(c, "cpimg") |
| ... | ... |
@@ -598,7 +599,7 @@ func (s *DockerSuite) TestEventsFilterType(c *check.C) {
|
| 598 | 598 |
label := "io.docker.testing=image" |
| 599 | 599 |
|
| 600 | 600 |
// Build a test image. |
| 601 |
- buildImageSuccessfully(c, name, withDockerfile(fmt.Sprintf(` |
|
| 601 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf(` |
|
| 602 | 602 |
FROM busybox:latest |
| 603 | 603 |
LABEL %s`, label))) |
| 604 | 604 |
dockerCmd(c, "tag", name, "labelfiltertest:tag1") |
| ... | ... |
@@ -15,6 +15,7 @@ import ( |
| 15 | 15 |
"unicode" |
| 16 | 16 |
|
| 17 | 17 |
"github.com/docker/docker/integration-cli/checker" |
| 18 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 18 | 19 |
"github.com/go-check/check" |
| 19 | 20 |
"github.com/kr/pty" |
| 20 | 21 |
) |
| ... | ... |
@@ -111,7 +112,7 @@ func (s *DockerSuite) TestEventsOOMDisableTrue(c *check.C) {
|
| 111 | 111 |
case <-time.After(20 * time.Second): |
| 112 | 112 |
observer.CheckEventError(c, containerID, "oom", matcher) |
| 113 | 113 |
case <-testActions["oom"]: |
| 114 |
- // ignore, done |
|
| 114 |
+ // ignore, done |
|
| 115 | 115 |
case errRun := <-errChan: |
| 116 | 116 |
if errRun != nil {
|
| 117 | 117 |
c.Fatalf("%v", errRun)
|
| ... | ... |
@@ -310,7 +311,7 @@ func (s *DockerSuite) TestEventsImageUntagDelete(c *check.C) {
|
| 310 | 310 |
defer observer.Stop() |
| 311 | 311 |
|
| 312 | 312 |
name := "testimageevents" |
| 313 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM scratch |
|
| 313 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM scratch |
|
| 314 | 314 |
MAINTAINER "docker"`)) |
| 315 | 315 |
imageID := getIDByName(c, name) |
| 316 | 316 |
c.Assert(deleteImages(name), checker.IsNil) |
| ... | ... |
@@ -16,6 +16,7 @@ import ( |
| 16 | 16 |
"time" |
| 17 | 17 |
|
| 18 | 18 |
"github.com/docker/docker/integration-cli/checker" |
| 19 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 19 | 20 |
"github.com/docker/docker/integration-cli/request" |
| 20 | 21 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 21 | 22 |
"github.com/go-check/check" |
| ... | ... |
@@ -470,7 +471,7 @@ func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
|
| 470 | 470 |
// Not applicable on Windows |
| 471 | 471 |
testRequires(c, DaemonIsLinux) |
| 472 | 472 |
name := "testbuilduser" |
| 473 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 473 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 474 | 474 |
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd |
| 475 | 475 |
USER dockerio`)) |
| 476 | 476 |
dockerCmd(c, "run", "-d", "--name", "dockerioexec", name, "top") |
| ... | ... |
@@ -2,13 +2,13 @@ package main |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 |
- |
|
| 6 | 5 |
"strconv" |
| 7 | 6 |
"strings" |
| 8 | 7 |
"time" |
| 9 | 8 |
|
| 10 | 9 |
"github.com/docker/docker/api/types" |
| 11 | 10 |
"github.com/docker/docker/integration-cli/checker" |
| 11 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 12 | 12 |
"github.com/go-check/check" |
| 13 | 13 |
) |
| 14 | 14 |
|
| ... | ... |
@@ -40,7 +40,7 @@ func (s *DockerSuite) TestHealth(c *check.C) {
|
| 40 | 40 |
testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows |
| 41 | 41 |
|
| 42 | 42 |
imageName := "testhealth" |
| 43 |
- buildImageSuccessfully(c, imageName, withDockerfile(`FROM busybox |
|
| 43 |
+ buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox |
|
| 44 | 44 |
RUN echo OK > /status |
| 45 | 45 |
CMD ["/bin/sleep", "120"] |
| 46 | 46 |
STOPSIGNAL SIGKILL |
| ... | ... |
@@ -55,10 +55,7 @@ func (s *DockerSuite) TestHealth(c *check.C) {
|
| 55 | 55 |
|
| 56 | 56 |
// Inspect the options |
| 57 | 57 |
out, _ = dockerCmd(c, "inspect", |
| 58 |
- "--format=timeout={{.Config.Healthcheck.Timeout}} "+
|
|
| 59 |
- "interval={{.Config.Healthcheck.Interval}} "+
|
|
| 60 |
- "retries={{.Config.Healthcheck.Retries}} "+
|
|
| 61 |
- "test={{.Config.Healthcheck.Test}}", name)
|
|
| 58 |
+ "--format=timeout={{.Config.Healthcheck.Timeout}} interval={{.Config.Healthcheck.Interval}} retries={{.Config.Healthcheck.Retries}} test={{.Config.Healthcheck.Test}}", name)
|
|
| 62 | 59 |
c.Check(out, checker.Equals, "timeout=30s interval=1s retries=0 test=[CMD-SHELL cat /status]\n") |
| 63 | 60 |
|
| 64 | 61 |
// Start |
| ... | ... |
@@ -87,7 +84,7 @@ func (s *DockerSuite) TestHealth(c *check.C) {
|
| 87 | 87 |
dockerCmd(c, "rm", "noh") |
| 88 | 88 |
|
| 89 | 89 |
// Disable the check with a new build |
| 90 |
- buildImageSuccessfully(c, "no_healthcheck", withDockerfile(`FROM testhealth |
|
| 90 |
+ buildImageSuccessfully(c, "no_healthcheck", build.WithDockerfile(`FROM testhealth |
|
| 91 | 91 |
HEALTHCHECK NONE`)) |
| 92 | 92 |
|
| 93 | 93 |
out, _ = dockerCmd(c, "inspect", "--format={{.ContainerConfig.Healthcheck.Test}}", "no_healthcheck")
|
| ... | ... |
@@ -131,7 +128,7 @@ func (s *DockerSuite) TestHealth(c *check.C) {
|
| 131 | 131 |
dockerCmd(c, "rm", "-f", "test") |
| 132 | 132 |
|
| 133 | 133 |
// Check JSON-format |
| 134 |
- buildImageSuccessfully(c, imageName, withDockerfile(`FROM busybox |
|
| 134 |
+ buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox |
|
| 135 | 135 |
RUN echo OK > /status |
| 136 | 136 |
CMD ["/bin/sleep", "120"] |
| 137 | 137 |
STOPSIGNAL SIGKILL |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/docker/docker/integration-cli/checker" |
| 10 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 10 | 11 |
"github.com/go-check/check" |
| 11 | 12 |
) |
| 12 | 13 |
|
| ... | ... |
@@ -14,7 +15,7 @@ import ( |
| 14 | 14 |
// sort is not predictable it doesn't always fail. |
| 15 | 15 |
func (s *DockerSuite) TestBuildHistory(c *check.C) {
|
| 16 | 16 |
name := "testbuildhistory" |
| 17 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 17 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 18 | 18 |
LABEL label.A="A" |
| 19 | 19 |
LABEL label.B="B" |
| 20 | 20 |
LABEL label.C="C" |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/docker/docker/integration-cli/checker" |
| 14 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 14 | 15 |
"github.com/docker/docker/pkg/stringid" |
| 15 | 16 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 16 | 17 |
"github.com/go-check/check" |
| ... | ... |
@@ -46,15 +47,15 @@ func (s *DockerSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *check.C) {
|
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 | 48 |
func (s *DockerSuite) TestImagesOrderedByCreationDate(c *check.C) {
|
| 49 |
- buildImageSuccessfully(c, "order:test_a", withDockerfile(`FROM busybox |
|
| 49 |
+ buildImageSuccessfully(c, "order:test_a", build.WithDockerfile(`FROM busybox |
|
| 50 | 50 |
MAINTAINER dockerio1`)) |
| 51 | 51 |
id1 := getIDByName(c, "order:test_a") |
| 52 | 52 |
time.Sleep(1 * time.Second) |
| 53 |
- buildImageSuccessfully(c, "order:test_c", withDockerfile(`FROM busybox |
|
| 53 |
+ buildImageSuccessfully(c, "order:test_c", build.WithDockerfile(`FROM busybox |
|
| 54 | 54 |
MAINTAINER dockerio2`)) |
| 55 | 55 |
id2 := getIDByName(c, "order:test_c") |
| 56 | 56 |
time.Sleep(1 * time.Second) |
| 57 |
- buildImageSuccessfully(c, "order:test_b", withDockerfile(`FROM busybox |
|
| 57 |
+ buildImageSuccessfully(c, "order:test_b", build.WithDockerfile(`FROM busybox |
|
| 58 | 58 |
MAINTAINER dockerio3`)) |
| 59 | 59 |
id3 := getIDByName(c, "order:test_b") |
| 60 | 60 |
|
| ... | ... |
@@ -75,15 +76,15 @@ func (s *DockerSuite) TestImagesFilterLabelMatch(c *check.C) {
|
| 75 | 75 |
imageName1 := "images_filter_test1" |
| 76 | 76 |
imageName2 := "images_filter_test2" |
| 77 | 77 |
imageName3 := "images_filter_test3" |
| 78 |
- buildImageSuccessfully(c, imageName1, withDockerfile(`FROM busybox |
|
| 78 |
+ buildImageSuccessfully(c, imageName1, build.WithDockerfile(`FROM busybox |
|
| 79 | 79 |
LABEL match me`)) |
| 80 | 80 |
image1ID := getIDByName(c, imageName1) |
| 81 | 81 |
|
| 82 |
- buildImageSuccessfully(c, imageName2, withDockerfile(`FROM busybox |
|
| 82 |
+ buildImageSuccessfully(c, imageName2, build.WithDockerfile(`FROM busybox |
|
| 83 | 83 |
LABEL match="me too"`)) |
| 84 | 84 |
image2ID := getIDByName(c, imageName2) |
| 85 | 85 |
|
| 86 |
- buildImageSuccessfully(c, imageName3, withDockerfile(`FROM busybox |
|
| 86 |
+ buildImageSuccessfully(c, imageName3, build.WithDockerfile(`FROM busybox |
|
| 87 | 87 |
LABEL nomatch me`)) |
| 88 | 88 |
image3ID := getIDByName(c, imageName3) |
| 89 | 89 |
|
| ... | ... |
@@ -112,13 +113,13 @@ func (s *DockerSuite) TestImagesFilterLabelWithCommit(c *check.C) {
|
| 112 | 112 |
} |
| 113 | 113 |
|
| 114 | 114 |
func (s *DockerSuite) TestImagesFilterSinceAndBefore(c *check.C) {
|
| 115 |
- buildImageSuccessfully(c, "image:1", withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 115 |
+ buildImageSuccessfully(c, "image:1", build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 116 | 116 |
LABEL number=1`)) |
| 117 | 117 |
imageID1 := getIDByName(c, "image:1") |
| 118 |
- buildImageSuccessfully(c, "image:2", withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 118 |
+ buildImageSuccessfully(c, "image:2", build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 119 | 119 |
LABEL number=2`)) |
| 120 | 120 |
imageID2 := getIDByName(c, "image:2") |
| 121 |
- buildImageSuccessfully(c, "image:3", withDockerfile(`FROM `+minimalBaseImage()+` |
|
| 121 |
+ buildImageSuccessfully(c, "image:3", build.WithDockerfile(`FROM `+minimalBaseImage()+` |
|
| 122 | 122 |
LABEL number=3`)) |
| 123 | 123 |
imageID3 := getIDByName(c, "image:3") |
| 124 | 124 |
|
| ... | ... |
@@ -184,7 +185,7 @@ func assertImageList(out string, expected []string) bool {
|
| 184 | 184 |
func (s *DockerSuite) TestImagesFilterSpaceTrimCase(c *check.C) {
|
| 185 | 185 |
imageName := "images_filter_test" |
| 186 | 186 |
// Build a image and fail to build so that we have dangling images ? |
| 187 |
- buildImage(imageName, withDockerfile(`FROM busybox |
|
| 187 |
+ buildImage(imageName, build.WithDockerfile(`FROM busybox |
|
| 188 | 188 |
RUN touch /test/foo |
| 189 | 189 |
RUN touch /test/bar |
| 190 | 190 |
RUN touch /test/baz`)).Assert(c, icmd.Expected{
|
| ... | ... |
@@ -261,7 +262,7 @@ func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *check.C) {
|
| 261 | 261 |
MAINTAINER docker |
| 262 | 262 |
ENV foo bar` |
| 263 | 263 |
name := "scratch-image" |
| 264 |
- result := buildImage(name, withDockerfile(dockerfile)) |
|
| 264 |
+ result := buildImage(name, build.WithDockerfile(dockerfile)) |
|
| 265 | 265 |
result.Assert(c, icmd.Success) |
| 266 | 266 |
id := getIDByName(c, name) |
| 267 | 267 |
|
| ... | ... |
@@ -285,7 +286,7 @@ func (s *DockerSuite) TestImagesEnsureImagesFromScratchShown(c *check.C) {
|
| 285 | 285 |
MAINTAINER docker` |
| 286 | 286 |
|
| 287 | 287 |
name := "scratch-image" |
| 288 |
- buildImageSuccessfully(c, name, withDockerfile(dockerfile)) |
|
| 288 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerfile)) |
|
| 289 | 289 |
id := getIDByName(c, name) |
| 290 | 290 |
|
| 291 | 291 |
out, _ := dockerCmd(c, "images") |
| ... | ... |
@@ -301,7 +302,7 @@ func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *check.C) {
|
| 301 | 301 |
MAINTAINER docker` |
| 302 | 302 |
name := "busybox-image" |
| 303 | 303 |
|
| 304 |
- buildImageSuccessfully(c, name, withDockerfile(dockerfile)) |
|
| 304 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerfile)) |
|
| 305 | 305 |
id := getIDByName(c, name) |
| 306 | 306 |
|
| 307 | 307 |
out, _ := dockerCmd(c, "images") |
| ... | ... |
@@ -38,16 +38,6 @@ func getExternalAddress(c *check.C) net.IP {
|
| 38 | 38 |
return ifaceIP |
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
-func getContainerLogs(c *check.C, containerID string) string {
|
|
| 42 |
- out, _ := dockerCmd(c, "logs", containerID) |
|
| 43 |
- return strings.Trim(out, "\r\n") |
|
| 44 |
-} |
|
| 45 |
- |
|
| 46 |
-func getContainerStatus(c *check.C, containerID string) string {
|
|
| 47 |
- out := inspectField(c, containerID, "State.Running") |
|
| 48 |
- return out |
|
| 49 |
-} |
|
| 50 |
- |
|
| 51 | 41 |
func (s *DockerSuite) TestNetworkNat(c *check.C) {
|
| 52 | 42 |
testRequires(c, DaemonIsLinux, SameHostDaemon) |
| 53 | 43 |
msg := "it works" |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/docker/docker/integration-cli/checker" |
| 14 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 14 | 15 |
"github.com/docker/docker/pkg/stringid" |
| 15 | 16 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 16 | 17 |
"github.com/go-check/check" |
| ... | ... |
@@ -305,17 +306,17 @@ func (s *DockerSuite) TestPsListContainersFilterName(c *check.C) {
|
| 305 | 305 |
func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *check.C) {
|
| 306 | 306 |
// Build images |
| 307 | 307 |
imageName1 := "images_ps_filter_test1" |
| 308 |
- buildImageSuccessfully(c, imageName1, withDockerfile(`FROM busybox |
|
| 308 |
+ buildImageSuccessfully(c, imageName1, build.WithDockerfile(`FROM busybox |
|
| 309 | 309 |
LABEL match me 1`)) |
| 310 | 310 |
imageID1 := getIDByName(c, imageName1) |
| 311 | 311 |
|
| 312 | 312 |
imageName1Tagged := "images_ps_filter_test1:tag" |
| 313 |
- buildImageSuccessfully(c, imageName1Tagged, withDockerfile(`FROM busybox |
|
| 313 |
+ buildImageSuccessfully(c, imageName1Tagged, build.WithDockerfile(`FROM busybox |
|
| 314 | 314 |
LABEL match me 1 tagged`)) |
| 315 | 315 |
imageID1Tagged := getIDByName(c, imageName1Tagged) |
| 316 | 316 |
|
| 317 | 317 |
imageName2 := "images_ps_filter_test2" |
| 318 |
- buildImageSuccessfully(c, imageName2, withDockerfile(fmt.Sprintf(`FROM %s |
|
| 318 |
+ buildImageSuccessfully(c, imageName2, build.WithDockerfile(fmt.Sprintf(`FROM %s |
|
| 319 | 319 |
LABEL match me 2`, imageName1))) |
| 320 | 320 |
imageID2 := getIDByName(c, imageName2) |
| 321 | 321 |
|
| ... | ... |
@@ -14,6 +14,7 @@ import ( |
| 14 | 14 |
"github.com/docker/distribution/manifest/manifestlist" |
| 15 | 15 |
"github.com/docker/distribution/manifest/schema2" |
| 16 | 16 |
"github.com/docker/docker/integration-cli/checker" |
| 17 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 17 | 18 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 18 | 19 |
"github.com/go-check/check" |
| 19 | 20 |
"github.com/opencontainers/go-digest" |
| ... | ... |
@@ -65,7 +66,7 @@ func testConcurrentPullWholeRepo(c *check.C) {
|
| 65 | 65 |
repos := []string{}
|
| 66 | 66 |
for _, tag := range []string{"recent", "fresh", "todays"} {
|
| 67 | 67 |
repo := fmt.Sprintf("%v:%v", repoName, tag)
|
| 68 |
- buildImageSuccessfully(c, repo, withDockerfile(fmt.Sprintf(` |
|
| 68 |
+ buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(` |
|
| 69 | 69 |
FROM busybox |
| 70 | 70 |
ENTRYPOINT ["/bin/echo"] |
| 71 | 71 |
ENV FOO foo |
| ... | ... |
@@ -153,7 +154,7 @@ func testConcurrentPullMultipleTags(c *check.C) {
|
| 153 | 153 |
repos := []string{}
|
| 154 | 154 |
for _, tag := range []string{"recent", "fresh", "todays"} {
|
| 155 | 155 |
repo := fmt.Sprintf("%v:%v", repoName, tag)
|
| 156 |
- buildImageSuccessfully(c, repo, withDockerfile(fmt.Sprintf(` |
|
| 156 |
+ buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(` |
|
| 157 | 157 |
FROM busybox |
| 158 | 158 |
ENTRYPOINT ["/bin/echo"] |
| 159 | 159 |
ENV FOO foo |
| ... | ... |
@@ -207,7 +208,7 @@ func testPullIDStability(c *check.C) {
|
| 207 | 207 |
derivedImage := privateRegistryURL + "/dockercli/id-stability" |
| 208 | 208 |
baseImage := "busybox" |
| 209 | 209 |
|
| 210 |
- buildImageSuccessfully(c, derivedImage, withDockerfile(fmt.Sprintf(` |
|
| 210 |
+ buildImageSuccessfully(c, derivedImage, build.WithDockerfile(fmt.Sprintf(` |
|
| 211 | 211 |
FROM %s |
| 212 | 212 |
ENV derived true |
| 213 | 213 |
ENV asdf true |
| ... | ... |
@@ -266,7 +267,7 @@ func (s *DockerSchema1RegistrySuite) TestPullIDStability(c *check.C) {
|
| 266 | 266 |
func testPullNoLayers(c *check.C) {
|
| 267 | 267 |
repoName := fmt.Sprintf("%v/dockercli/scratch", privateRegistryURL)
|
| 268 | 268 |
|
| 269 |
- buildImageSuccessfully(c, repoName, withDockerfile(` |
|
| 269 |
+ buildImageSuccessfully(c, repoName, build.WithDockerfile(` |
|
| 270 | 270 |
FROM scratch |
| 271 | 271 |
ENV foo bar`)) |
| 272 | 272 |
dockerCmd(c, "push", repoName) |
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/integration-cli/checker" |
| 9 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 9 | 10 |
"github.com/docker/docker/pkg/testutil" |
| 10 | 11 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 11 | 12 |
"github.com/go-check/check" |
| ... | ... |
@@ -149,7 +150,7 @@ func (s *DockerTrustSuite) TestTrustedOfflinePull(c *check.C) {
|
| 149 | 149 |
func (s *DockerTrustSuite) TestTrustedPullDelete(c *check.C) {
|
| 150 | 150 |
repoName := fmt.Sprintf("%v/dockercli/%s:latest", privateRegistryURL, "trusted-pull-delete")
|
| 151 | 151 |
// tag the image and upload it to the private registry |
| 152 |
- buildImageSuccessfully(c, repoName, withDockerfile(` |
|
| 152 |
+ buildImageSuccessfully(c, repoName, build.WithDockerfile(` |
|
| 153 | 153 |
FROM busybox |
| 154 | 154 |
CMD echo trustedpulldelete |
| 155 | 155 |
`)) |
| ... | ... |
@@ -15,6 +15,7 @@ import ( |
| 15 | 15 |
"github.com/docker/distribution/reference" |
| 16 | 16 |
cliconfig "github.com/docker/docker/cli/config" |
| 17 | 17 |
"github.com/docker/docker/integration-cli/checker" |
| 18 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 18 | 19 |
"github.com/docker/docker/pkg/testutil" |
| 19 | 20 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 20 | 21 |
"github.com/go-check/check" |
| ... | ... |
@@ -161,7 +162,7 @@ func testConcurrentPush(c *check.C) {
|
| 161 | 161 |
repos := []string{}
|
| 162 | 162 |
for _, tag := range []string{"push1", "push2", "push3"} {
|
| 163 | 163 |
repo := fmt.Sprintf("%v:%v", repoName, tag)
|
| 164 |
- buildImageSuccessfully(c, repo, withDockerfile(fmt.Sprintf(` |
|
| 164 |
+ buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(` |
|
| 165 | 165 |
FROM busybox |
| 166 | 166 |
ENTRYPOINT ["/bin/echo"] |
| 167 | 167 |
ENV FOO foo |
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"os" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/docker/docker/integration-cli/checker" |
| 8 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 8 | 9 |
"github.com/go-check/check" |
| 9 | 10 |
) |
| 10 | 11 |
|
| ... | ... |
@@ -60,12 +61,12 @@ func (s *DockerSuite) TestRmContainerOrphaning(c *check.C) {
|
| 60 | 60 |
MAINTAINER Integration Tests` |
| 61 | 61 |
|
| 62 | 62 |
// build first dockerfile |
| 63 |
- buildImageSuccessfully(c, img, withDockerfile(dockerfile1)) |
|
| 63 |
+ buildImageSuccessfully(c, img, build.WithDockerfile(dockerfile1)) |
|
| 64 | 64 |
img1 := getIDByName(c, img) |
| 65 | 65 |
// run container on first image |
| 66 | 66 |
dockerCmd(c, "run", img) |
| 67 | 67 |
// rebuild dockerfile with a small addition at the end |
| 68 |
- buildImageSuccessfully(c, img, withDockerfile(dockerfile2)) |
|
| 68 |
+ buildImageSuccessfully(c, img, build.WithDockerfile(dockerfile2)) |
|
| 69 | 69 |
// try to remove the image, should not error out. |
| 70 | 70 |
out, _, err := dockerCmdWithError("rmi", img)
|
| 71 | 71 |
c.Assert(err, check.IsNil, check.Commentf("Expected to removing the image, but failed: %s", out))
|
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/integration-cli/checker" |
| 9 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 9 | 10 |
"github.com/docker/docker/pkg/stringid" |
| 10 | 11 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 11 | 12 |
"github.com/go-check/check" |
| ... | ... |
@@ -147,7 +148,7 @@ func (s *DockerSuite) TestRmiImgIDForce(c *check.C) {
|
| 147 | 147 |
// See https://github.com/docker/docker/issues/14116 |
| 148 | 148 |
func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c *check.C) {
|
| 149 | 149 |
dockerfile := "FROM busybox\nRUN echo test 14116\n" |
| 150 |
- buildImageSuccessfully(c, "test-14116", withDockerfile(dockerfile)) |
|
| 150 |
+ buildImageSuccessfully(c, "test-14116", build.WithDockerfile(dockerfile)) |
|
| 151 | 151 |
imgID := getIDByName(c, "test-14116") |
| 152 | 152 |
|
| 153 | 153 |
newTag := "newtag" |
| ... | ... |
@@ -205,7 +206,7 @@ func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *check.C) {
|
| 205 | 205 |
tag1 := imageName + ":tag1" |
| 206 | 206 |
tag2 := imageName + ":tag2" |
| 207 | 207 |
|
| 208 |
- buildImageSuccessfully(c, tag1, withDockerfile(`FROM busybox |
|
| 208 |
+ buildImageSuccessfully(c, tag1, build.WithDockerfile(`FROM busybox |
|
| 209 | 209 |
MAINTAINER "docker"`)) |
| 210 | 210 |
dockerCmd(c, "tag", tag1, tag2) |
| 211 | 211 |
|
| ... | ... |
@@ -234,7 +235,7 @@ func (s *DockerSuite) TestRmiContainerImageNotFound(c *check.C) {
|
| 234 | 234 |
imageIds := make([]string, 2) |
| 235 | 235 |
for i, name := range imageNames {
|
| 236 | 236 |
dockerfile := fmt.Sprintf("FROM busybox\nMAINTAINER %s\nRUN echo %s\n", name, name)
|
| 237 |
- buildImageSuccessfully(c, name, withoutCache, withDockerfile(dockerfile)) |
|
| 237 |
+ buildImageSuccessfully(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
|
| 238 | 238 |
id := getIDByName(c, name) |
| 239 | 239 |
imageIds[i] = id |
| 240 | 240 |
} |
| ... | ... |
@@ -263,7 +264,7 @@ RUN echo 0 #layer0 |
| 263 | 263 |
RUN echo 1 #layer1 |
| 264 | 264 |
RUN echo 2 #layer2 |
| 265 | 265 |
` |
| 266 |
- buildImageSuccessfully(c, image, withoutCache, withDockerfile(dockerfile)) |
|
| 266 |
+ buildImageSuccessfully(c, image, build.WithoutCache, build.WithDockerfile(dockerfile)) |
|
| 267 | 267 |
out, _ := dockerCmd(c, "history", "-q", image) |
| 268 | 268 |
ids := strings.Split(out, "\n") |
| 269 | 269 |
idToTag := ids[2] |
| ... | ... |
@@ -299,7 +300,7 @@ RUN echo 2 #layer2 |
| 299 | 299 |
} |
| 300 | 300 |
|
| 301 | 301 |
func (*DockerSuite) TestRmiParentImageFail(c *check.C) {
|
| 302 |
- buildImageSuccessfully(c, "test", withDockerfile(` |
|
| 302 |
+ buildImageSuccessfully(c, "test", build.WithDockerfile(` |
|
| 303 | 303 |
FROM busybox |
| 304 | 304 |
RUN echo hello`)) |
| 305 | 305 |
|
| ... | ... |
@@ -22,6 +22,7 @@ import ( |
| 22 | 22 |
"time" |
| 23 | 23 |
|
| 24 | 24 |
"github.com/docker/docker/integration-cli/checker" |
| 25 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 25 | 26 |
"github.com/docker/docker/pkg/mount" |
| 26 | 27 |
"github.com/docker/docker/pkg/stringid" |
| 27 | 28 |
"github.com/docker/docker/pkg/stringutils" |
| ... | ... |
@@ -410,7 +411,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir(c *check.C) {
|
| 410 | 410 |
containerPath = "/test/test" |
| 411 | 411 |
cmd = "true" |
| 412 | 412 |
} |
| 413 |
- buildImageSuccessfully(c, name, withDockerfile(dockerFile)) |
|
| 413 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerFile)) |
|
| 414 | 414 |
dockerCmd(c, "run", "-v", containerPath, name, cmd) |
| 415 | 415 |
} |
| 416 | 416 |
|
| ... | ... |
@@ -435,7 +436,7 @@ func (s *DockerSuite) TestRunCreateVolumesInSymlinkDir2(c *check.C) {
|
| 435 | 435 |
containerPath = "/test/test" |
| 436 | 436 |
cmd = "true" |
| 437 | 437 |
} |
| 438 |
- buildImageSuccessfully(c, name, withDockerfile(dockerFile)) |
|
| 438 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(dockerFile)) |
|
| 439 | 439 |
dockerCmd(c, "run", "-v", containerPath, name, cmd) |
| 440 | 440 |
} |
| 441 | 441 |
|
| ... | ... |
@@ -1658,7 +1659,7 @@ func (s *DockerSuite) TestRunCopyVolumeUIDGID(c *check.C) {
|
| 1658 | 1658 |
// Not applicable on Windows as it does not support uid or gid in this way |
| 1659 | 1659 |
testRequires(c, DaemonIsLinux) |
| 1660 | 1660 |
name := "testrunvolumesuidgid" |
| 1661 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1661 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1662 | 1662 |
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd |
| 1663 | 1663 |
RUN echo 'dockerio:x:1001:' >> /etc/group |
| 1664 | 1664 |
RUN mkdir -p /hello && touch /hello/test && chown dockerio.dockerio /hello`)) |
| ... | ... |
@@ -1677,7 +1678,7 @@ func (s *DockerSuite) TestRunCopyVolumeContent(c *check.C) {
|
| 1677 | 1677 |
// that copies from the image to the volume. |
| 1678 | 1678 |
testRequires(c, DaemonIsLinux) |
| 1679 | 1679 |
name := "testruncopyvolumecontent" |
| 1680 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1680 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1681 | 1681 |
RUN mkdir -p /hello/local && echo hello > /hello/local/world`)) |
| 1682 | 1682 |
|
| 1683 | 1683 |
// Test that the content is copied from the image to the volume |
| ... | ... |
@@ -1689,7 +1690,7 @@ func (s *DockerSuite) TestRunCopyVolumeContent(c *check.C) {
|
| 1689 | 1689 |
|
| 1690 | 1690 |
func (s *DockerSuite) TestRunCleanupCmdOnEntrypoint(c *check.C) {
|
| 1691 | 1691 |
name := "testrunmdcleanuponentrypoint" |
| 1692 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 1692 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 1693 | 1693 |
ENTRYPOINT ["echo"] |
| 1694 | 1694 |
CMD ["testingpoint"]`)) |
| 1695 | 1695 |
|
| ... | ... |
@@ -2173,7 +2174,7 @@ func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) {
|
| 2173 | 2173 |
// are pre-populated such as is built in the dockerfile used in this test. |
| 2174 | 2174 |
testRequires(c, DaemonIsLinux) |
| 2175 | 2175 |
prefix, slash := getPrefixAndSlashFromDaemonPlatform() |
| 2176 |
- buildImageSuccessfully(c, "dataimage", withDockerfile(`FROM busybox |
|
| 2176 |
+ buildImageSuccessfully(c, "dataimage", build.WithDockerfile(`FROM busybox |
|
| 2177 | 2177 |
RUN ["mkdir", "-p", "/foo"] |
| 2178 | 2178 |
RUN ["touch", "/foo/bar"]`)) |
| 2179 | 2179 |
dockerCmd(c, "run", "--name", "test", "-v", prefix+slash+"foo", "busybox") |
| ... | ... |
@@ -2204,7 +2205,7 @@ func (s *DockerSuite) TestRunNoOutputFromPullInStdout(c *check.C) {
|
| 2204 | 2204 |
func (s *DockerSuite) TestRunVolumesCleanPaths(c *check.C) {
|
| 2205 | 2205 |
testRequires(c, SameHostDaemon) |
| 2206 | 2206 |
prefix, slash := getPrefixAndSlashFromDaemonPlatform() |
| 2207 |
- buildImageSuccessfully(c, "run_volumes_clean_paths", withDockerfile(`FROM busybox |
|
| 2207 |
+ buildImageSuccessfully(c, "run_volumes_clean_paths", build.WithDockerfile(`FROM busybox |
|
| 2208 | 2208 |
VOLUME `+prefix+`/foo/`)) |
| 2209 | 2209 |
dockerCmd(c, "run", "-v", prefix+"/foo", "-v", prefix+"/bar/", "--name", "dark_helmet", "run_volumes_clean_paths") |
| 2210 | 2210 |
|
| ... | ... |
@@ -3843,7 +3844,7 @@ func (s *DockerSuite) TestRunInitLayerPathOwnership(c *check.C) {
|
| 3843 | 3843 |
// Not applicable on Windows as it does not support Linux uid/gid ownership |
| 3844 | 3844 |
testRequires(c, DaemonIsLinux) |
| 3845 | 3845 |
name := "testetcfileownership" |
| 3846 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 3846 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 3847 | 3847 |
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd |
| 3848 | 3848 |
RUN echo 'dockerio:x:1001:' >> /etc/group |
| 3849 | 3849 |
RUN chown dockerio:dockerio /etc`)) |
| ... | ... |
@@ -3975,7 +3976,7 @@ func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *check.C) {
|
| 3975 | 3975 |
testRequires(c, DaemonIsLinux) |
| 3976 | 3976 |
|
| 3977 | 3977 |
testImg := "testvolumecopy" |
| 3978 |
- buildImageSuccessfully(c, testImg, withDockerfile(` |
|
| 3978 |
+ buildImageSuccessfully(c, testImg, build.WithDockerfile(` |
|
| 3979 | 3979 |
FROM busybox |
| 3980 | 3980 |
RUN mkdir -p /foo && echo hello > /foo/hello |
| 3981 | 3981 |
`)) |
| ... | ... |
@@ -4054,7 +4055,7 @@ func (s *DockerSuite) TestRunVolumeWithOneCharacter(c *check.C) {
|
| 4054 | 4054 |
|
| 4055 | 4055 |
func (s *DockerSuite) TestRunVolumeCopyFlag(c *check.C) {
|
| 4056 | 4056 |
testRequires(c, DaemonIsLinux) // Windows does not support copying data from image to the volume |
| 4057 |
- buildImageSuccessfully(c, "volumecopy", withDockerfile(`FROM busybox |
|
| 4057 |
+ buildImageSuccessfully(c, "volumecopy", build.WithDockerfile(`FROM busybox |
|
| 4058 | 4058 |
RUN mkdir /foo && echo hello > /foo/bar |
| 4059 | 4059 |
CMD cat /foo/bar`)) |
| 4060 | 4060 |
dockerCmd(c, "volume", "create", "test") |
| ... | ... |
@@ -17,6 +17,7 @@ import ( |
| 17 | 17 |
"time" |
| 18 | 18 |
|
| 19 | 19 |
"github.com/docker/docker/integration-cli/checker" |
| 20 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 20 | 21 |
"github.com/docker/docker/pkg/homedir" |
| 21 | 22 |
"github.com/docker/docker/pkg/mount" |
| 22 | 23 |
"github.com/docker/docker/pkg/parsers" |
| ... | ... |
@@ -828,7 +829,7 @@ func (s *DockerSuite) TestRunTmpfsMounts(c *check.C) {
|
| 828 | 828 |
|
| 829 | 829 |
func (s *DockerSuite) TestRunTmpfsMountsOverrideImageVolumes(c *check.C) {
|
| 830 | 830 |
name := "img-with-volumes" |
| 831 |
- buildImageSuccessfully(c, name, withDockerfile(` |
|
| 831 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(` |
|
| 832 | 832 |
FROM busybox |
| 833 | 833 |
VOLUME /run |
| 834 | 834 |
RUN touch /run/stuff |
| ... | ... |
@@ -14,6 +14,7 @@ import ( |
| 14 | 14 |
"time" |
| 15 | 15 |
|
| 16 | 16 |
"github.com/docker/docker/integration-cli/checker" |
| 17 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 17 | 18 |
"github.com/docker/docker/pkg/testutil" |
| 18 | 19 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 19 | 20 |
"github.com/go-check/check" |
| ... | ... |
@@ -265,7 +266,7 @@ func (s *DockerSuite) TestSaveDirectoryPermissions(c *check.C) {
|
| 265 | 265 |
os.Mkdir(extractionDirectory, 0777) |
| 266 | 266 |
|
| 267 | 267 |
defer os.RemoveAll(tmpDir) |
| 268 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 268 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 269 | 269 |
RUN adduser -D user && mkdir -p /opt/a/b && chown -R user:user /opt/a |
| 270 | 270 |
RUN touch /opt/a/b/c && chown user:user /opt/a/b/c`)) |
| 271 | 271 |
|
| ... | ... |
@@ -360,7 +361,7 @@ func (s *DockerSuite) TestSaveLoadNoTag(c *check.C) {
|
| 360 | 360 |
|
| 361 | 361 |
name := "saveloadnotag" |
| 362 | 362 |
|
| 363 |
- buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nENV foo=bar"))
|
|
| 363 |
+ buildImageSuccessfully(c, name, build.WithDockerfile("FROM busybox\nENV foo=bar"))
|
|
| 364 | 364 |
id := inspectField(c, name, "Id") |
| 365 | 365 |
|
| 366 | 366 |
// Test to make sure that save w/o name just shows imageID during load |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"time" |
| 13 | 13 |
|
| 14 | 14 |
"github.com/docker/docker/integration-cli/checker" |
| 15 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 15 | 16 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 16 | 17 |
"github.com/go-check/check" |
| 17 | 18 |
"github.com/kr/pty" |
| ... | ... |
@@ -71,7 +72,7 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *check.C) {
|
| 71 | 71 |
|
| 72 | 72 |
func (s *DockerSuite) TestSaveAndLoadWithProgressBar(c *check.C) {
|
| 73 | 73 |
name := "test-load" |
| 74 |
- buildImageSuccessfully(c, name, withDockerfile(`FROM busybox |
|
| 74 |
+ buildImageSuccessfully(c, name, build.WithDockerfile(`FROM busybox |
|
| 75 | 75 |
RUN touch aa |
| 76 | 76 |
`)) |
| 77 | 77 |
|
| ... | ... |
@@ -17,6 +17,7 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/api/types" |
| 18 | 18 |
"github.com/docker/docker/api/types/swarm" |
| 19 | 19 |
"github.com/docker/docker/integration-cli/checker" |
| 20 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 20 | 21 |
"github.com/docker/docker/integration-cli/daemon" |
| 21 | 22 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 22 | 23 |
"github.com/docker/libnetwork/driverapi" |
| ... | ... |
@@ -57,8 +58,8 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
|
| 57 | 57 |
return sw.Spec |
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 |
- out, err := d.Cmd("swarm", "init", "--cert-expiry", "30h", "--dispatcher-heartbeat", "11s")
|
|
| 61 |
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
|
| 60 |
+ cli.Docker(cli.Cmd("swarm", "init", "--cert-expiry", "30h", "--dispatcher-heartbeat", "11s"),
|
|
| 61 |
+ cli.Daemon(d.Daemon)).Assert(c, icmd.Success) |
|
| 62 | 62 |
|
| 63 | 63 |
spec := getSpec() |
| 64 | 64 |
c.Assert(spec.CAConfig.NodeCertExpiry, checker.Equals, 30*time.Hour) |
| ... | ... |
@@ -66,8 +67,7 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
|
| 66 | 66 |
|
| 67 | 67 |
c.Assert(d.Leave(true), checker.IsNil) |
| 68 | 68 |
time.Sleep(500 * time.Millisecond) // https://github.com/docker/swarmkit/issues/1421 |
| 69 |
- out, err = d.Cmd("swarm", "init")
|
|
| 70 |
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
|
| 69 |
+ cli.Docker(cli.Cmd("swarm", "init"), cli.Daemon(d.Daemon)).Assert(c, icmd.Success)
|
|
| 71 | 70 |
|
| 72 | 71 |
spec = getSpec() |
| 73 | 72 |
c.Assert(spec.CAConfig.NodeCertExpiry, checker.Equals, 90*24*time.Hour) |
| ... | ... |
@@ -77,15 +77,12 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
|
| 77 | 77 |
func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *check.C) {
|
| 78 | 78 |
testRequires(c, IPv6) |
| 79 | 79 |
d1 := s.AddDaemon(c, false, false) |
| 80 |
- out, err := d1.Cmd("swarm", "init", "--listen-addr", "::1")
|
|
| 81 |
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
|
| 80 |
+ cli.Docker(cli.Cmd("swarm", "init", "--listen-add", "::1"), cli.Daemon(d1.Daemon)).Assert(c, icmd.Success)
|
|
| 82 | 81 |
|
| 83 | 82 |
d2 := s.AddDaemon(c, false, false) |
| 84 |
- out, err = d2.Cmd("swarm", "join", "::1")
|
|
| 85 |
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
|
| 83 |
+ cli.Docker(cli.Cmd("swarm", "join", "::1"), cli.Daemon(d2.Daemon)).Assert(c, icmd.Success)
|
|
| 86 | 84 |
|
| 87 |
- out, err = d2.Cmd("info")
|
|
| 88 |
- c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
|
| 85 |
+ out := cli.Docker(cli.Cmd("info"), cli.Daemon(d2.Daemon)).Assert(c, icmd.Success).Combined()
|
|
| 89 | 86 |
c.Assert(out, checker.Contains, "Swarm: active") |
| 90 | 87 |
} |
| 91 | 88 |
|
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/docker/docker/integration-cli/checker" |
| 8 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 8 | 9 |
"github.com/docker/docker/pkg/stringid" |
| 9 | 10 |
"github.com/docker/docker/pkg/stringutils" |
| 10 | 11 |
"github.com/go-check/check" |
| ... | ... |
@@ -142,7 +143,7 @@ func (s *DockerSuite) TestTagInvalidRepoName(c *check.C) {
|
| 142 | 142 |
|
| 143 | 143 |
// ensure tags cannot create ambiguity with image ids |
| 144 | 144 |
func (s *DockerSuite) TestTagTruncationAmbiguity(c *check.C) {
|
| 145 |
- buildImageSuccessfully(c, "notbusybox:latest", withDockerfile(`FROM busybox |
|
| 145 |
+ buildImageSuccessfully(c, "notbusybox:latest", build.WithDockerfile(`FROM busybox |
|
| 146 | 146 |
MAINTAINER dockerio`)) |
| 147 | 147 |
imageID := getIDByName(c, "notbusybox:latest") |
| 148 | 148 |
truncatedImageID := stringid.TruncateID(imageID) |
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/docker/docker/integration-cli/checker" |
| 13 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 13 | 14 |
"github.com/docker/docker/integration-cli/request" |
| 14 | 15 |
icmd "github.com/docker/docker/pkg/testutil/cmd" |
| 15 | 16 |
"github.com/go-check/check" |
| ... | ... |
@@ -497,7 +498,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *check.C) {
|
| 497 | 497 |
testRequires(c, DaemonIsLinux) |
| 498 | 498 |
|
| 499 | 499 |
image := "vimage" |
| 500 |
- buildImageSuccessfully(c, image, withDockerfile(` |
|
| 500 |
+ buildImageSuccessfully(c, image, build.WithDockerfile(` |
|
| 501 | 501 |
FROM busybox |
| 502 | 502 |
VOLUME ["/tmp/data"]`)) |
| 503 | 503 |
|
| ... | ... |
@@ -539,7 +540,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *check.C) |
| 539 | 539 |
testRequires(c, DaemonIsLinux) |
| 540 | 540 |
|
| 541 | 541 |
image := "vimage" |
| 542 |
- buildImageSuccessfully(c, image, withDockerfile(` |
|
| 542 |
+ buildImageSuccessfully(c, image, build.WithDockerfile(` |
|
| 543 | 543 |
FROM busybox |
| 544 | 544 |
VOLUME ["/tmp/data"]`)) |
| 545 | 545 |
|
| ... | ... |
@@ -583,7 +584,7 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *check.C |
| 583 | 583 |
testRequires(c, SameHostDaemon, DaemonIsLinux) |
| 584 | 584 |
|
| 585 | 585 |
image := "vimage" |
| 586 |
- buildImageSuccessfully(c, image, withDockerfile(` |
|
| 586 |
+ buildImageSuccessfully(c, image, build.WithDockerfile(` |
|
| 587 | 587 |
FROM busybox |
| 588 | 588 |
VOLUME ["/tmp/data"]`)) |
| 589 | 589 |
|
| ... | ... |
@@ -21,6 +21,8 @@ import ( |
| 21 | 21 |
|
| 22 | 22 |
"github.com/docker/docker/api/types" |
| 23 | 23 |
"github.com/docker/docker/integration-cli/checker" |
| 24 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 25 |
+ "github.com/docker/docker/integration-cli/cli/build" |
|
| 24 | 26 |
"github.com/docker/docker/integration-cli/daemon" |
| 25 | 27 |
"github.com/docker/docker/integration-cli/registry" |
| 26 | 28 |
"github.com/docker/docker/integration-cli/request" |
| ... | ... |
@@ -351,7 +353,7 @@ func newRemoteFileServer(c *check.C, ctx *FakeContext) *remoteFileServer {
|
| 351 | 351 |
// Build the image |
| 352 | 352 |
fakeContextAddDockerfile(c, ctx, `FROM httpserver |
| 353 | 353 |
COPY . /static`) |
| 354 |
- buildImageSuccessfully(c, image, withoutCache, withExternalBuildContext(ctx)) |
|
| 354 |
+ buildImageSuccessfully(c, image, build.WithoutCache, withExternalBuildContext(ctx)) |
|
| 355 | 355 |
|
| 356 | 356 |
// Start the container |
| 357 | 357 |
dockerCmd(c, "run", "-d", "-P", "--name", container, image) |
| ... | ... |
@@ -484,26 +486,14 @@ func getIDByName(c *check.C, name string) string {
|
| 484 | 484 |
return id |
| 485 | 485 |
} |
| 486 | 486 |
|
| 487 |
-func buildImageSuccessfully(c *check.C, name string, cmdOperators ...func(*icmd.Cmd) func()) {
|
|
| 487 |
+// Deprecated: use cli.Build |
|
| 488 |
+func buildImageSuccessfully(c *check.C, name string, cmdOperators ...cli.CmdOperator) {
|
|
| 488 | 489 |
buildImage(name, cmdOperators...).Assert(c, icmd.Success) |
| 489 | 490 |
} |
| 490 | 491 |
|
| 491 |
-func buildImage(name string, cmdOperators ...func(*icmd.Cmd) func()) *icmd.Result {
|
|
| 492 |
- cmd := icmd.Command(dockerBinary, "build", "-t", name) |
|
| 493 |
- for _, op := range cmdOperators {
|
|
| 494 |
- deferFn := op(&cmd) |
|
| 495 |
- if deferFn != nil {
|
|
| 496 |
- defer deferFn() |
|
| 497 |
- } |
|
| 498 |
- } |
|
| 499 |
- return icmd.RunCmd(cmd) |
|
| 500 |
-} |
|
| 501 |
- |
|
| 502 |
-func withBuildContextPath(path string) func(*icmd.Cmd) func() {
|
|
| 503 |
- return func(cmd *icmd.Cmd) func() {
|
|
| 504 |
- cmd.Command = append(cmd.Command, path) |
|
| 505 |
- return nil |
|
| 506 |
- } |
|
| 492 |
+// Deprecated: use cli.Build |
|
| 493 |
+func buildImage(name string, cmdOperators ...cli.CmdOperator) *icmd.Result {
|
|
| 494 |
+ return cli.Docker(cli.Build(name), cmdOperators...) |
|
| 507 | 495 |
} |
| 508 | 496 |
|
| 509 | 497 |
func withExternalBuildContext(ctx *FakeContext) func(*icmd.Cmd) func() {
|
| ... | ... |
@@ -528,18 +518,6 @@ func withBuildContext(c *check.C, contextOperators ...func(*FakeContext) error) |
| 528 | 528 |
} |
| 529 | 529 |
} |
| 530 | 530 |
|
| 531 |
-func withBuildFlags(flags ...string) func(*icmd.Cmd) func() {
|
|
| 532 |
- return func(cmd *icmd.Cmd) func() {
|
|
| 533 |
- cmd.Command = append(cmd.Command, flags...) |
|
| 534 |
- return nil |
|
| 535 |
- } |
|
| 536 |
-} |
|
| 537 |
- |
|
| 538 |
-func withoutCache(cmd *icmd.Cmd) func() {
|
|
| 539 |
- cmd.Command = append(cmd.Command, "--no-cache") |
|
| 540 |
- return nil |
|
| 541 |
-} |
|
| 542 |
- |
|
| 543 | 531 |
func withFile(name, content string) func(*FakeContext) error {
|
| 544 | 532 |
return func(ctx *FakeContext) error {
|
| 545 | 533 |
return ctx.Add(name, content) |
| ... | ... |
@@ -554,26 +532,11 @@ func closeBuildContext(c *check.C, ctx *FakeContext) func() {
|
| 554 | 554 |
} |
| 555 | 555 |
} |
| 556 | 556 |
|
| 557 |
-func withDockerfile(dockerfile string) func(*icmd.Cmd) func() {
|
|
| 558 |
- return func(cmd *icmd.Cmd) func() {
|
|
| 559 |
- cmd.Command = append(cmd.Command, "-") |
|
| 560 |
- cmd.Stdin = strings.NewReader(dockerfile) |
|
| 561 |
- return nil |
|
| 562 |
- } |
|
| 563 |
-} |
|
| 564 |
- |
|
| 565 | 557 |
func trustedBuild(cmd *icmd.Cmd) func() {
|
| 566 | 558 |
trustedCmd(cmd) |
| 567 | 559 |
return nil |
| 568 | 560 |
} |
| 569 | 561 |
|
| 570 |
-func withEnvironmentVariales(envs ...string) func(cmd *icmd.Cmd) func() {
|
|
| 571 |
- return func(cmd *icmd.Cmd) func() {
|
|
| 572 |
- cmd.Env = envs |
|
| 573 |
- return nil |
|
| 574 |
- } |
|
| 575 |
-} |
|
| 576 |
- |
|
| 577 | 562 |
type gitServer interface {
|
| 578 | 563 |
URL() string |
| 579 | 564 |
Close() error |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"io/ioutil" |
| 6 | 6 |
"os" |
| 7 |
+ "os/exec" |
|
| 7 | 8 |
"path/filepath" |
| 8 | 9 |
"strconv" |
| 9 | 10 |
"strings" |
| ... | ... |
@@ -11,9 +12,15 @@ import ( |
| 11 | 11 |
"github.com/docker/docker/api/types" |
| 12 | 12 |
"github.com/docker/docker/api/types/container" |
| 13 | 13 |
"github.com/docker/docker/client" |
| 14 |
+ "github.com/docker/docker/opts" |
|
| 14 | 15 |
"golang.org/x/net/context" |
| 15 | 16 |
) |
| 16 | 17 |
|
| 18 |
+const ( |
|
| 19 |
+ // DefaultDockerBinary is the name of the docker binary |
|
| 20 |
+ DefaultDockerBinary = "docker" |
|
| 21 |
+) |
|
| 22 |
+ |
|
| 17 | 23 |
// Execution holds informations about the test execution environment. |
| 18 | 24 |
type Execution struct {
|
| 19 | 25 |
daemonPlatform string |
| ... | ... |
@@ -31,7 +38,8 @@ type Execution struct {
|
| 31 | 31 |
containerStoragePath string |
| 32 | 32 |
// baseImage is the name of the base image for testing |
| 33 | 33 |
// Environment variable WINDOWS_BASE_IMAGE can override this |
| 34 |
- baseImage string |
|
| 34 |
+ baseImage string |
|
| 35 |
+ dockerBinary string |
|
| 35 | 36 |
|
| 36 | 37 |
protectedElements protectedElements |
| 37 | 38 |
} |
| ... | ... |
@@ -90,6 +98,16 @@ func New() (*Execution, error) {
|
| 90 | 90 |
daemonPid = int(p) |
| 91 | 91 |
} |
| 92 | 92 |
} |
| 93 |
+ |
|
| 94 |
+ var dockerBinary = DefaultDockerBinary |
|
| 95 |
+ if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
|
|
| 96 |
+ dockerBinary = dockerBin |
|
| 97 |
+ } |
|
| 98 |
+ dockerBinary, err = exec.LookPath(dockerBinary) |
|
| 99 |
+ if err != nil {
|
|
| 100 |
+ return nil, err |
|
| 101 |
+ } |
|
| 102 |
+ |
|
| 93 | 103 |
return &Execution{
|
| 94 | 104 |
localDaemon: localDaemon, |
| 95 | 105 |
daemonPlatform: daemonPlatform, |
| ... | ... |
@@ -102,6 +120,7 @@ func New() (*Execution, error) {
|
| 102 | 102 |
daemonPid: daemonPid, |
| 103 | 103 |
experimentalDaemon: info.ExperimentalBuild, |
| 104 | 104 |
baseImage: baseImage, |
| 105 |
+ dockerBinary: dockerBinary, |
|
| 105 | 106 |
protectedElements: protectedElements{
|
| 106 | 107 |
images: map[string]struct{}{},
|
| 107 | 108 |
}, |
| ... | ... |
@@ -190,3 +209,17 @@ func (e *Execution) DaemonKernelVersionNumeric() int {
|
| 190 | 190 |
v, _ := strconv.Atoi(strings.Split(e.daemonKernelVersion, " ")[1]) |
| 191 | 191 |
return v |
| 192 | 192 |
} |
| 193 |
+ |
|
| 194 |
+// DockerBinary returns the docker binary for this testing environment |
|
| 195 |
+func (e *Execution) DockerBinary() string {
|
|
| 196 |
+ return e.dockerBinary |
|
| 197 |
+} |
|
| 198 |
+ |
|
| 199 |
+// DaemonHost return the daemon host string for this test execution |
|
| 200 |
+func DaemonHost() string {
|
|
| 201 |
+ daemonURLStr := "unix://" + opts.DefaultUnixSocket |
|
| 202 |
+ if daemonHostVar := os.Getenv("DOCKER_HOST"); daemonHostVar != "" {
|
|
| 203 |
+ daemonURLStr = daemonHostVar |
|
| 204 |
+ } |
|
| 205 |
+ return daemonURLStr |
|
| 206 |
+} |
| ... | ... |
@@ -54,10 +54,10 @@ type Result struct {
|
| 54 | 54 |
|
| 55 | 55 |
// Assert compares the Result against the Expected struct, and fails the test if |
| 56 | 56 |
// any of the expcetations are not met. |
| 57 |
-func (r *Result) Assert(t testingT, exp Expected) {
|
|
| 57 |
+func (r *Result) Assert(t testingT, exp Expected) *Result {
|
|
| 58 | 58 |
err := r.Compare(exp) |
| 59 | 59 |
if err == nil {
|
| 60 |
- return |
|
| 60 |
+ return r |
|
| 61 | 61 |
} |
| 62 | 62 |
_, file, line, ok := runtime.Caller(1) |
| 63 | 63 |
if ok {
|
| ... | ... |
@@ -65,6 +65,7 @@ func (r *Result) Assert(t testingT, exp Expected) {
|
| 65 | 65 |
} else {
|
| 66 | 66 |
t.Fatalf("(no file/line info) - %s", err.Error())
|
| 67 | 67 |
} |
| 68 |
+ return nil |
|
| 68 | 69 |
} |
| 69 | 70 |
|
| 70 | 71 |
// Compare returns a formatted error with the command, stdout, stderr, exit |