Skip to content

Commit 21aadaf

Browse files
committed
proxy: Make OpenImageOptional work with oci-archive:
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. Signed-off-by: Colin Walters <[email protected]>
1 parent 7c7e600 commit 21aadaf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cmd/skopeo/proxy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ func isDockerManifestUnknownError(err error) bool {
235235
// TODO drive this into containers/image properly
236236
func isNotFoundImageError(err error) bool {
237237
return isDockerManifestUnknownError(err) ||
238-
errors.Is(err, ocilayout.ImageNotFoundError{})
238+
errors.Is(err, ocilayout.ImageNotFoundError{}) ||
239+
errors.Is(err, os.ErrNotExist)
239240
}
240241

241242
func (h *proxyHandler) openImageImpl(args []any, allowNotFound bool) (retReplyBuf replyBuf, retErr error) {

integration/proxy_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,11 @@ func (s *proxySuite) TestProxy() {
354354
err = fmt.Errorf("Testing optional image %s: %v", knownNotExtantImage, err)
355355
}
356356
assert.NoError(t, err)
357+
358+
nonExistentArchive := "oci-archive:/enoent"
359+
err = runTestOpenImageOptionalNotFound(p, nonExistentArchive)
360+
if err != nil {
361+
err = fmt.Errorf("Testing optional image %s: %v", nonExistentArchive, err)
362+
}
363+
assert.NoError(t, err)
357364
}

0 commit comments

Comments
 (0)