Skip to content

Commit

Permalink
proxy: Make OpenImageOptional work with oci-archive:
Browse files Browse the repository at this point in the history
By adding the standard ENOENT to our list of errors.

I hit this while working on
coreos/rpm-ostree#4598
which is a tool that builds base images and wants to query
if the image exists beforehand.
  • Loading branch information
cgwalters committed Sep 15, 2023
1 parent 7c7e600 commit acaf245
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/skopeo/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ func isDockerManifestUnknownError(err error) bool {
// TODO drive this into containers/image properly
func isNotFoundImageError(err error) bool {
return isDockerManifestUnknownError(err) ||
errors.Is(err, ocilayout.ImageNotFoundError{})
errors.Is(err, ocilayout.ImageNotFoundError{}) ||
errors.Is(err, os.ErrNotExist)
}

func (h *proxyHandler) openImageImpl(args []any, allowNotFound bool) (retReplyBuf replyBuf, retErr error) {
Expand Down
7 changes: 7 additions & 0 deletions integration/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,11 @@ func (s *proxySuite) TestProxy() {
err = fmt.Errorf("Testing optional image %s: %v", knownNotExtantImage, err)
}
assert.NoError(t, err)

nonExistentArchive := "oci-archive:/enoent"
err = runTestOpenImageOptionalNotFound(p, nonExistentArchive)
if err != nil {
err = fmt.Errorf("Testing optional image %s: %v", nonExistentArchive, err)
}
assert.NoError(t, err)
}

0 comments on commit acaf245

Please sign in to comment.