mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to master@cbfd4023383d
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
52
vendor/github.com/moby/buildkit/client/llb/source.go
generated
vendored
52
vendor/github.com/moby/buildkit/client/llb/source.go
generated
vendored
@ -5,10 +5,11 @@ import (
|
||||
_ "crypto/sha256" // for opencontainers/go-digest
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/moby/buildkit/solver/pb"
|
||||
"github.com/moby/buildkit/util/apicaps"
|
||||
"github.com/moby/buildkit/util/gitutil"
|
||||
@ -226,7 +227,7 @@ type ImageInfo struct {
|
||||
// Git returns a state that represents a git repository.
|
||||
// Example:
|
||||
//
|
||||
// st := llb.Git("https://github.com/moby/buildkit.git#v0.11.6")
|
||||
// st := llb.Git("https://github.com/moby/buildkit.git", "v0.11.6")
|
||||
//
|
||||
// The example fetches the v0.11.6 tag of the buildkit repository.
|
||||
// You can also use a commit hash or a branch name.
|
||||
@ -237,29 +238,30 @@ type ImageInfo struct {
|
||||
//
|
||||
// By default the git repository is cloned with `--depth=1` to reduce the amount of data downloaded.
|
||||
// Additionally the ".git" directory is removed after the clone, you can keep ith with the [KeepGitDir] [GitOption].
|
||||
func Git(remote, ref string, opts ...GitOption) State {
|
||||
url := strings.Split(remote, "#")[0]
|
||||
|
||||
var protocolType int
|
||||
remote, protocolType = gitutil.ParseProtocol(remote)
|
||||
|
||||
var sshHost string
|
||||
if protocolType == gitutil.SSHProtocol {
|
||||
parts := strings.SplitN(remote, ":", 2)
|
||||
if len(parts) == 2 {
|
||||
sshHost = parts[0]
|
||||
// keep remote consistent with http(s) version
|
||||
remote = parts[0] + "/" + parts[1]
|
||||
}
|
||||
}
|
||||
if protocolType == gitutil.UnknownProtocol {
|
||||
func Git(url, ref string, opts ...GitOption) State {
|
||||
remote, err := gitutil.ParseURL(url)
|
||||
if errors.Is(err, gitutil.ErrUnknownProtocol) {
|
||||
url = "https://" + url
|
||||
remote, err = gitutil.ParseURL(url)
|
||||
}
|
||||
if remote != nil {
|
||||
remote.Fragment = ""
|
||||
url = remote.String()
|
||||
}
|
||||
|
||||
id := remote
|
||||
|
||||
if ref != "" {
|
||||
id += "#" + ref
|
||||
var id string
|
||||
if err != nil {
|
||||
// If we can't parse the URL, just use the full URL as the ID. The git
|
||||
// operation will fail later on.
|
||||
id = url
|
||||
} else {
|
||||
// We construct the ID manually here, so that we can create the same ID
|
||||
// for different protocols (e.g. https and ssh) that have the same
|
||||
// host/path/fragment combination.
|
||||
id = remote.Host + path.Join("/", remote.Path)
|
||||
if ref != "" {
|
||||
id += "#" + ref
|
||||
}
|
||||
}
|
||||
|
||||
gi := &GitInfo{
|
||||
@ -290,11 +292,11 @@ func Git(remote, ref string, opts ...GitOption) State {
|
||||
addCap(&gi.Constraints, pb.CapSourceGitHTTPAuth)
|
||||
}
|
||||
}
|
||||
if protocolType == gitutil.SSHProtocol {
|
||||
if remote != nil && remote.Scheme == gitutil.SSHProtocol {
|
||||
if gi.KnownSSHHosts != "" {
|
||||
attrs[pb.AttrKnownSSHHosts] = gi.KnownSSHHosts
|
||||
} else if sshHost != "" {
|
||||
keyscan, err := sshutil.SSHKeyScan(sshHost)
|
||||
} else {
|
||||
keyscan, err := sshutil.SSHKeyScan(remote.Host)
|
||||
if err == nil {
|
||||
// best effort
|
||||
attrs[pb.AttrKnownSSHHosts] = keyscan
|
||||
|
42
vendor/github.com/moby/buildkit/client/llb/sourcemap.go
generated
vendored
42
vendor/github.com/moby/buildkit/client/llb/sourcemap.go
generated
vendored
@ -1,6 +1,7 @@
|
||||
package llb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
"github.com/moby/buildkit/solver/pb"
|
||||
@ -47,6 +48,33 @@ func (s *SourceMap) Location(r []*pb.Range) ConstraintsOpt {
|
||||
})
|
||||
}
|
||||
|
||||
func equalSourceMap(sm1, sm2 *SourceMap) (out bool) {
|
||||
if sm1 == nil || sm2 == nil {
|
||||
return false
|
||||
}
|
||||
if sm1.Filename != sm2.Filename {
|
||||
return false
|
||||
}
|
||||
if sm1.Language != sm2.Language {
|
||||
return false
|
||||
}
|
||||
if len(sm1.Data) != len(sm2.Data) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(sm1.Data, sm2.Data) {
|
||||
return false
|
||||
}
|
||||
if sm1.Definition != nil && sm2.Definition != nil {
|
||||
if len(sm1.Definition.Def) != len(sm2.Definition.Def) && len(sm1.Definition.Def) != 0 {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(sm1.Definition.Def[len(sm1.Definition.Def)-1], sm2.Definition.Def[len(sm2.Definition.Def)-1]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
type SourceLocation struct {
|
||||
SourceMap *SourceMap
|
||||
Ranges []*pb.Range
|
||||
@ -69,8 +97,18 @@ func (smc *sourceMapCollector) Add(dgst digest.Digest, ls []*SourceLocation) {
|
||||
for _, l := range ls {
|
||||
idx, ok := smc.index[l.SourceMap]
|
||||
if !ok {
|
||||
idx = len(smc.maps)
|
||||
smc.maps = append(smc.maps, l.SourceMap)
|
||||
idx = -1
|
||||
// slow equality check
|
||||
for i, m := range smc.maps {
|
||||
if equalSourceMap(m, l.SourceMap) {
|
||||
idx = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if idx == -1 {
|
||||
idx = len(smc.maps)
|
||||
smc.maps = append(smc.maps, l.SourceMap)
|
||||
}
|
||||
}
|
||||
smc.index[l.SourceMap] = idx
|
||||
}
|
||||
|
Reference in New Issue
Block a user