From 83a8be4f913c94f85a127b32fd260814370ee7a5 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 11 Dec 2024 12:37:19 +0000 Subject: [PATCH] chore: clean code of json metadata output for attach Signed-off-by: Billy Zha --- cmd/oras/internal/display/metadata/json/attach.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/oras/internal/display/metadata/json/attach.go b/cmd/oras/internal/display/metadata/json/attach.go index 91cda78b2..a684534f6 100644 --- a/cmd/oras/internal/display/metadata/json/attach.go +++ b/cmd/oras/internal/display/metadata/json/attach.go @@ -27,9 +27,9 @@ import ( // AttachHandler handles json metadata output for attach events. type AttachHandler struct { - out io.Writer - target *option.Target - root ocispec.Descriptor + out io.Writer + path string + root ocispec.Descriptor } // NewAttachHandler creates a new handler for attach events. @@ -41,11 +41,11 @@ func NewAttachHandler(out io.Writer) metadata.AttachHandler { // OnAttached implements AttachHandler. func (ah *AttachHandler) OnAttached(target *option.Target, root ocispec.Descriptor, _ ocispec.Descriptor) { - ah.target = target + ah.path = target.Path ah.root = root } // Render is called when the attach command is completed. func (ah *AttachHandler) Render() error { - return output.PrintPrettyJSON(ah.out, model.NewAttach(ah.root, ah.target.Path)) + return output.PrintPrettyJSON(ah.out, model.NewAttach(ah.root, ah.path)) }