Skip to content

Commit

Permalink
fix: only fallback to OCI image when current media type is OCI artifa…
Browse files Browse the repository at this point in the history
…ct (oras-project#673)

Resolves oras-project#672 

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
  • Loading branch information
qweeah authored and Terry Howe committed Feb 2, 2023
1 parent 636680f commit 2d13295
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/oras/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ func pushArtifact(dst *remote.Repository, pack packFunc, packOpts *oras.PackOpti
return root, nil
}

if !copyRootAttempted || !isArtifactUnsupported(err) {
if !copyRootAttempted || root.MediaType != ocispec.MediaTypeArtifactManifest ||
!isManifestUnsupported(err) {
return ocispec.Descriptor{}, err
}

Expand Down Expand Up @@ -276,7 +277,7 @@ func pushArtifact(dst *remote.Repository, pack packFunc, packOpts *oras.PackOpti
return root, nil
}

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

0 comments on commit 2d13295

Please sign in to comment.