🐛 Moves from moby/buildkit#3755
We have a few locations of testing if a URL is a valid Git URL:
|
func IsRemoteURL(url string) bool { |
|
if _, _, ok := detectHTTPContext(url); ok { |
|
return true |
|
} |
|
if _, ok := detectGitContext(url); ok { |
|
return true |
|
} |
|
return false |
|
} |
|
func isRemoteResource(str string) bool { |
|
return urlutil.IsGitURL(str) || urlutil.IsURL(str) |
|
} |
|
if urlutil.IsGitURL(v.Path) || urlutil.IsURL(v.Path) || strings.HasPrefix(v.Path, "docker-image://") || strings.HasPrefix(v.Path, "target:") { |
However, since moby/buildkit@8bfeafa, the logic for parsing Git URLs has changed, and the corresponding logic in Buildx has not been updated - we should use these BuildKit helpers.
gitutil.ParseGitRef (from buildkit) does not produce the same results as urlutil.IsGitURL (from moby):
gitutil.ParseGitRef does not recognize slashes right after the name such as [email protected]/docker/buildx.git (note /docker instead of :docker), while urlutil.IsGitURL (this use to work before moby/buildkit@8bfeafa, I have no idea why or how though). cc @AkihiroSuda do you know why this behavior would have broken after that commit? I can't identify what part caused the issue 👀
gitutil.ParseGitRef recognize git:// urls such as ssh://[email protected]:docker/buildx.git, while urlutil.IsGitURL does not seem to.
Because of the disparity in these functions, buildx will incorrectly identify URLs as git-urls, and buildkit will fail to handle them correctly.
🐛 Moves from moby/buildkit#3755
We have a few locations of testing if a URL is a valid Git URL:
buildx/bake/remote.go
Lines 86 to 94 in 33388d6
buildx/bake/bake.go
Lines 1043 to 1045 in 33388d6
buildx/build/build.go
Line 1349 in 33388d6
However, since moby/buildkit@8bfeafa, the logic for parsing Git URLs has changed, and the corresponding logic in Buildx has not been updated - we should use these BuildKit helpers.
gitutil.ParseGitRef(from buildkit) does not produce the same results asurlutil.IsGitURL(from moby):gitutil.ParseGitRefdoes not recognize slashes right after the name such as[email protected]/docker/buildx.git(note/dockerinstead of:docker), whileurlutil.IsGitURL(this use to work before moby/buildkit@8bfeafa, I have no idea why or how though). cc @AkihiroSuda do you know why this behavior would have broken after that commit? I can't identify what part caused the issue 👀gitutil.ParseGitRefrecognizegit://urls such asssh://[email protected]:docker/buildx.git, whileurlutil.IsGitURLdoes not seem to.Because of the disparity in these functions, buildx will incorrectly identify URLs as git-urls, and buildkit will fail to handle them correctly.