Skip to content

Commit 0cdf6ba

Browse files
committed
vendor: update buildkit to ae7ff174
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
1 parent e6d949b commit 0cdf6ba

File tree

36 files changed

+1105
-490
lines changed

36 files changed

+1105
-490
lines changed

builder/builder-next/adapters/containerimage/pull.go

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ import (
3131
"github.com/moby/buildkit/cache"
3232
"github.com/moby/buildkit/client/llb"
3333
"github.com/moby/buildkit/session"
34-
"github.com/moby/buildkit/session/auth"
3534
"github.com/moby/buildkit/source"
3635
"github.com/moby/buildkit/util/flightcontrol"
3736
"github.com/moby/buildkit/util/imageutil"
3837
"github.com/moby/buildkit/util/progress"
3938
"github.com/moby/buildkit/util/resolver"
40-
"github.com/moby/buildkit/util/tracing"
4139
digest "github.com/opencontainers/go-digest"
4240
"github.com/opencontainers/image-spec/identity"
4341
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -54,7 +52,7 @@ type SourceOpt struct {
5452
DownloadManager distribution.RootFSDownloadManager
5553
MetadataStore metadata.V2MetadataService
5654
ImageStore image.Store
57-
ResolverOpt resolver.ResolveOptionsFunc
55+
RegistryHosts docker.RegistryHosts
5856
LayerStore layer.Store
5957
}
6058

@@ -78,44 +76,15 @@ func (is *imageSource) ID() string {
7876
return source.DockerImageScheme
7977
}
8078

81-
func (is *imageSource) getResolver(ctx context.Context, rfn resolver.ResolveOptionsFunc, ref string, sm *session.Manager) remotes.Resolver {
79+
func (is *imageSource) getResolver(ctx context.Context, hosts docker.RegistryHosts, ref string, sm *session.Manager) remotes.Resolver {
8280
if res := is.resolverCache.Get(ctx, ref); res != nil {
8381
return res
8482
}
85-
86-
opt := docker.ResolverOptions{
87-
Client: tracing.DefaultClient,
88-
}
89-
if rfn != nil {
90-
opt = rfn(ref)
91-
}
92-
opt.Credentials = is.getCredentialsFromSession(ctx, sm)
93-
r := docker.NewResolver(opt)
83+
r := resolver.New(ctx, hosts, sm)
9484
r = is.resolverCache.Add(ctx, ref, r)
9585
return r
9686
}
9787

98-
func (is *imageSource) getCredentialsFromSession(ctx context.Context, sm *session.Manager) func(string) (string, string, error) {
99-
id := session.FromContext(ctx)
100-
if id == "" {
101-
// can be removed after containerd/containerd#2812
102-
return func(string) (string, string, error) {
103-
return "", "", nil
104-
}
105-
}
106-
return func(host string) (string, string, error) {
107-
timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
108-
defer cancel()
109-
110-
caller, err := sm.Get(timeoutCtx, id)
111-
if err != nil {
112-
return "", "", err
113-
}
114-
115-
return auth.CredentialsFunc(tracing.ContextWithSpanFromContext(context.TODO(), ctx), caller)(host)
116-
}
117-
}
118-
11988
func (is *imageSource) resolveLocal(refStr string) (*image.Image, error) {
12089
ref, err := distreference.ParseNormalizedNamed(refStr)
12190
if err != nil {
@@ -138,7 +107,7 @@ func (is *imageSource) resolveRemote(ctx context.Context, ref string, platform *
138107
dt []byte
139108
}
140109
res, err := is.g.Do(ctx, ref, func(ctx context.Context) (interface{}, error) {
141-
dgst, dt, err := imageutil.Config(ctx, ref, is.getResolver(ctx, is.ResolverOpt, ref, sm), is.ContentStore, nil, platform)
110+
dgst, dt, err := imageutil.Config(ctx, ref, is.getResolver(ctx, is.RegistryHosts, ref, sm), is.ContentStore, nil, platform)
142111
if err != nil {
143112
return nil, err
144113
}
@@ -208,7 +177,7 @@ func (is *imageSource) Resolve(ctx context.Context, id source.Identifier, sm *se
208177
p := &puller{
209178
src: imageIdentifier,
210179
is: is,
211-
resolver: is.getResolver(ctx, is.ResolverOpt, imageIdentifier.Reference.String(), sm),
180+
resolver: is.getResolver(ctx, is.RegistryHosts, imageIdentifier.Reference.String(), sm),
212181
platform: platform,
213182
sm: sm,
214183
}

builder/builder-next/adapters/localinlinecache/inlinecache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/containerd/containerd/content"
99
"github.com/containerd/containerd/images"
10+
"github.com/containerd/containerd/remotes/docker"
1011
distreference "github.com/docker/distribution/reference"
1112
imagestore "github.com/docker/docker/image"
1213
"github.com/docker/docker/reference"
@@ -15,17 +16,16 @@ import (
1516
v1 "github.com/moby/buildkit/cache/remotecache/v1"
1617
"github.com/moby/buildkit/session"
1718
"github.com/moby/buildkit/solver"
18-
"github.com/moby/buildkit/util/resolver"
1919
"github.com/moby/buildkit/worker"
2020
digest "github.com/opencontainers/go-digest"
2121
specs "github.com/opencontainers/image-spec/specs-go/v1"
2222
"github.com/pkg/errors"
2323
)
2424

2525
// ResolveCacheImporterFunc returns a resolver function for local inline cache
26-
func ResolveCacheImporterFunc(sm *session.Manager, resolverOpt resolver.ResolveOptionsFunc, cs content.Store, rs reference.Store, is imagestore.Store) remotecache.ResolveCacheImporterFunc {
26+
func ResolveCacheImporterFunc(sm *session.Manager, resolverFunc docker.RegistryHosts, cs content.Store, rs reference.Store, is imagestore.Store) remotecache.ResolveCacheImporterFunc {
2727

28-
upstream := registryremotecache.ResolveCacheImporterFunc(sm, cs, resolverOpt)
28+
upstream := registryremotecache.ResolveCacheImporterFunc(sm, cs, resolverFunc)
2929

3030
return func(ctx context.Context, attrs map[string]string) (remotecache.Importer, specs.Descriptor, error) {
3131
if dt, err := tryImportLocal(rs, is, attrs["ref"]); err == nil {

builder/builder-next/builder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/containerd/containerd/platforms"
14+
"github.com/containerd/containerd/remotes/docker"
1415
"github.com/docker/docker/api/types"
1516
"github.com/docker/docker/api/types/backend"
1617
"github.com/docker/docker/builder"
@@ -26,7 +27,6 @@ import (
2627
"github.com/moby/buildkit/identity"
2728
"github.com/moby/buildkit/session"
2829
"github.com/moby/buildkit/util/entitlements"
29-
"github.com/moby/buildkit/util/resolver"
3030
"github.com/moby/buildkit/util/tracing"
3131
"github.com/pkg/errors"
3232
"golang.org/x/sync/errgroup"
@@ -70,7 +70,7 @@ type Opt struct {
7070
Dist images.DistributionServices
7171
NetworkController libnetwork.NetworkController
7272
DefaultCgroupParent string
73-
ResolverOpt resolver.ResolveOptionsFunc
73+
RegistryHosts docker.RegistryHosts
7474
BuilderConfig config.BuilderConfig
7575
Rootless bool
7676
IdentityMapping *idtools.IdentityMapping

builder/builder-next/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
119119
MetadataStore: dist.V2MetadataService,
120120
ImageStore: dist.ImageStore,
121121
ReferenceStore: dist.ReferenceStore,
122-
ResolverOpt: opt.ResolverOpt,
122+
RegistryHosts: opt.RegistryHosts,
123123
LayerStore: dist.LayerStore,
124124
})
125125
if err != nil {
@@ -210,7 +210,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
210210
Frontends: frontends,
211211
CacheKeyStorage: cacheStorage,
212212
ResolveCacheImporterFuncs: map[string]remotecache.ResolveCacheImporterFunc{
213-
"registry": localinlinecache.ResolveCacheImporterFunc(opt.SessionManager, opt.ResolverOpt, store, dist.ReferenceStore, dist.ImageStore),
213+
"registry": localinlinecache.ResolveCacheImporterFunc(opt.SessionManager, opt.RegistryHosts, store, dist.ReferenceStore, dist.ImageStore),
214214
"local": localremotecache.ResolveCacheImporterFunc(opt.SessionManager),
215215
},
216216
ResolveCacheExporterFuncs: map[string]remotecache.ResolveCacheExporterFunc{

cmd/dockerd/daemon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func newRouterOptions(config *config.Config, d *daemon.Daemon) (routerOptions, e
292292
Dist: d.DistributionServices(),
293293
NetworkController: d.NetworkController(),
294294
DefaultCgroupParent: cgroupParent,
295-
ResolverOpt: d.NewResolveOptionsFunc(),
295+
RegistryHosts: d.RegistryHosts(),
296296
BuilderConfig: config.Builder,
297297
Rootless: d.Rootless(),
298298
IdentityMapping: d.IdentityMapping(),

daemon/daemon.go

Lines changed: 35 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"context"
1010
"fmt"
1111
"io/ioutil"
12-
"math/rand"
1312
"net"
1413
"net/url"
1514
"os"
@@ -28,7 +27,6 @@ import (
2827
"github.com/containerd/containerd/defaults"
2928
"github.com/containerd/containerd/pkg/dialer"
3029
"github.com/containerd/containerd/remotes/docker"
31-
"github.com/docker/distribution/reference"
3230
"github.com/docker/docker/api/types"
3331
containertypes "github.com/docker/docker/api/types/container"
3432
"github.com/docker/docker/api/types/swarm"
@@ -42,8 +40,8 @@ import (
4240
"github.com/docker/docker/daemon/logger"
4341
"github.com/docker/docker/daemon/network"
4442
"github.com/docker/docker/errdefs"
43+
bkconfig "github.com/moby/buildkit/cmd/buildkitd/config"
4544
"github.com/moby/buildkit/util/resolver"
46-
"github.com/moby/buildkit/util/tracing"
4745
"github.com/sirupsen/logrus"
4846

4947
// register graph drivers
@@ -153,63 +151,46 @@ func (daemon *Daemon) Features() *map[string]bool {
153151
return &daemon.configStore.Features
154152
}
155153

156-
// NewResolveOptionsFunc returns a call back function to resolve "registry-mirrors" and
157-
// "insecure-registries" for buildkit
158-
func (daemon *Daemon) NewResolveOptionsFunc() resolver.ResolveOptionsFunc {
159-
return func(ref string) docker.ResolverOptions {
160-
var (
161-
registryKey = "docker.io"
162-
mirrors = make([]string, len(daemon.configStore.Mirrors))
163-
m = map[string]resolver.RegistryConf{}
164-
)
165-
// must trim "https://" or "http://" prefix
166-
for i, v := range daemon.configStore.Mirrors {
167-
if uri, err := url.Parse(v); err == nil {
168-
v = uri.Host
169-
}
170-
mirrors[i] = v
171-
}
172-
// set "registry-mirrors"
173-
m[registryKey] = resolver.RegistryConf{Mirrors: mirrors}
174-
// set "insecure-registries"
175-
for _, v := range daemon.configStore.InsecureRegistries {
176-
if uri, err := url.Parse(v); err == nil {
177-
v = uri.Host
178-
}
179-
plainHTTP := true
180-
m[v] = resolver.RegistryConf{
181-
PlainHTTP: &plainHTTP,
182-
}
183-
}
184-
def := docker.ResolverOptions{
185-
Client: tracing.DefaultClient,
186-
}
187-
188-
parsed, err := reference.ParseNormalizedNamed(ref)
189-
if err != nil {
190-
return def
154+
// RegistryHosts returns registry configuration in containerd resolvers format
155+
func (daemon *Daemon) RegistryHosts() docker.RegistryHosts {
156+
var (
157+
registryKey = "docker.io"
158+
mirrors = make([]string, len(daemon.configStore.Mirrors))
159+
m = map[string]bkconfig.RegistryConfig{}
160+
)
161+
// must trim "https://" or "http://" prefix
162+
for i, v := range daemon.configStore.Mirrors {
163+
if uri, err := url.Parse(v); err == nil {
164+
v = uri.Host
191165
}
192-
host := reference.Domain(parsed)
193-
194-
c, ok := m[host]
195-
if !ok {
196-
return def
197-
}
198-
199-
if len(c.Mirrors) > 0 {
200-
// TODO ResolverOptions.Host is deprecated; ResolverOptions.Hosts should be used
201-
def.Host = func(string) (string, error) {
202-
return c.Mirrors[rand.Intn(len(c.Mirrors))], nil
166+
mirrors[i] = v
167+
}
168+
// set mirrors for default registry
169+
m[registryKey] = bkconfig.RegistryConfig{Mirrors: mirrors}
170+
171+
for _, v := range daemon.configStore.InsecureRegistries {
172+
u, err := url.Parse(v)
173+
c := bkconfig.RegistryConfig{}
174+
if err == nil {
175+
v = u.Host
176+
t := true
177+
if u.Scheme == "http" {
178+
c.PlainHTTP = &t
179+
} else {
180+
c.Insecure = &t
203181
}
204182
}
183+
m[v] = c
184+
}
205185

206-
// TODO ResolverOptions.PlainHTTP is deprecated; ResolverOptions.Hosts should be used
207-
if c.PlainHTTP != nil {
208-
def.PlainHTTP = *c.PlainHTTP
186+
for k, v := range m {
187+
if d, err := registry.HostCertsDir(k); err == nil {
188+
v.TLSConfigDir = []string{d}
189+
m[k] = v
209190
}
210-
211-
return def
212191
}
192+
193+
return resolver.NewRegistryConfig(m)
213194
}
214195

215196
func (daemon *Daemon) restore() error {

registry/registry.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,36 @@ var (
2626
ErrAlreadyExists = errors.New("Image already exists")
2727
)
2828

29+
// HostCertsDir returns the config directory for a specific host
30+
func HostCertsDir(hostname string) (string, error) {
31+
certsDir := CertsDir
32+
33+
if rootless.RunningWithRootlessKit() {
34+
configHome, err := homedir.GetConfigHome()
35+
if err != nil {
36+
return "", err
37+
}
38+
39+
certsDir = filepath.Join(configHome, "docker/certs.d")
40+
}
41+
42+
hostDir := filepath.Join(certsDir, cleanPath(hostname))
43+
44+
return hostDir, nil
45+
}
46+
2947
func newTLSConfig(hostname string, isSecure bool) (*tls.Config, error) {
3048
// PreferredServerCipherSuites should have no effect
3149
tlsConfig := tlsconfig.ServerDefault()
3250

3351
tlsConfig.InsecureSkipVerify = !isSecure
3452

3553
if isSecure && CertsDir != "" {
36-
certsDir := CertsDir
37-
38-
if rootless.RunningWithRootlessKit() {
39-
configHome, err := homedir.GetConfigHome()
40-
if err != nil {
41-
return nil, err
42-
}
43-
44-
certsDir = filepath.Join(configHome, "docker/certs.d")
54+
hostDir, err := HostCertsDir(hostname)
55+
if err != nil {
56+
return nil, err
4557
}
4658

47-
hostDir := filepath.Join(certsDir, cleanPath(hostname))
48-
4959
logrus.Debugf("hostDir: %s", hostDir)
5060
if err := ReadCertsDirectory(tlsConfig, hostDir); err != nil {
5161
return nil, err

vendor.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ github.com/imdario/mergo 1afb36080aec31e0d1528973ebe6
2727
golang.org/x/sync cd5d95a43a6e21273425c7ae415d3df9ea832eeb
2828

2929
# buildkit
30-
github.com/moby/buildkit 4d8d91bf49c769b8458e9aa84746c842b4a0e39a
31-
github.com/tonistiigi/fsutil 013a9fe6aee2d1658457075bf9e688bc8c0be2e0
30+
github.com/moby/buildkit ae7ff7174f73bcb4df89b97e1623b3fb0bfb0a0c
31+
github.com/tonistiigi/fsutil c2c7d7b0e1441705cd802e5699c0a10b1dfe39fd
3232
github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746
3333
github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7
3434
github.com/google/shlex e7afc7fbc51079733e9468cdfd1efcd7d196cd1d

vendor/github.com/moby/buildkit/README.md

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/buildkit/cache/contenthash/tarsum.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)