mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
Update buildkit
- updated buildkit to current code in master via: go mod edit -require github.com/moby/buildkit@master && go mod tidy && ./hack/update-vendor Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
This commit is contained in:
46
vendor/github.com/moby/buildkit/util/gitutil/git_protocol.go
generated
vendored
Normal file
46
vendor/github.com/moby/buildkit/util/gitutil/git_protocol.go
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
package gitutil
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/moby/buildkit/util/sshutil"
|
||||
)
|
||||
|
||||
const (
|
||||
HTTPProtocol = iota + 1
|
||||
HTTPSProtocol
|
||||
SSHProtocol
|
||||
GitProtocol
|
||||
UnknownProtocol
|
||||
)
|
||||
|
||||
// ParseProtocol parses a git URL and returns the remote url and protocol type
|
||||
func ParseProtocol(remote string) (string, int) {
|
||||
prefixes := map[string]int{
|
||||
"http://": HTTPProtocol,
|
||||
"https://": HTTPSProtocol,
|
||||
"git://": GitProtocol,
|
||||
"ssh://": SSHProtocol,
|
||||
}
|
||||
protocolType := UnknownProtocol
|
||||
for prefix, potentialType := range prefixes {
|
||||
if strings.HasPrefix(remote, prefix) {
|
||||
remote = strings.TrimPrefix(remote, prefix)
|
||||
protocolType = potentialType
|
||||
}
|
||||
}
|
||||
|
||||
if protocolType == UnknownProtocol && sshutil.IsImplicitSSHTransport(remote) {
|
||||
protocolType = SSHProtocol
|
||||
}
|
||||
|
||||
// remove name from ssh
|
||||
if protocolType == SSHProtocol {
|
||||
parts := strings.SplitN(remote, "@", 2)
|
||||
if len(parts) == 2 {
|
||||
remote = parts[1]
|
||||
}
|
||||
}
|
||||
|
||||
return remote, protocolType
|
||||
}
|
Reference in New Issue
Block a user