Files
docker-cli/components/engine/integration-cli/cli/build/build.go
allencloud d840f6fbf0 remove redundant comments in test build.go
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 32b81dae29fbb6f831cda5e9db1c120f78cd4a91
Component: engine
2017-03-27 10:59:13 +08:00

31 lines
742 B
Go

package build
import (
"strings"
icmd "github.com/docker/docker/pkg/testutil/cmd"
)
// WithDockerfile creates / returns a CmdOperator to set the Dockerfile for a build operation
func WithDockerfile(dockerfile string) func(*icmd.Cmd) func() {
return func(cmd *icmd.Cmd) func() {
cmd.Command = append(cmd.Command, "-")
cmd.Stdin = strings.NewReader(dockerfile)
return nil
}
}
// WithoutCache makes the build ignore cache
func WithoutCache(cmd *icmd.Cmd) func() {
cmd.Command = append(cmd.Command, "--no-cache")
return nil
}
// WithContextPath sets the build context path
func WithContextPath(path string) func(*icmd.Cmd) func() {
return func(cmd *icmd.Cmd) func() {
cmd.Command = append(cmd.Command, path)
return nil
}
}