Skip to content
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

image: fix the interaction of findManifest and findConfig with walker.find #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

knieriem
Copy link

Before rev. 9027d58 findManifest and findConfig called w.walk directly,
providing a walkFunc that returned errEOW in case a file has been
found and processed successfully. A switch construct evaluating the
error-result of w.walk then tested for the errEOW case, meaning the file
has been found.

Starting with rev. 9027d58 the call to w.walk in findManifest and
findConfig has been replaced by w.find. Though, the function literal
provided by findManifest and findConfig to w.find -- now a findFunc,
not a walkFunc anymore -- still returns errEOW. As a consequence,
walker.find implementations for tar and zip would treat errEOW as an
error, making oci-image-tool 'validate' and 'create' stop with an error:

<tar-image>: find failed: unable to walk: end of walk

This patch adjusts tarWalker's and zipWalker's implementations of
walker.find, using errEOW to stop w.walk early in case of success; there
is no need for the 'done' variable anymore. Additionally, places where
w.find is called, functions findManifest, unpackManifest, and findConfig,
have been adapted so that their findFunc argument to w.find does not
return errEOW anymore; instead nil is returned on success. Consequently,
the switch constructs now test err for 'nil' instead of 'errEOW', and
'os.ErrNotExist' instead of nil.

Fixes #205

Signed-off-by: Michael Teichgräber mteichgraeber@gmx.de

….find

Before rev. 9027d58 findManifest and findConfig called w.walk directly,
providing a walkFunc that returned errEOW in case a file has been
found and processed successfully.  A switch construct evaluating the
error-result of w.walk then tested for the errEOW case, meaning the file
has been found.

Starting with rev. 9027d58 the call to w.walk in findManifest and
findConfig has been replaced by w.find. Though, the function literal
provided by findManifest and findConfig to w.find -- now a findFunc,
not a walkFunc anymore -- still returns errEOW. As a consequence,
walker.find implementations for tar and zip would treat errEOW as an
error, making oci-image-tool 'validate' and 'create' stop with an error:

	<tar-image>: find failed: unable to walk: end of walk

This patch adjusts tarWalker's and zipWalker's implementations of
walker.find, using errEOW to stop w.walk early in case of success; there
is no need for the 'done' variable anymore. Additionally, places where
w.find is called, functions findManifest, unpackManifest, and findConfig,
have been adapted so that their findFunc argument to w.find does not
return errEOW anymore; instead nil is returned on success. Consequently,
the switch constructs now test err for 'nil' instead of 'errEOW', and
'os.ErrNotExist' instead of nil.

Fixes opencontainers#205

Signed-off-by: Michael Teichgräber <mteichgraeber@gmx.de>
@edtan
Copy link

edtan commented Sep 4, 2019

Just wondering if there's anything blocking this PR? I ran into this issue with some buildkit-generated tars when trying to use the validate and create commands. (I was using this tool to learn more about the OCI specs.) Thanks!

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.

oci-image-tool commands ‘validate’ and ‘create’ failing for tar and zip images
2 participants