diff --git a/pkg/action/push.go b/pkg/action/push.go index 856a1993a..285005f86 100644 --- a/pkg/action/push.go +++ b/pkg/action/push.go @@ -36,7 +36,6 @@ type Push struct { caFile string insecureSkipTLSVerify bool plainHTTP bool - out io.Writer } // PushOpt is a type of function that sets options for a push action. @@ -72,13 +71,6 @@ func WithPlainHTTP(plainHTTP bool) PushOpt { } } -// WithPushOptWriter sets the registryOut field on the push configuration object. -func WithPushOptWriter(out io.Writer) PushOpt { - return func(p *Push) { - p.out = out - } -} - // NewPushWithOpts creates a new push, with configuration options. func NewPushWithOpts(opts ...PushOpt) *Push { p := &Push{} diff --git a/pkg/cmd/push.go b/pkg/cmd/push.go index a6f0168a4..1d135fa64 100644 --- a/pkg/cmd/push.go +++ b/pkg/cmd/push.go @@ -19,6 +19,7 @@ package cmd import ( "fmt" "io" + "text/tabwriter" "github.com/spf13/cobra" @@ -57,10 +58,14 @@ type pushWriter struct { result pushResult } -// WriteTable is a no-op for push: the registry client already prints -// "Pushed:" and "Digest:" to stderr, so we avoid duplicating that output. -func (w *pushWriter) WriteTable(_ io.Writer) error { - return nil +// WriteTable writes a minimal human-readable push result to the provided output. +// The registry client prints progress to stderr; this writes the structured +// result (ref + digest) to the command's stdout stream. +func (w *pushWriter) WriteTable(out io.Writer) error { + tw := tabwriter.NewWriter(out, 0, 0, 2, ' ', 0) + fmt.Fprintf(tw, "REF\t%s\n", w.result.Ref) + fmt.Fprintf(tw, "DIGEST\t%s\n", w.result.Digest) + return tw.Flush() } // WriteJSON writes the push result in JSON format diff --git a/pkg/cmd/push_test.go b/pkg/cmd/push_test.go index 964337ddd..177cb88c6 100644 --- a/pkg/cmd/push_test.go +++ b/pkg/cmd/push_test.go @@ -29,8 +29,6 @@ func TestPushFileCompletion(t *testing.T) { } func TestPushWriterTable(t *testing.T) { - // WriteTable is intentionally a no-op: the registry client already prints - // push details to stderr, so we avoid duplicating that output. w := &pushWriter{result: pushResult{ Ref: "oci://example.com/charts/mychart:1.0.0", Digest: "sha256:abc123", @@ -39,8 +37,15 @@ func TestPushWriterTable(t *testing.T) { if err := w.WriteTable(&buf); err != nil { t.Fatal(err) } - if got := buf.String(); got != "" { - t.Errorf("table output should be empty (registry client writes to stderr), got: %q", got) + got := buf.String() + if !strings.Contains(got, "REF") || !strings.Contains(got, "DIGEST") { + t.Errorf("table output missing headers, got: %q", got) + } + if !strings.Contains(got, "oci://example.com/charts/mychart:1.0.0") { + t.Errorf("table output missing Ref value, got: %q", got) + } + if !strings.Contains(got, "sha256:abc123") { + t.Errorf("table output missing Digest value, got: %q", got) } }