From b5c6b3f10b74ec04398243b1457ea020b88874a0 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Tue, 28 Mar 2023 16:11:52 +0100 Subject: [PATCH] build: fixup resolvePaths for remote context path Signed-off-by: Justin Chadwell --- commands/build.go | 8 +++++--- commands/build_test.go | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/commands/build.go b/commands/build.go index fef0b48c..51532f57 100644 --- a/commands/build.go +++ b/commands/build.go @@ -670,9 +670,11 @@ func dockerUlimitToControllerUlimit(u *dockeropts.UlimitOpt) *controllerapi.Ulim // and replaces them to absolute paths. func resolvePaths(options *controllerapi.BuildOptions) (_ *controllerapi.BuildOptions, err error) { if options.ContextPath != "" && options.ContextPath != "-" { - options.ContextPath, err = filepath.Abs(options.ContextPath) - if err != nil { - return nil, err + if !urlutil.IsGitURL(options.ContextPath) && !urlutil.IsURL(options.ContextPath) { + options.ContextPath, err = filepath.Abs(options.ContextPath) + if err != nil { + return nil, err + } } } if options.DockerfileName != "" && options.DockerfileName != "-" { diff --git a/commands/build_test.go b/commands/build_test.go index 1a7f335e..3bf0e563 100644 --- a/commands/build_test.go +++ b/commands/build_test.go @@ -35,6 +35,11 @@ func TestResolvePaths(t *testing.T) { options: controllerapi.BuildOptions{ContextPath: "-"}, want: controllerapi.BuildOptions{ContextPath: "-"}, }, + { + name: "contextpath-ssh", + options: controllerapi.BuildOptions{ContextPath: "git@github.com:docker/buildx.git"}, + want: controllerapi.BuildOptions{ContextPath: "git@github.com:docker/buildx.git"}, + }, { name: "dockerfilename", options: controllerapi.BuildOptions{DockerfileName: "test"},