From 6f5beea146ed9ab54fce4c7734b9c0440ecf49e2 Mon Sep 17 00:00:00 2001 From: Da McGrady Date: Wed, 25 Aug 2021 11:34:25 +0800 Subject: [PATCH] Remove platform argument from Puller interface. The platform argument is unneeded because ImagePullConfig is already in the v2Puller struct. Signed-off-by: Da McGrady --- distribution/pull.go | 5 ++--- distribution/pull_v2.go | 10 +++++----- distribution/registry_unit_test.go | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/distribution/pull.go b/distribution/pull.go index 2352eca412..829c5fed6a 100644 --- a/distribution/pull.go +++ b/distribution/pull.go @@ -11,7 +11,6 @@ import ( refstore "github.com/docker/docker/reference" "github.com/docker/docker/registry" digest "github.com/opencontainers/go-digest" - specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -21,7 +20,7 @@ type Puller interface { // 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(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. @@ -95,7 +94,7 @@ func Pull(ctx context.Context, ref reference.Named, imagePullConfig *ImagePullCo 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 // back. fallback := false diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go index cecc6ca13a..4d0bb7ef59 100644 --- a/distribution/pull_v2.go +++ b/distribution/pull_v2.go @@ -60,7 +60,7 @@ type v2Puller struct { 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 p.repo, err = NewV2Repository(ctx, p.repoInfo, p.endpoint, p.config.MetaHeaders, p.config.AuthConfig, "pull") if err != nil { @@ -73,7 +73,7 @@ func (p *v2Puller) Pull(ctx context.Context, ref reference.Named, platform *spec return err } - if err = p.pullV2Repository(ctx, ref, platform); err != nil { + if err = p.pullV2Repository(ctx, ref); err != nil { if _, ok := err.(fallbackError); ok { return err } @@ -87,10 +87,10 @@ func (p *v2Puller) Pull(ctx context.Context, ref reference.Named, platform *spec 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 if !reference.IsNameOnly(ref) { - layersDownloaded, err = p.pullV2Tag(ctx, ref, platform) + layersDownloaded, err = p.pullV2Tag(ctx, ref, p.config.Platform) if err != nil { return err } @@ -105,7 +105,7 @@ func (p *v2Puller) pullV2Repository(ctx context.Context, ref reference.Named, pl if err != nil { return err } - pulledNew, err := p.pullV2Tag(ctx, tagRef, platform) + pulledNew, err := p.pullV2Tag(ctx, tagRef, p.config.Platform) if err != nil { // Since this is the pull-all-tags case, don't // allow an error pulling a particular tag to diff --git a/distribution/registry_unit_test.go b/distribution/registry_unit_test.go index 5770ad8a37..3cbd09f562 100644 --- a/distribution/registry_unit_test.go +++ b/distribution/registry_unit_test.go @@ -83,7 +83,7 @@ func testTokenPassThru(t *testing.T, ts *httptest.Server) { logrus.Debug("About to pull") // 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") - _ = p.pullV2Repository(ctx, tag, nil) + _ = p.pullV2Repository(ctx, tag) } func TestTokenPassThru(t *testing.T) {