mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-19 01:47:43 +08:00
build: fixup resolvePaths for remote context path
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
3f59b27cf4
commit
b5c6b3f10b
@ -670,11 +670,13 @@ func dockerUlimitToControllerUlimit(u *dockeropts.UlimitOpt) *controllerapi.Ulim
|
|||||||
// and replaces them to absolute paths.
|
// and replaces them to absolute paths.
|
||||||
func resolvePaths(options *controllerapi.BuildOptions) (_ *controllerapi.BuildOptions, err error) {
|
func resolvePaths(options *controllerapi.BuildOptions) (_ *controllerapi.BuildOptions, err error) {
|
||||||
if options.ContextPath != "" && options.ContextPath != "-" {
|
if options.ContextPath != "" && options.ContextPath != "-" {
|
||||||
|
if !urlutil.IsGitURL(options.ContextPath) && !urlutil.IsURL(options.ContextPath) {
|
||||||
options.ContextPath, err = filepath.Abs(options.ContextPath)
|
options.ContextPath, err = filepath.Abs(options.ContextPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if options.DockerfileName != "" && options.DockerfileName != "-" {
|
if options.DockerfileName != "" && options.DockerfileName != "-" {
|
||||||
options.DockerfileName, err = filepath.Abs(options.DockerfileName)
|
options.DockerfileName, err = filepath.Abs(options.DockerfileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -35,6 +35,11 @@ func TestResolvePaths(t *testing.T) {
|
|||||||
options: controllerapi.BuildOptions{ContextPath: "-"},
|
options: controllerapi.BuildOptions{ContextPath: "-"},
|
||||||
want: 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",
|
name: "dockerfilename",
|
||||||
options: controllerapi.BuildOptions{DockerfileName: "test"},
|
options: controllerapi.BuildOptions{DockerfileName: "test"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user