Skip to content

Commit

Permalink
code clean
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Nov 4, 2022
1 parent 7afa04c commit c2d413f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/oras/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,26 @@ func skipFallbackToImageManifest(root ocispec.Descriptor, err error) bool {
if root.MediaType != ocispec.MediaTypeArtifactManifest {
return true
}

return !isManifestUnsupported(err)
}

func isManifestUnsupported(err error) bool {
var errResp *errcode.ErrorResponse
if !errors.As(err, &errResp) || errResp.StatusCode != http.StatusBadRequest {
return true
return false
}

var errCode errcode.Error
if !errors.As(errResp, &errCode) {
return true
return false
}

// As of November 2022, ECR is known to return UNSUPPORTED error when
// putting an OCI artifact manifest.
switch errCode.Code {
case errcode.ErrorCodeManifestInvalid, errcode.ErrorCodeUnsupported:
return false
return true
}
return true
return false
}

0 comments on commit c2d413f

Please sign in to comment.