mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #42782 from dkkb/McGrady/code_improvement
Remove platform argument from Puller interface.
This commit is contained in:
commit
8684f482e4
3 changed files with 8 additions and 9 deletions
|
@ -11,7 +11,6 @@ import (
|
||||||
refstore "github.com/docker/docker/reference"
|
refstore "github.com/docker/docker/reference"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -21,7 +20,7 @@ type Puller interface {
|
||||||
// Pull tries to pull the image referenced by `tag`
|
// Pull tries to pull the image referenced by `tag`
|
||||||
// Pull returns an error if any, as well as a boolean that determines whether to retry Pull on the next configured endpoint.
|
// Pull returns an error if any, as well as a boolean that determines whether to retry Pull on the next configured endpoint.
|
||||||
//
|
//
|
||||||
Pull(ctx context.Context, ref reference.Named, platform *specs.Platform) error
|
Pull(ctx context.Context, ref reference.Named) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// newPuller returns a Puller interface that will pull from a v2 registry.
|
// newPuller returns a Puller interface that will pull from a v2 registry.
|
||||||
|
@ -95,7 +94,7 @@ func Pull(ctx context.Context, ref reference.Named, imagePullConfig *ImagePullCo
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := puller.Pull(ctx, ref, imagePullConfig.Platform); err != nil {
|
if err := puller.Pull(ctx, ref); err != nil {
|
||||||
// Was this pull cancelled? If so, don't try to fall
|
// Was this pull cancelled? If so, don't try to fall
|
||||||
// back.
|
// back.
|
||||||
fallback := false
|
fallback := false
|
||||||
|
|
|
@ -59,7 +59,7 @@ type v2Puller struct {
|
||||||
manifestStore *manifestStore
|
manifestStore *manifestStore
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *v2Puller) Pull(ctx context.Context, ref reference.Named, platform *specs.Platform) (err error) {
|
func (p *v2Puller) Pull(ctx context.Context, ref reference.Named) (err error) {
|
||||||
// TODO(tiborvass): was ReceiveTimeout
|
// TODO(tiborvass): was ReceiveTimeout
|
||||||
p.repo, err = NewV2Repository(ctx, p.repoInfo, p.endpoint, p.config.MetaHeaders, p.config.AuthConfig, "pull")
|
p.repo, err = NewV2Repository(ctx, p.repoInfo, p.endpoint, p.config.MetaHeaders, p.config.AuthConfig, "pull")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -72,7 +72,7 @@ func (p *v2Puller) Pull(ctx context.Context, ref reference.Named, platform *spec
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = p.pullV2Repository(ctx, ref, platform); err != nil {
|
if err = p.pullV2Repository(ctx, ref); err != nil {
|
||||||
if _, ok := err.(fallbackError); ok {
|
if _, ok := err.(fallbackError); ok {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -86,10 +86,10 @@ func (p *v2Puller) Pull(ctx context.Context, ref reference.Named, platform *spec
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *v2Puller) pullV2Repository(ctx context.Context, ref reference.Named, platform *specs.Platform) (err error) {
|
func (p *v2Puller) pullV2Repository(ctx context.Context, ref reference.Named) (err error) {
|
||||||
var layersDownloaded bool
|
var layersDownloaded bool
|
||||||
if !reference.IsNameOnly(ref) {
|
if !reference.IsNameOnly(ref) {
|
||||||
layersDownloaded, err = p.pullV2Tag(ctx, ref, platform)
|
layersDownloaded, err = p.pullV2Tag(ctx, ref, p.config.Platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (p *v2Puller) pullV2Repository(ctx context.Context, ref reference.Named, pl
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pulledNew, err := p.pullV2Tag(ctx, tagRef, platform)
|
pulledNew, err := p.pullV2Tag(ctx, tagRef, p.config.Platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Since this is the pull-all-tags case, don't
|
// Since this is the pull-all-tags case, don't
|
||||||
// allow an error pulling a particular tag to
|
// allow an error pulling a particular tag to
|
||||||
|
|
|
@ -83,7 +83,7 @@ func testTokenPassThru(t *testing.T, ts *httptest.Server) {
|
||||||
logrus.Debug("About to pull")
|
logrus.Debug("About to pull")
|
||||||
// We expect it to fail, since we haven't mock'd the full registry exchange in our handler above
|
// We expect it to fail, since we haven't mock'd the full registry exchange in our handler above
|
||||||
tag, _ := reference.WithTag(n, "tag_goes_here")
|
tag, _ := reference.WithTag(n, "tag_goes_here")
|
||||||
_ = p.pullV2Repository(ctx, tag, nil)
|
_ = p.pullV2Repository(ctx, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTokenPassThru(t *testing.T) {
|
func TestTokenPassThru(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue