-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct fetch order for manifests and blobs with hints on media …
…type (#1209) <!-- markdownlint-disable MD041 --> #### What this PR does / why we need it This PR changes the OCI fetch logic to: 1. Fetch Blobs before Manifests in case there is no media type 2. Fetch Manifests before Blobs or Blobs before Manifests if there is a media type hint #### Which issue(s) this PR fixes <!-- Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> --------- Signed-off-by: Gergely Brautigam <[email protected]> Co-authored-by: Gergely Brautigam <[email protected]>
- Loading branch information
1 parent
f9c1e27
commit 285a20a
Showing
6 changed files
with
94 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package oras | ||
|
||
import ( | ||
ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||
) | ||
|
||
// defaultManifestMediaTypes contains the default set of manifests media types. | ||
var defaultManifestMediaTypes = []string{ | ||
"application/vnd.docker.distribution.manifest.v2+json", | ||
"application/vnd.docker.distribution.manifest.list.v2+json", | ||
"application/vnd.oci.artifact.manifest.v1+json", | ||
ocispec.MediaTypeImageManifest, | ||
ocispec.MediaTypeImageIndex, | ||
} | ||
|
||
// isManifest determines if the given descriptor points to a manifest. | ||
func isManifest(manifestMediaTypes []string, desc ocispec.Descriptor) bool { | ||
if len(manifestMediaTypes) == 0 { | ||
manifestMediaTypes = defaultManifestMediaTypes | ||
} | ||
for _, mediaType := range manifestMediaTypes { | ||
if desc.MediaType == mediaType { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters