Skip to content

Conversation

@squeed
Copy link
Contributor

@squeed squeed commented Apr 4, 2017

This allows the image library to handle any ReadSeeker, enabling on-the-fly uncompression.

Also, refactor the validate methods to avoid unnecessary copies.

Signed-off-by: Casey Callendrello [email protected]

Copy link
Contributor

@s-urbaniak s-urbaniak left a comment

Choose a reason for hiding this comment

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

LGTM with a minor question/suggestion.

I think it is unfortunate that the walker interface received new methods via reader in the first place effectively also gaining a public method.

This looks better now by making get private only (as it was intended in the first place) for the walker interface.

image/image.go Outdated
// ValidateReader walks through the stream and validates the manifest
// pointed to by the given refs or returns an error if the validation failed.
// The stream must be a valid .tar file.
func ValidateReader(r io.ReadSeeker, refs []string, out *log.Logger) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd even call this Validate as it is more general than the filename based one.

Copy link
Contributor

@s-urbaniak s-urbaniak Apr 4, 2017

Choose a reason for hiding this comment

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

If we can't break the API, then I'd call this ValidateReadSeeker as it is more honest.

image/image.go Outdated
// Validate walks through the given .tar file and validates the manifest
// pointed to by the given refs or returns an error if the validation failed.
// Validate opens the tar file given by the filename, then calls ValidateReader
func Validate(tarFile string, refs []string, out *log.Logger) error {
Copy link
Contributor

@s-urbaniak s-urbaniak Apr 4, 2017

Choose a reason for hiding this comment

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

I'd call this ValidateFile(name string, refs []string, out *log.Logger....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to break the public API - though I can if you like.

image/image.go Outdated
// UnpackReader walks through the tar stream and, using the layers specified in
// the manifest pointed to by the given ref, unpacks all layers in the given
// destination directory or returns an error if the unpacking failed.
func UnpackReader(r io.ReadSeeker, dest, refName string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

same comments apply as for the Validate* methods.

@cyphar
Copy link
Member

cyphar commented Apr 4, 2017

At the moment, the public API is going to have to be reworked anyway. Ultimately I don't really care if we break it because:

a. We are not a 1.0 project.
b. There are a lot of things that need to be fixed with the current API that it doesn't make sense for us to mandate keeping a broken API (we're not kernel developers after all).

@jonboulle
Copy link
Contributor

agreed with aleksa - this looks reasonable for now. Needs signed-off-by at the least though.

@squeed squeed force-pushed the tar-streams branch 2 times, most recently from f2f8899 to 7785596 Compare April 4, 2017 16:48
@squeed
Copy link
Contributor Author

squeed commented Apr 4, 2017

Updated the PR to rename methods according to @s-urbaniak's suggestions; I added a quick optimization while I was at it.

@squeed
Copy link
Contributor Author

squeed commented Apr 5, 2017

Fixed oci-image-tool create while I was at it.

Not sure why "Signed-off-by" isn't being detected.

@vbatts
Copy link
Member

vbatts commented Apr 5, 2017

also, make lint has some feedback

@squeed
Copy link
Contributor Author

squeed commented Apr 5, 2017

Whups, fixed, thanks.

@vbatts
Copy link
Member

vbatts commented Apr 5, 2017

Not sure about the @pullapprove failure on recognizing the DCO. It passed the make .gitvalidation check which also includes DCO. :-\

@caniszczyk
Copy link
Contributor

@vbatts is "Signed-off-by: Casey Callendrello [email protected]" an email associated with @squeed's github account?

This allows the image library to handle any ReadSeeker, enabling
on-the-fly uncompression.

Also, refactor the validate methods to avoid unnecessary copies.

Signed-off-by: Casey Callendrello <[email protected]>
@squeed
Copy link
Contributor Author

squeed commented Apr 5, 2017

Ah, probably just the case difference - I fixed the commit.

@caniszczyk
Copy link
Contributor

@squeed looks like that was it (sigh)

@vbatts
Copy link
Member

vbatts commented Apr 5, 2017

OHMAN
LGTM

Approved with PullApprove

// or returns an error if the unpacking failed.
func CreateRuntimeBundle(tarFile, dest, ref, root string) error {
// CreateRuntimeBundleFile opens the file pointed by tarFile and calls
// CreateRuntimeBundle.
Copy link
Contributor

@xiekeyang xiekeyang Apr 6, 2017

Choose a reason for hiding this comment

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

s/CreateRuntimeBundle/createRuntimeBundle ?

And, CreateRuntimeBundle which seems to be unused should be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of this PR is to allow for arbitrary tar streams, making this more useful as a library.

While CreateRuntimeBundle isn't used by the cli tool, it's a good library function.

@jonboulle
Copy link
Contributor

jonboulle commented Apr 6, 2017

👍

Approved with PullApprove

@jonboulle jonboulle merged commit 261e335 into opencontainers:master Apr 6, 2017
@xiekeyang xiekeyang mentioned this pull request Jun 29, 2017
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.

7 participants