From bb33a43c749b5b319e11f4ef57cd4111b06cdcff Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 10 Nov 2022 17:30:21 +0100 Subject: [PATCH] registry/client: use struct literals Remove some intermediate variables, and use struct literals instead. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 1d8cd5e443cad5e6d1fdee8bfdfd94b840030eee) Signed-off-by: Sebastiaan van Stijn --- registry/client/repository.go | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/registry/client/repository.go b/registry/client/repository.go index c2bcca897..969994420 100644 --- a/registry/client/repository.go +++ b/registry/client/repository.go @@ -135,16 +135,14 @@ func NewRepository(name reference.Named, baseURL string, transport http.RoundTri return nil, err } - client := &http.Client{ - Transport: transport, - CheckRedirect: checkHTTPRedirect, - // TODO(dmcgowan): create cookie jar - } - return &repository{ - client: client, - ub: ub, - name: name, + client: &http.Client{ + Transport: transport, + CheckRedirect: checkHTTPRedirect, + // TODO(dmcgowan): create cookie jar + }, + ub: ub, + name: name, }, nil } @@ -159,16 +157,15 @@ func (r *repository) Named() reference.Named { } func (r *repository) Blobs(ctx context.Context) distribution.BlobStore { - statter := &blobStatter{ + return &blobs{ name: r.name, ub: r.ub, client: r.client, - } - return &blobs{ - name: r.name, - ub: r.ub, - client: r.client, - statter: cache.NewCachedBlobStatter(memory.NewInMemoryBlobDescriptorCacheProvider(), statter), + statter: cache.NewCachedBlobStatter(memory.NewInMemoryBlobDescriptorCacheProvider(), &blobStatter{ + name: r.name, + ub: r.ub, + client: r.client, + }), } }