Skip to content

Commit

Permalink
removed def in discard
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
Xiaoxuan Wang committed Feb 6, 2025
1 parent a0c0994 commit 74cfa86
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
5 changes: 0 additions & 5 deletions cmd/oras/internal/display/metadata/discard.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,3 @@ func (Discard) OnTagged(ocispec.Descriptor, string) error {

// OnIndexCreated implements ManifestIndexCreateHandler.
func (Discard) OnIndexCreated(ocispec.Descriptor) {}

// OnCompleted implements ManifestIndexCreateHandler.
func (Discard) OnCompleted(ocispec.Descriptor) error {
return nil
}
6 changes: 3 additions & 3 deletions cmd/oras/internal/display/metadata/text/manifest_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// ManifestIndexCreateHandler handles text metadata output for index create events.
type ManifestIndexCreateHandler struct {
printer *output.Printer
desc ocispec.Descriptor
root ocispec.Descriptor
}

// NewManifestIndexCreateHandler returns a new handler for index create events.
Expand All @@ -41,10 +41,10 @@ func (h *ManifestIndexCreateHandler) OnTagged(_ ocispec.Descriptor, tag string)

// OnIndexCreated implements ManifestIndexCreateHandler.
func (h *ManifestIndexCreateHandler) OnIndexCreated(desc ocispec.Descriptor) {
h.desc = desc
h.root = desc
}

// Render implements ManifestIndexCreateHandler.
func (h *ManifestIndexCreateHandler) Render() error {
return h.printer.Println("Digest:", h.desc.Digest)
return h.printer.Println("Digest:", h.root.Digest)
}
4 changes: 2 additions & 2 deletions cmd/oras/internal/display/metadata/text/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (w *errorWriter) Write(p []byte) (n int, err error) {
return 0, fmt.Errorf("got an error")
}

func TestPushHandler_OnCompleted(t *testing.T) {
func TestPushHandler_Render(t *testing.T) {
content := []byte("content")
tests := []struct {
name string
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestPushHandler_OnCompleted(t *testing.T) {
root: tt.root,
}
if err := p.Render(); (err != nil) != tt.wantErr {
t.Errorf("PushHandler.OnCompleted() error = %v, wantErr %v", err, tt.wantErr)
t.Errorf("PushHandler.Render() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
Expand Down

0 comments on commit 74cfa86

Please sign in to comment.