Skip to content

Commit

Permalink
fix: update
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao committed Feb 21, 2025
1 parent 2abca21 commit 83d602b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
8 changes: 0 additions & 8 deletions cmd/notation/internal/display/metadata/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,10 @@ type BlobVerifyHandler interface {
// signatures.
type ListHandler interface {
Renderer

// OnResolvingTagReference outputs the tag reference warning.
OnResolvingTagReference(reference string)

// OnReferenceResolved sets the artifact reference and media type for the
// handler.
OnReferenceResolved(reference string)

// OnSignatureListed adds the signature digest to be rendered.
OnSignatureListed(signatureManifest ocispec.Descriptor)

// OnExceedMaxSignatures outputs the warning message when the number of
// signatures exceeds the maximum limit.
OnExceedMaxSignatures(err error)
}
11 changes: 0 additions & 11 deletions cmd/notation/internal/display/metadata/tree/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ func NewListHandler(printer *output.Printer) *ListHandler {
}
}

// OnResolvingTagReference outputs the tag reference warning.
func (h *ListHandler) OnResolvingTagReference(reference string) {
h.printer.PrintErrorf("Warning: Always list the artifact using digest(@sha256:...) rather than a tag(:%s) because resolved digest may not point to the same signed artifact, as tags are mutable.\n", reference)
}

// OnReferenceResolved sets the artifact reference and media type for the
// handler.
func (h *ListHandler) OnReferenceResolved(reference string) {
Expand All @@ -69,12 +64,6 @@ func (h *ListHandler) OnSignatureListed(signatureManifest ocispec.Descriptor) {
h.sprinter.PrintNode(newNode(signatureManifest.Digest.String()))
}

// OnExceedMaxSignatures outputs the warning message when the number of
// signatures exceeds the maximum limit.
func (h *ListHandler) OnExceedMaxSignatures(err error) {
h.printer.PrintErrorf("Warning: %v\n", err)
}

// Render completes the rendering of the list of signature digests.
func (h *ListHandler) Render() error {
if h.sprinter.prevNode == nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/notation/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func runList(ctx context.Context, opts *listOpts) error {
return err
}
manifestDesc, resolvedRef, err := resolveReference(ctx, opts.inputType, reference, sigRepo, func(ref string, manifestDesc ocispec.Descriptor) {
displayHandler.OnResolvingTagReference(ref)
opts.Printer.PrintErrorf("Warning: Always list the artifact using digest(@sha256:...) rather than a tag(:%s) because resolved digest may not point to the same signed artifact, as tags are mutable.\n", ref)
})
if err != nil {
return err
Expand All @@ -129,7 +129,7 @@ func runList(ctx context.Context, opts *listOpts) error {
if !errors.As(err, &errExceedMaxSignatures) {
return err
}
displayHandler.OnExceedMaxSignatures(err)
opts.Printer.PrintErrorf("Warning: %v\n", err)
}

return displayHandler.Render()
Expand Down

0 comments on commit 83d602b

Please sign in to comment.