-
Notifications
You must be signed in to change notification settings - Fork 394
Wrap public transport implementations to consistently use a private API #1463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Set everything in the initializer - Use the same order as the type definition Shoud not change behavior. Signed-off-by: Miloslav Trmač <[email protected]>
Should not change behavior. Signed-off-by: Miloslav Trmač <[email protected]>
…ype checks Signed-off-by: Miloslav Trmač <[email protected]>
Signed-off-by: Miloslav Trmač <[email protected]>
Instead, move PutBlobPartial into private.ImageDestination, and add a SupportsPutBlobPartial() call. Sadly, Go doesn't have optional interface methods like Objective C. In a sense, the type check is more elegant, but doing it this way it requires an explicit choice about what to do for every single new transport, or new private optional feature, and it looks a bit better on the call site (and it might be slightly more efficient). The need for two boilerplate methods at every private transport is ugly, but it will also go away as we add an internal/implement mixin. Signed-off-by: Miloslav Trmač <[email protected]>
The way we actually use this, injecting a progress-reporting proxy, the PutBlobPartial method doesn't have access to the full ImageSource; so, differentiate more clearly between this small interface and an ImageSource. Should not change behavior. Signed-off-by: Miloslav Trmač <[email protected]>
It is neither. Should not change behavior. Signed-off-by: Miloslav Trmač <[email protected]>
Following the now-established pattern, introduce private.ImageSource (with a new SupportsGetBlobAt() method), implement it in dockerImageSource, and use a wrapped version in c/image/copy. This gives us private.ImageSource and private.ImageDestination, to allow for future features. Should not change behavior. Signed-off-by: Miloslav Trmač <[email protected]>
…objects ... do even .Close() via the private wrapper, to ensure we always consistently use the wrapper. Should not change behavior. Signed-off-by: Miloslav Trmač <[email protected]>
17ea4e2 to
1430dd8
Compare
vrothberg
reviewed
Feb 14, 2022
Member
vrothberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, really nice work, @mtrmac
vrothberg
approved these changes
Feb 14, 2022
Member
|
@giuseppe PTAL |
Collaborator
Author
|
BTW I’d like to add #1459 next, before converting transports to private-only implementations. |
giuseppe
approved these changes
Feb 14, 2022
Member
giuseppe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Another part of the #1439 concept.
private.ImageSource, similar to the existingprivate.ImageDestination.internal/imagesource.FromPublicandinternal/imagedestination.FromPublic; the copy pipeline can now always use the private API without cluttering the code with compatibility paths.ImageSourceSeekableandPutBlobPartialinterfaces with mandatory methods on the private interfaces, along with "Supports…” methods. For now, this is more wordy and risks inconsistency between the supports flags and actual implementations, but we’ll eventually make it cleaner and type-safe again, by providing mix-ins (so that a transport that doesn’t support a feature, or does support a feature, needs just to add a mix-in).See individual commit messages for details.