0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-03-25 02:32:57 -05:00

notaryv2: fix 'notation list'

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
Ramkumar Chinchani 2022-01-31 21:33:07 +00:00 committed by Ramkumar Chinchani
parent f9d14d7f94
commit 45fe129c63
5 changed files with 22 additions and 11 deletions

View file

@ -3322,6 +3322,15 @@ func TestImageSignatures(t *testing.T) {
So(msg, ShouldNotBeEmpty)
So(strings.Contains(msg, "verification failure"), ShouldBeFalse)
// check list
cmd = exec.Command("notation", "list", "--plain-http", image)
out, err = cmd.CombinedOutput()
So(err, ShouldBeNil)
msg = strings.TrimSuffix(string(out), "\n")
So(msg, ShouldNotBeEmpty)
_, err = godigest.Parse(msg)
So(err, ShouldBeNil)
// verify the image with incorrect key
cmd = exec.Command("notation", "verify", "--cert", "bad", "--plain-http", image)
out, err = cmd.CombinedOutput()

View file

@ -24,9 +24,9 @@ import (
"github.com/gorilla/mux"
jsoniter "github.com/json-iterator/go"
"github.com/notaryproject/notation-go-lib"
notreg "github.com/notaryproject/notation/pkg/registry"
ispec "github.com/opencontainers/image-spec/specs-go/v1"
artifactspec "github.com/oras-project/artifacts-spec/specs-go/v1"
httpSwagger "github.com/swaggo/http-swagger"
zerr "zotregistry.io/zot/errors"
ext "zotregistry.io/zot/pkg/extensions"
@ -1361,7 +1361,7 @@ func getImageManifest(routeHandler *RouteHandler, imgStore storage.ImageStore, n
}
type ReferenceList struct {
References []notation.Descriptor `json:"references"`
References []artifactspec.Descriptor `json:"references"`
}
// GetReferrers godoc

View file

@ -20,9 +20,9 @@ import (
// Load s3 driver.
_ "github.com/docker/distribution/registry/storage/driver/s3-aws"
guuid "github.com/gofrs/uuid"
"github.com/notaryproject/notation-go-lib"
godigest "github.com/opencontainers/go-digest"
ispec "github.com/opencontainers/image-spec/specs-go/v1"
artifactspec "github.com/oras-project/artifacts-spec/specs-go/v1"
"github.com/rs/zerolog"
zerr "zotregistry.io/zot/errors"
"zotregistry.io/zot/pkg/extensions/monitoring"
@ -1109,7 +1109,7 @@ func (is *ObjectStorage) GetBlobContent(repo string, digest string) ([]byte, err
return buf.Bytes(), nil
}
func (is *ObjectStorage) GetReferrers(repo, digest string, mediaType string) ([]notation.Descriptor, error) {
func (is *ObjectStorage) GetReferrers(repo, digest string, mediaType string) ([]artifactspec.Descriptor, error) {
return nil, zerr.ErrMethodNotSupported
}

View file

@ -4,8 +4,8 @@ import (
"io"
"time"
"github.com/notaryproject/notation-go-lib"
"github.com/opencontainers/go-digest"
artifactspec "github.com/oras-project/artifacts-spec/specs-go/v1"
)
const (
@ -42,5 +42,5 @@ type ImageStore interface {
DeleteBlob(repo string, digest string) error
GetIndexContent(repo string) ([]byte, error)
GetBlobContent(repo, digest string) ([]byte, error)
GetReferrers(repo, digest string, mediaType string) ([]notation.Descriptor, error)
GetReferrers(repo, digest string, mediaType string) ([]artifactspec.Descriptor, error)
}

View file

@ -19,6 +19,7 @@ import (
guuid "github.com/gofrs/uuid"
"github.com/minio/sha256-simd"
"github.com/notaryproject/notation-go-lib"
notreg "github.com/notaryproject/notation/pkg/registry"
godigest "github.com/opencontainers/go-digest"
ispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/umoci"
@ -1381,7 +1382,7 @@ func (is *ImageStoreFS) DeleteBlob(repo string, digest string) error {
return nil
}
func (is *ImageStoreFS) GetReferrers(repo, digest string, mediaType string) ([]notation.Descriptor, error) {
func (is *ImageStoreFS) GetReferrers(repo, digest string, mediaType string) ([]artifactspec.Descriptor, error) {
var lockLatency time.Time
dir := path.Join(is.rootDir, repo)
@ -1419,7 +1420,7 @@ func (is *ImageStoreFS) GetReferrers(repo, digest string, mediaType string) ([]n
found := false
result := []notation.Descriptor{}
result := []artifactspec.Descriptor{}
for _, manifest := range index.Manifests {
if manifest.MediaType != artifactspec.MediaTypeArtifactManifest {
@ -1451,9 +1452,10 @@ func (is *ImageStoreFS) GetReferrers(repo, digest string, mediaType string) ([]n
continue
}
result = append(result, notation.Descriptor{
MediaType: manifest.MediaType,
Digest: manifest.Digest, Size: manifest.Size, Annotations: manifest.Annotations,
result = append(result, artifactspec.Descriptor{
MediaType: manifest.MediaType,
ArtifactType: notreg.ArtifactTypeNotation,
Digest: manifest.Digest, Size: manifest.Size, Annotations: manifest.Annotations,
})
found = true