api: client: build: do not fall through if git isn't installed
Signed-off-by: Antonio Murdaca <runcom@redhat.com> Upstream-commit: 167cc42986c8939c7aacf73570adaf19b8cad0b3 Component: engine
This commit is contained in:
@ -81,9 +81,6 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||
err error
|
||||
)
|
||||
|
||||
_, err = exec.LookPath("git")
|
||||
hasGit := err == nil
|
||||
|
||||
specifiedContext := cmd.Arg(0)
|
||||
|
||||
var (
|
||||
@ -104,7 +101,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||
switch {
|
||||
case specifiedContext == "-":
|
||||
context, relDockerfile, err = getContextFromReader(cli.in, *dockerfileName)
|
||||
case urlutil.IsGitURL(specifiedContext) && hasGit:
|
||||
case urlutil.IsGitURL(specifiedContext):
|
||||
tempDir, relDockerfile, err = getContextFromGitURL(specifiedContext, *dockerfileName)
|
||||
case urlutil.IsURL(specifiedContext):
|
||||
context, relDockerfile, err = getContextFromURL(progBuff, specifiedContext, *dockerfileName)
|
||||
@ -503,6 +500,9 @@ func getContextFromReader(r io.ReadCloser, dockerfileName string) (out io.ReadCl
|
||||
// path of the dockerfile in that context directory, and a non-nil error on
|
||||
// success.
|
||||
func getContextFromGitURL(gitURL, dockerfileName string) (absContextDir, relDockerfile string, err error) {
|
||||
if _, err := exec.LookPath("git"); err != nil {
|
||||
return "", "", fmt.Errorf("unable to find 'git': %v", err)
|
||||
}
|
||||
if absContextDir, err = gitutils.Clone(gitURL); err != nil {
|
||||
return "", "", fmt.Errorf("unable to 'git clone' to temporary context directory: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user