mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
build: use buildkit's gitutil package to detect remote files
BuildKit's gitutil package behaves slightly differently than moby's urlutil, so we should rely on BuildKit's gitutil when detecting URLs to avoid cases of accidentally producing invalid build requests that can confuse users. Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
@ -8,6 +8,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/builder/remotecontext/urlutil"
|
||||
"github.com/moby/buildkit/util/gitutil"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -20,6 +22,16 @@ const (
|
||||
mobyHostGatewayName = "host-gateway"
|
||||
)
|
||||
|
||||
func IsRemoteURL(c string) bool {
|
||||
if urlutil.IsURL(c) {
|
||||
return true
|
||||
}
|
||||
if _, err := gitutil.ParseGitRef(c); err == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isLocalDir(c string) bool {
|
||||
st, err := os.Stat(c)
|
||||
return err == nil && st.IsDir()
|
||||
|
Reference in New Issue
Block a user