ContainerRegistry: Separate registry operations into ImageSource and ImageDestination protocols
#148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently,
RegistryClienthandles uploading and downloading container images to and from a registry. In fact,containertoolcreates two clients: one is used only to download images from the source repository, and the other is used only to upload images to the destination. Registries are read/write, but in the future we may need to handle sources of images which are read-only or write-only - for example when writing a container image out to an archive on disk.This change adds two new protocols, splitting up the operations needed to upload and download images. This allows for future clients which cannot handle both sets of operations.
Modifications
ImageSourceandImageDestinationprotocols, defining the functions needed to download and upload images, respectively.RegistryClientextensions which implement theImageSourceandImageDestinationprotocols.Result
Refactoring. No functional change, but responsibilities of different objects are clearer.
Test Plan
Existing tests continue to pass.