Skip to content

Commit dea7c10

Browse files
dependabot[bot]ashutosh-narkar
authored andcommitted
build(deps): bump oras.land/oras-go/v2 from 2.2.1 to 2.3.0
Bumps [oras.land/oras-go/v2](https://github.com/oras-project/oras-go) from 2.2.1 to 2.3.0. - [Release notes](https://github.com/oras-project/oras-go/releases) - [Commits](oras-project/oras-go@v2.2.1...v2.3.0) --- updated-dependencies: - dependency-name: oras.land/oras-go/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
1 parent 9cab6c9 commit dea7c10

File tree

16 files changed

+393
-79
lines changed

16 files changed

+393
-79
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ require (
4242
google.golang.org/grpc v1.57.0
4343
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
4444
gopkg.in/yaml.v2 v2.4.0
45-
oras.land/oras-go/v2 v2.2.1
45+
oras.land/oras-go/v2 v2.3.0
4646
sigs.k8s.io/yaml v1.3.0
4747
)
4848

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
640640
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
641641
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
642642
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
643-
oras.land/oras-go/v2 v2.2.1 h1:3VJTYqy5KfelEF9c2jo1MLSpr+TM3mX8K42wzZcd6qE=
644-
oras.land/oras-go/v2 v2.2.1/go.mod h1:GeAwLuC4G/JpNwkd+bSZ6SkDMGaaYglt6YK2WvZP7uQ=
643+
oras.land/oras-go/v2 v2.3.0 h1:lqX1aXdN+DAmDTKjiDyvq85cIaI4RkIKp/PghWlAGIU=
644+
oras.land/oras-go/v2 v2.3.0/go.mod h1:GeAwLuC4G/JpNwkd+bSZ6SkDMGaaYglt6YK2WvZP7uQ=
645645
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
646646
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
647647
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

vendor/modules.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ gopkg.in/yaml.v2
458458
# gopkg.in/yaml.v3 v3.0.1
459459
## explicit
460460
gopkg.in/yaml.v3
461-
# oras.land/oras-go/v2 v2.2.1
461+
# oras.land/oras-go/v2 v2.3.0
462462
## explicit; go 1.19
463463
oras.land/oras-go/v2
464464
oras.land/oras-go/v2/content
@@ -473,6 +473,7 @@ oras.land/oras-go/v2/internal/fs/tarfs
473473
oras.land/oras-go/v2/internal/graph
474474
oras.land/oras-go/v2/internal/interfaces
475475
oras.land/oras-go/v2/internal/ioutil
476+
oras.land/oras-go/v2/internal/manifestutil
476477
oras.land/oras-go/v2/internal/platform
477478
oras.land/oras-go/v2/internal/registryutil
478479
oras.land/oras-go/v2/internal/resolver

vendor/oras.land/oras-go/v2/content/graph.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,33 @@ func Successors(ctx context.Context, fetcher Fetcher, node ocispec.Descriptor) (
7575
}
7676
nodes = append(nodes, manifest.Config)
7777
return append(nodes, manifest.Layers...), nil
78-
case docker.MediaTypeManifestList, ocispec.MediaTypeImageIndex:
78+
case docker.MediaTypeManifestList:
7979
content, err := FetchAll(ctx, fetcher, node)
8080
if err != nil {
8181
return nil, err
8282
}
8383

84-
// docker manifest list and oci index are equivalent for successors.
84+
// OCI manifest index schema can be used to marshal docker manifest list
8585
var index ocispec.Index
8686
if err := json.Unmarshal(content, &index); err != nil {
8787
return nil, err
8888
}
8989
return index.Manifests, nil
90+
case ocispec.MediaTypeImageIndex:
91+
content, err := FetchAll(ctx, fetcher, node)
92+
if err != nil {
93+
return nil, err
94+
}
95+
96+
var index ocispec.Index
97+
if err := json.Unmarshal(content, &index); err != nil {
98+
return nil, err
99+
}
100+
var nodes []ocispec.Descriptor
101+
if index.Subject != nil {
102+
nodes = append(nodes, *index.Subject)
103+
}
104+
return append(nodes, index.Manifests...), nil
90105
case spec.MediaTypeArtifactManifest:
91106
content, err := FetchAll(ctx, fetcher, node)
92107
if err != nil {

vendor/oras.land/oras-go/v2/content/oci/oci.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License.
1414
*/
1515

1616
// Package oci provides access to an OCI content store.
17-
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md
17+
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc4/image-layout.md
1818
package oci
1919

2020
import (
@@ -40,17 +40,17 @@ import (
4040

4141
// ociImageIndexFile is the file name of the index
4242
// from the OCI Image Layout Specification.
43-
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md#indexjson-file
43+
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc4/image-layout.md#indexjson-file
4444
const ociImageIndexFile = "index.json"
4545

4646
// ociBlobsDir is the name of the blobs directory
4747
// from the OCI Image Layout Specification.
48-
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md#content
48+
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc4/image-layout.md#content
4949
const ociBlobsDir = "blobs"
5050

5151
// Store implements `oras.Target`, and represents a content store
5252
// based on file system with the OCI-Image layout.
53-
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md
53+
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc4/image-layout.md
5454
type Store struct {
5555
// AutoSaveIndex controls if the OCI store will automatically save the index
5656
// file on each Tag() call.
@@ -135,7 +135,7 @@ func (s *Store) Exists(ctx context.Context, target ocispec.Descriptor) (bool, er
135135

136136
// Tag tags a descriptor with a reference string.
137137
// reference should be a valid tag (e.g. "latest").
138-
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md#indexjson-file
138+
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc4/image-layout.md#indexjson-file
139139
func (s *Store) Tag(ctx context.Context, desc ocispec.Descriptor, reference string) error {
140140
if err := validateReference(reference); err != nil {
141141
return err

vendor/oras.land/oras-go/v2/content/oci/readonlyoci.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636

3737
// ReadOnlyStore implements `oras.ReadonlyTarget`, and represents a read-only
3838
// content store based on file system with the OCI-Image layout.
39-
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md
39+
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc4/image-layout.md
4040
type ReadOnlyStore struct {
4141
fsys fs.FS
4242
storage content.ReadOnlyStorage

vendor/oras.land/oras-go/v2/content/oci/readonlystorage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131

3232
// ReadOnlyStorage is a read-only CAS based on file system with the OCI-Image
3333
// layout.
34-
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md
34+
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc4/image-layout.md
3535
type ReadOnlyStorage struct {
3636
fsys fs.FS
3737
}

vendor/oras.land/oras-go/v2/content/oci/storage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var bufPool = sync.Pool{
4242
}
4343

4444
// Storage is a CAS based on file system with the OCI-Image layout.
45-
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc2/image-layout.md
45+
// Reference: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc4/image-layout.md
4646
type Storage struct {
4747
*ReadOnlyStorage
4848
// root is the root directory of the OCI layout.

vendor/oras.land/oras-go/v2/content/storage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type Fetcher interface {
3131
// Pusher pushes content.
3232
type Pusher interface {
3333
// Push pushes the content, matching the expected descriptor.
34-
// Reader is perferred to Writer so that the suitable buffer size can be
34+
// Reader is preferred to Writer so that the suitable buffer size can be
3535
// chosen by the underlying implementation. Furthermore, the implementation
3636
// can also do reflection on the Reader for more advanced I/O optimization.
3737
Push(ctx context.Context, expected ocispec.Descriptor, content io.Reader) error

vendor/oras.land/oras-go/v2/errdef/errors.go

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var (
2222
ErrAlreadyExists = errors.New("already exists")
2323
ErrInvalidDigest = errors.New("invalid digest")
2424
ErrInvalidReference = errors.New("invalid reference")
25+
ErrInvalidMediaType = errors.New("invalid media type")
2526
ErrMissingReference = errors.New("missing reference")
2627
ErrNotFound = errors.New("not found")
2728
ErrSizeExceedsLimit = errors.New("size exceeds limit")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
Copyright The ORAS Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package manifestutil
17+
18+
import (
19+
"context"
20+
"encoding/json"
21+
22+
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
23+
"oras.land/oras-go/v2/content"
24+
"oras.land/oras-go/v2/internal/docker"
25+
)
26+
27+
// Config returns the config of desc, if present.
28+
func Config(ctx context.Context, fetcher content.Fetcher, desc ocispec.Descriptor) (*ocispec.Descriptor, error) {
29+
switch desc.MediaType {
30+
case docker.MediaTypeManifest, ocispec.MediaTypeImageManifest:
31+
content, err := content.FetchAll(ctx, fetcher, desc)
32+
if err != nil {
33+
return nil, err
34+
}
35+
// OCI manifest schema can be used to marshal docker manifest
36+
var manifest ocispec.Manifest
37+
if err := json.Unmarshal(content, &manifest); err != nil {
38+
return nil, err
39+
}
40+
return &manifest.Config, nil
41+
default:
42+
return nil, nil
43+
}
44+
}
45+
46+
// Manifest returns the manifests of desc, if present.
47+
func Manifests(ctx context.Context, fetcher content.Fetcher, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
48+
switch desc.MediaType {
49+
case docker.MediaTypeManifestList, ocispec.MediaTypeImageIndex:
50+
content, err := content.FetchAll(ctx, fetcher, desc)
51+
if err != nil {
52+
return nil, err
53+
}
54+
// OCI manifest index schema can be used to marshal docker manifest list
55+
var index ocispec.Index
56+
if err := json.Unmarshal(content, &index); err != nil {
57+
return nil, err
58+
}
59+
return index.Manifests, nil
60+
default:
61+
return nil, nil
62+
}
63+
}

vendor/oras.land/oras-go/v2/internal/platform/platform.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"oras.land/oras-go/v2/content"
2626
"oras.land/oras-go/v2/errdef"
2727
"oras.land/oras-go/v2/internal/docker"
28+
"oras.land/oras-go/v2/internal/manifestutil"
2829
)
2930

3031
// Match checks whether the current platform matches the target platform.
@@ -35,7 +36,7 @@ import (
3536
// array of the current platform.
3637
//
3738
// Note: Variant, OSVersion and OSFeatures are optional fields, will skip
38-
// the comparison if the target platform does not provide specfic value.
39+
// the comparison if the target platform does not provide specific value.
3940
func Match(got *ocispec.Platform, want *ocispec.Platform) bool {
4041
if got.Architecture != want.Architecture || got.OS != want.OS {
4142
return false
@@ -77,7 +78,7 @@ func isSubset(a, b []string) bool {
7778
func SelectManifest(ctx context.Context, src content.ReadOnlyStorage, root ocispec.Descriptor, p *ocispec.Platform) (ocispec.Descriptor, error) {
7879
switch root.MediaType {
7980
case docker.MediaTypeManifestList, ocispec.MediaTypeImageIndex:
80-
manifests, err := content.Successors(ctx, src, root)
81+
manifests, err := manifestutil.Manifests(ctx, src, root)
8182
if err != nil {
8283
return ocispec.Descriptor{}, err
8384
}
@@ -90,7 +91,8 @@ func SelectManifest(ctx context.Context, src content.ReadOnlyStorage, root ocisp
9091
}
9192
return ocispec.Descriptor{}, fmt.Errorf("%s: %w: no matching manifest was found in the manifest list", root.Digest, errdef.ErrNotFound)
9293
case docker.MediaTypeManifest, ocispec.MediaTypeImageManifest:
93-
descs, err := content.Successors(ctx, src, root)
94+
// config will be non-nil for docker manifest and OCI image manifest
95+
config, err := manifestutil.Config(ctx, src, root)
9496
if err != nil {
9597
return ocispec.Descriptor{}, err
9698
}
@@ -99,8 +101,7 @@ func SelectManifest(ctx context.Context, src content.ReadOnlyStorage, root ocisp
99101
if root.MediaType == ocispec.MediaTypeImageManifest {
100102
configMediaType = ocispec.MediaTypeImageConfig
101103
}
102-
103-
cfgPlatform, err := getPlatformFromConfig(ctx, src, descs[0], configMediaType)
104+
cfgPlatform, err := getPlatformFromConfig(ctx, src, *config, configMediaType)
104105
if err != nil {
105106
return ocispec.Descriptor{}, err
106107
}

0 commit comments

Comments
 (0)