Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2
github.com/go-git/go-git/v5 v5.2.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.2
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/prometheus/client_golang v1.12.1
github.com/sirupsen/logrus v1.8.1
Expand Down Expand Up @@ -110,7 +111,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
16 changes: 12 additions & 4 deletions pkg/registry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/distribution/distribution/v3/registry/client/transport"

"github.com/opencontainers/go-digest"
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"

"go.uber.org/ratelimit"

Expand All @@ -35,6 +36,15 @@ import (

// TODO: Check image's architecture and OS

// knownMediaTypes is the list of media types we can process
var knownMediaTypes = []string{
ocischema.SchemaVersion.MediaType,
schema1.MediaTypeSignedManifest,
schema2.SchemaVersion.MediaType,
manifestlist.SchemaVersion.MediaType,
ociv1.MediaTypeImageIndex,
}

// RegistryClient defines the methods we need for querying container registries
type RegistryClient interface {
NewRepository(nameInRepository string) error
Expand Down Expand Up @@ -159,11 +169,10 @@ func (clt *registryClient) ManifestForTag(tagStr string) (distribution.Manifest,
if err != nil {
return nil, err
}
mediaType := []string{ocischema.SchemaVersion.MediaType, schema1.MediaTypeSignedManifest, schema2.SchemaVersion.MediaType, manifestlist.SchemaVersion.MediaType}
manifest, err := manService.Get(
context.Background(),
digest.FromString(tagStr),
distribution.WithTag(tagStr), distribution.WithManifestMediaTypes(mediaType))
distribution.WithTag(tagStr), distribution.WithManifestMediaTypes(knownMediaTypes))
if err != nil {
return nil, err
}
Expand All @@ -176,11 +185,10 @@ func (clt *registryClient) ManifestForDigest(dgst digest.Digest) (distribution.M
if err != nil {
return nil, err
}
mediaType := []string{ocischema.SchemaVersion.MediaType, schema1.MediaTypeSignedManifest, schema2.SchemaVersion.MediaType, manifestlist.SchemaVersion.MediaType}
manifest, err := manService.Get(
context.Background(),
dgst,
distribution.WithManifestMediaTypes(mediaType))
distribution.WithManifestMediaTypes(knownMediaTypes))
if err != nil {
return nil, err
}
Expand Down