Skip to content

Commit

Permalink
move outputable to view
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Mar 26, 2024
1 parent eeabec7 commit 61e0241
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
14 changes: 4 additions & 10 deletions cmd/oras/internal/display/metadata/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,22 @@ limitations under the License.
package metadata

import (
"io"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras/cmd/oras/internal/display/metadata/view"
"oras.land/oras/cmd/oras/internal/option"
)

type Outputable interface {
// WithOutput resets output of the handler.
WithOutput(out io.Writer)
}

// PushHandler handles metadata output for push events.
type PushHandler interface {
OnCopied(opts *option.Target) error
OnCompleted(root ocispec.Descriptor) error
Outputable
view.Outputable
}

// AttachHandler handles metadata output for attach events.
type AttachHandler interface {
OnCompleted(opts *option.Target, root, subject ocispec.Descriptor) error
Outputable
view.Outputable
}

// PullHandler handles metadata output for attach events.
Expand All @@ -46,5 +40,5 @@ type PullHandler interface {
OnFilePulled(name string, outputDir string, desc ocispec.Descriptor, descPath string)
// OnCompleted is called when the pull cmd execution is completed.
OnCompleted(opts *option.Target, desc ocispec.Descriptor, layerSkipped bool) error
Outputable
view.Outputable
}
9 changes: 7 additions & 2 deletions cmd/oras/internal/display/metadata/view/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ import (
"io"

"github.com/Masterminds/sprig/v3"
"oras.land/oras/cmd/oras/internal/display/metadata"
)

// Outputable interface is used to reset output of the handler.
type Outputable interface {
// WithOutput resets output of the handler.
WithOutput(out io.Writer)
}

// Printer prints.
type Printer interface {
Printf(format string, a ...any) (n int, err error)
Println(a ...any) (n int, err error)
PrintJSON(object any) error
ParseAndWrite(object any, templateStr string) error
metadata.Outputable
Outputable
}

type printer struct {
Expand Down

0 comments on commit 61e0241

Please sign in to comment.