diff --git a/cmd/oras/internal/display/status/discard.go b/cmd/oras/internal/display/status/discard.go index d8e007fc2..adfe695be 100644 --- a/cmd/oras/internal/display/status/discard.go +++ b/cmd/oras/internal/display/status/discard.go @@ -46,8 +46,10 @@ func (DiscardHandler) TrackTarget(gt oras.GraphTarget) (oras.GraphTarget, error) return gt, nil } -// StopTracking stops tracking the status of the target. -func (DiscardHandler) StopTracking() {} +// Close implements io.Closer. +func (DiscardHandler) Close() error { + return nil +} // UpdateCopyOptions updates the copy options for the artifact push. func (DiscardHandler) UpdateCopyOptions(opts *oras.CopyGraphOptions, fetcher content.Fetcher) {} diff --git a/cmd/oras/internal/display/status/interface.go b/cmd/oras/internal/display/status/interface.go index b1a9309e6..758d18af5 100644 --- a/cmd/oras/internal/display/status/interface.go +++ b/cmd/oras/internal/display/status/interface.go @@ -16,6 +16,7 @@ limitations under the License. package status import ( + "io" "sync" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -39,8 +40,7 @@ type PullHandler interface { // TrackTarget returns a tracked target. // If no TTY is available, it returns the original target. TrackTarget(gt oras.GraphTarget) (oras.GraphTarget, error) - // StopTracking stops tracking the target if available. - StopTracking() + io.Closer // OnNodeProcessing is called when processing a manifest. OnNodeProcessing(desc ocispec.Descriptor) error // OnNodeDownloading is called before downloading a node. diff --git a/cmd/oras/internal/display/status/text.go b/cmd/oras/internal/display/status/text.go index f67429cf9..416b013f6 100644 --- a/cmd/oras/internal/display/status/text.go +++ b/cmd/oras/internal/display/status/text.go @@ -107,8 +107,10 @@ func (ph *TextPullHandler) TrackTarget(gt oras.GraphTarget) (oras.GraphTarget, e return gt, nil } -// StopTracking stop tracked target. -func (ph *TextPullHandler) StopTracking() {} +// Close implements io.Closer. +func (ph *TextPullHandler) Close() error { + return nil +} // OnNodeDownloading implements PullHandler. func (ph *TextPullHandler) OnNodeDownloading(desc ocispec.Descriptor) error { diff --git a/cmd/oras/internal/display/status/tty.go b/cmd/oras/internal/display/status/tty.go index 74407e7f7..d9c248545 100644 --- a/cmd/oras/internal/display/status/tty.go +++ b/cmd/oras/internal/display/status/tty.go @@ -134,9 +134,9 @@ func (ph *TTYPullHandler) OnNodeSkipped(printed *sync.Map, desc ocispec.Descript return ph.printOnce(printed, desc, "Skipped ") } -// StopTracking stop tracked target. -func (ph *TTYPullHandler) StopTracking() { - ph.tracked.Close() +// Close implements io.Closer. +func (ph *TTYPullHandler) Close() error { + return ph.tracked.Close() } // TrackTarget returns a tracked target. diff --git a/cmd/oras/root/pull.go b/cmd/oras/root/pull.go index ea9083bed..59939ba16 100644 --- a/cmd/oras/root/pull.go +++ b/cmd/oras/root/pull.go @@ -162,7 +162,7 @@ func doPull(ctx context.Context, src oras.ReadOnlyTarget, dst oras.GraphTarget, if err != nil { return ocispec.Descriptor{}, false, nil, err } - defer statusHandler.StopTracking() + defer statusHandler.Close() var printed sync.Map var getConfigOnce sync.Once var layerSkipped atomic.Bool