From 4d6c6a5000e3348a30ebc2ff4246baf0dcdaf1b9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 18 Feb 2022 16:45:34 +0100 Subject: distribution/xfer: smaller interface, rename to DigestRegisterer All uses of this interface already accept a DownloadDescriptor; keeping the interface small to allow this functionality to be used by other download-descriptors, while still being able to check for the actual functionality (to be able to register a digest). Signed-off-by: Sebastiaan van Stijn --- distribution/xfer/download.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'distribution') diff --git a/distribution/xfer/download.go b/distribution/xfer/download.go index b03960761f..8ccccbcbfb 100644 --- a/distribution/xfer/download.go +++ b/distribution/xfer/download.go @@ -90,13 +90,12 @@ type DownloadDescriptor interface { Close() } -// DownloadDescriptorWithRegistered is a DownloadDescriptor that has an -// additional Registered method which gets called after a downloaded layer is -// registered. This allows the user of the download manager to know the DiffID -// of each registered layer. This method is called if a cast to -// DownloadDescriptorWithRegistered is successful. -type DownloadDescriptorWithRegistered interface { - DownloadDescriptor +// DigestRegisterer can be implemented by a DownloadDescriptor, and provides a +// Registered method which gets called after a downloaded layer is registered. +// This allows the user of the download manager to know the DiffID of each +// registered layer. This method is called if a cast to DigestRegisterer is +// successful. +type DigestRegisterer interface { // TODO existing implementations in distribution and builder-next swallow errors // when registering the diffID. Consider changing the Registered signature @@ -145,7 +144,7 @@ func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS ima missingLayer = false rootFS.Append(diffID) // Register this repository as a source of this layer. - if withRegistered, ok := descriptor.(DownloadDescriptorWithRegistered); ok { // As layerstore may set the driver + if withRegistered, ok := descriptor.(DigestRegisterer); ok { // As layerstore may set the driver withRegistered.Registered(diffID) } continue @@ -368,7 +367,7 @@ func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, progress.Update(progressOutput, descriptor.ID(), "Pull complete") - if withRegistered, ok := descriptor.(DownloadDescriptorWithRegistered); ok { + if withRegistered, ok := descriptor.(DigestRegisterer); ok { withRegistered.Registered(d.layer.DiffID()) } @@ -460,7 +459,7 @@ func (ldm *LayerDownloadManager) makeDownloadFuncFromDownload(descriptor Downloa return } - if withRegistered, ok := descriptor.(DownloadDescriptorWithRegistered); ok { + if withRegistered, ok := descriptor.(DigestRegisterer); ok { withRegistered.Registered(d.layer.DiffID()) } -- cgit v1.2.1