Merge pull request #1701 from jedevc/fixup-resolve-paths-context-path

build: fixup resolvePaths for remote context path
pull/1552/head
Justin Chadwell 2 years ago committed by GitHub
commit 799715ea24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 != "-" {

@ -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"},

Loading…
Cancel
Save