Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

image: accept arbitrary file streams#136

Merged
jonboulle merged 1 commit into
opencontainers:masterfrom
squeed:tar-streams
Apr 6, 2017
Merged

image: accept arbitrary file streams#136
jonboulle merged 1 commit into
opencontainers:masterfrom
squeed:tar-streams

Conversation

@squeed

@squeed squeed commented Apr 4, 2017

Copy link
Copy Markdown
Contributor

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 casey.Callendrello@coreos.com

@s-urbaniak s-urbaniak left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread 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
Copy Markdown
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.

@s-urbaniak s-urbaniak Apr 4, 2017

Copy link
Copy Markdown
Contributor

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.

Comment thread 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 {

@s-urbaniak s-urbaniak Apr 4, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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

cyphar commented Apr 4, 2017

Copy link
Copy Markdown
Member

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
Copy Markdown
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

squeed commented Apr 4, 2017

Copy link
Copy Markdown
Contributor Author

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

@squeed

squeed commented Apr 5, 2017

Copy link
Copy Markdown
Contributor Author

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

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

@vbatts

vbatts commented Apr 5, 2017

Copy link
Copy Markdown
Member

also, make lint has some feedback

@squeed

squeed commented Apr 5, 2017

Copy link
Copy Markdown
Contributor Author

Whups, fixed, thanks.

@vbatts

vbatts commented Apr 5, 2017

Copy link
Copy Markdown
Member

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

@caniszczyk

Copy link
Copy Markdown
Contributor

@vbatts is "Signed-off-by: Casey Callendrello casey.Callendrello@coreos.com" 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 <casey.callendrello@coreos.com>
@squeed

squeed commented Apr 5, 2017

Copy link
Copy Markdown
Contributor Author

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

@caniszczyk

Copy link
Copy Markdown
Contributor

@squeed looks like that was it (sigh)

@vbatts

vbatts commented Apr 5, 2017

Copy link
Copy Markdown
Member

OHMAN
LGTM

Approved with PullApprove

Comment thread image/image.go
// 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.

@xiekeyang xiekeyang Apr 6, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

jonboulle commented Apr 6, 2017

Copy link
Copy Markdown
Contributor

👍

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants