diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2022-02-18 16:45:34 +0100 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2022-02-18 16:58:40 +0100 |
commit | 4d6c6a5000e3348a30ebc2ff4246baf0dcdaf1b9 (patch) | |
tree | 98bf384a8a9dff634e0326faae5f88dcc1fe0453 /distribution | |
parent | 047e032461f9ef6226143b4768331b7f893d2572 (diff) | |
download | docker-4d6c6a5000e3348a30ebc2ff4246baf0dcdaf1b9.tar.gz |
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 <github@gone.nl>
Diffstat (limited to 'distribution')
-rw-r--r-- | distribution/xfer/download.go | 19 |
1 files changed, 9 insertions, 10 deletions
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()) } |