Skip to content

Commit fc2ceb4

Browse files
authored
fix: Also request OCI media type image index (#524)
Signed-off-by: jannfis <jann@mistrust.net> Signed-off-by: jannfis <jann@mistrust.net>
1 parent 98e5e9d commit fc2ceb4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2
1212
github.com/go-git/go-git/v5 v5.2.0
1313
github.com/opencontainers/go-digest v1.0.0
14+
github.com/opencontainers/image-spec v1.0.2
1415
github.com/patrickmn/go-cache v2.1.0+incompatible
1516
github.com/prometheus/client_golang v1.12.1
1617
github.com/sirupsen/logrus v1.8.1
@@ -110,7 +111,6 @@ require (
110111
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
111112
github.com/modern-go/reflect2 v1.0.2 // indirect
112113
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
113-
github.com/opencontainers/image-spec v1.0.2 // indirect
114114
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
115115
github.com/pkg/errors v0.9.1 // indirect
116116
github.com/pmezard/go-difflib v1.0.0 // indirect

pkg/registry/client.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/distribution/distribution/v3/registry/client/transport"
2525

2626
"github.com/opencontainers/go-digest"
27+
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
2728

2829
"go.uber.org/ratelimit"
2930

@@ -35,6 +36,15 @@ import (
3536

3637
// TODO: Check image's architecture and OS
3738

39+
// knownMediaTypes is the list of media types we can process
40+
var knownMediaTypes = []string{
41+
ocischema.SchemaVersion.MediaType,
42+
schema1.MediaTypeSignedManifest,
43+
schema2.SchemaVersion.MediaType,
44+
manifestlist.SchemaVersion.MediaType,
45+
ociv1.MediaTypeImageIndex,
46+
}
47+
3848
// RegistryClient defines the methods we need for querying container registries
3949
type RegistryClient interface {
4050
NewRepository(nameInRepository string) error
@@ -159,11 +169,10 @@ func (clt *registryClient) ManifestForTag(tagStr string) (distribution.Manifest,
159169
if err != nil {
160170
return nil, err
161171
}
162-
mediaType := []string{ocischema.SchemaVersion.MediaType, schema1.MediaTypeSignedManifest, schema2.SchemaVersion.MediaType, manifestlist.SchemaVersion.MediaType}
163172
manifest, err := manService.Get(
164173
context.Background(),
165174
digest.FromString(tagStr),
166-
distribution.WithTag(tagStr), distribution.WithManifestMediaTypes(mediaType))
175+
distribution.WithTag(tagStr), distribution.WithManifestMediaTypes(knownMediaTypes))
167176
if err != nil {
168177
return nil, err
169178
}
@@ -176,11 +185,10 @@ func (clt *registryClient) ManifestForDigest(dgst digest.Digest) (distribution.M
176185
if err != nil {
177186
return nil, err
178187
}
179-
mediaType := []string{ocischema.SchemaVersion.MediaType, schema1.MediaTypeSignedManifest, schema2.SchemaVersion.MediaType, manifestlist.SchemaVersion.MediaType}
180188
manifest, err := manService.Get(
181189
context.Background(),
182190
dgst,
183-
distribution.WithManifestMediaTypes(mediaType))
191+
distribution.WithManifestMediaTypes(knownMediaTypes))
184192
if err != nil {
185193
return nil, err
186194
}

0 commit comments

Comments
 (0)