Skip to content

Conversation

@mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Feb 12, 2022

Another part of the #1439 concept.

  • Add private.ImageSource, similar to the existing private.ImageDestination.
  • Introduce internal/imagesource.FromPublic and internal/imagedestination.FromPublic; the copy pipeline can now always use the private API without cluttering the code with compatibility paths.
  • Replace the use of optional ImageSourceSeekable and PutBlobPartial interfaces 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.

- 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]>
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]>
Copy link
Member

@vrothberg vrothberg left a 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
Copy link
Member

@giuseppe PTAL

@mtrmac
Copy link
Collaborator Author

mtrmac commented Feb 14, 2022

BTW I’d like to add #1459 next, before converting transports to private-only implementations.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vrothberg vrothberg merged commit 0586e21 into containers:main Feb 14, 2022
@mtrmac mtrmac deleted the private-client branch February 14, 2022 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants