mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
vendor: update buildkit to 0e3037c0182e
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
35
vendor/github.com/moby/buildkit/util/contentutil/refs.go
generated
vendored
35
vendor/github.com/moby/buildkit/util/contentutil/refs.go
generated
vendored
@ -16,12 +16,41 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func ProviderFromRef(ref string) (ocispecs.Descriptor, content.Provider, error) {
|
||||
type ResolveOpt struct {
|
||||
Credentials func(string) (string, string, error)
|
||||
}
|
||||
|
||||
type ResolveOptFunc func(*ResolveOpt)
|
||||
|
||||
func WithCredentials(c func(string) (string, string, error)) ResolveOptFunc {
|
||||
return func(o *ResolveOpt) {
|
||||
o.Credentials = func(host string) (string, string, error) {
|
||||
if host == "registry-1.docker.io" {
|
||||
host = "https://index.docker.io/v1/"
|
||||
}
|
||||
return c(host)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ProviderFromRef(ref string, opts ...ResolveOptFunc) (ocispecs.Descriptor, content.Provider, error) {
|
||||
headers := http.Header{}
|
||||
headers.Set("User-Agent", version.UserAgent())
|
||||
remote := docker.NewResolver(docker.ResolverOptions{
|
||||
|
||||
var ro ResolveOpt
|
||||
for _, f := range opts {
|
||||
f(&ro)
|
||||
}
|
||||
|
||||
dro := docker.ResolverOptions{
|
||||
Headers: headers,
|
||||
})
|
||||
}
|
||||
if ro.Credentials != nil {
|
||||
dro.Hosts = docker.ConfigureDefaultRegistries(
|
||||
docker.WithAuthorizer(docker.NewDockerAuthorizer(docker.WithAuthCreds(ro.Credentials))),
|
||||
)
|
||||
}
|
||||
remote := docker.NewResolver(dro)
|
||||
|
||||
name, desc, err := remote.Resolve(context.TODO(), ref)
|
||||
if err != nil {
|
||||
|
12
vendor/github.com/moby/buildkit/util/testutil/integration/run.go
generated
vendored
12
vendor/github.com/moby/buildkit/util/testutil/integration/run.go
generated
vendored
@ -19,6 +19,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/v2/core/content"
|
||||
"github.com/containerd/containerd/v2/core/remotes/docker"
|
||||
"github.com/docker/cli/cli/config"
|
||||
"github.com/gofrs/flock"
|
||||
"github.com/moby/buildkit/util/appcontext"
|
||||
"github.com/moby/buildkit/util/contentutil"
|
||||
@ -257,7 +258,16 @@ func copyImagesLocal(t *testing.T, host string, images map[string]string) error
|
||||
defer closer()
|
||||
}
|
||||
} else {
|
||||
desc, provider, err = contentutil.ProviderFromRef(from)
|
||||
dockerConfig := config.LoadDefaultConfigFile(os.Stderr)
|
||||
|
||||
desc, provider, err = contentutil.ProviderFromRef(from, contentutil.WithCredentials(
|
||||
func(host string) (string, string, error) {
|
||||
ac, err := dockerConfig.GetAuthConfig(host)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
return ac.Username, ac.Password, nil
|
||||
}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user