Skip to content

Commit

Permalink
fix: check if configPath is empty before writing to Annotations (#509)
Browse files Browse the repository at this point in the history
Signed-off-by: wangxiaoxuan273 <[email protected]>
  • Loading branch information
wangxiaoxuan273 authored Aug 19, 2022
1 parent a6a360e commit 27e9834
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/oras/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,22 @@ func runPull(opts pullOptions) error {
}
var ret []ocispec.Descriptor
// Iterate all the successors to
// 1) Add name annotation if configPath is not empty
// 2) Skip fetching unamed leaf nodes
// 1) Add name annotation to config if configPath is not empty
// 2) Skip fetching unnamed leaf nodes
for i, s := range successors {
// Save the config when:
// 1) MediaType matches, or
// 2) MediaType not specified and current node is config.
// Note: For a manifest, the 0th indexed element is always a
// manifest config.
if s.MediaType == configMediaType || (configMediaType == "" && i == 0 && isManifestMediaType(desc.MediaType)) {
if (s.MediaType == configMediaType || (configMediaType == "" && i == 0 && isManifestMediaType(desc.MediaType))) && configPath != "" {
// Add annotation for manifest config
if s.Annotations == nil {
s.Annotations = make(map[string]string)
}
s.Annotations[ocispec.AnnotationTitle] = configPath
} else if s.Annotations[ocispec.AnnotationTitle] == "" {
}
if s.Annotations[ocispec.AnnotationTitle] == "" {
ss, err := content.Successors(ctx, fetcher, s)
if err != nil {
return nil, err
Expand Down

0 comments on commit 27e9834

Please sign in to comment.