Skip to content

Conversation

thaJeztah
Copy link
Member

Go's io package in stdlib now defines this interface, so we can switch to using that instead. Also doing some minor cleanup.

The remaining use of this interface is removed in #3787

@thaJeztah thaJeztah force-pushed the deprecate_ReadSeekCloser branch from d42e1bf to bcf144b Compare November 10, 2022 16:49
Copy link
Member

@milosgajdos milosgajdos left a comment

Choose a reason for hiding this comment

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

I get that distribution.ReadSeekCloser is now type aliased to io.ReadSeekCloser but I still wonder if many of these funcs should be returning io.ReadSeekCloser instead of distribution.ReadSeekCloser; seems like type aliasing does the trick and we dont need to change those return values. Is the reason for that change to be explicit about the type we return

@thaJeztah
Copy link
Member Author

The ReadSeekCloser interface was introduced with the intent for it to be as agnostic as possible (593bbcc);

This allows blobs to take many forms, such as a ReadSeekCloser or a simple
byte buffer, allowing blob oriented operations to better integrate with blob
agnostic APIs (such as the io package)

But, at the time, Go was still at version 1.4, and io.ReadSeekCloser wasn't available until go1.16

FROM golang:1.4

While the alias would "work", it would prevent us from removing it.

Using io.ReadSeekCloser better reflects the intent; implementers can implement a BlobProvider without importing / depending on https://github.com/distribution/distribution; as long as they satisfy the interface and return an io.ReadSeekCloser, it's good.

Go's io package in stdlib now defines this interface, so we can switch
to using that instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…Closer

General convention is to define interfaces on the receiver side, and
to return concrete types.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Remove some intermediate variables, and use struct literals instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the deprecate_ReadSeekCloser branch from bcf144b to 1d8cd5e Compare November 10, 2022 22:11
Copy link

@vbatts vbatts left a comment

Choose a reason for hiding this comment

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

LGTM
I didn't see if there is a project commitment to compile on older golang versions.

@milosgajdos
Copy link
Member

I didn't see if there is a project commitment to compile on older golang versions.

We should document this publicly 💯 Ideally, we should not go far back wrt to supporting older versions - it's an actual nightmare sometimes to be b/w compatible to ancient version.

@thaJeztah
Copy link
Member Author

thaJeztah commented Nov 14, 2022

Go recommendation is to support current + previous (which are the only "supported" versions). I think it's ok if we go for try to support "last 3 versions" (as some projects may be lingering slightly behind), but we should clearly document that to be a "best effort".

@thaJeztah
Copy link
Member Author

@corhere PTAL

Copy link
Collaborator

@wy65701436 wy65701436 left a 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants