action/push: remove unused WithPushOptWriter and out field

cmd/push: implement WriteTable to emit ref and digest

The WithPushOptWriter option and the out field on Push were never
wired to any meaningful output path — ChartUploader.Out is not read
by UploadTo() and the registry client manages its own writer.
Remove them to avoid dead API surface.

WriteTable now writes a tab-aligned REF/DIGEST result to the
command's stdout stream. The registry client continues to write
its own progress output to stderr, so there is no duplication.

Signed-off-by: Mentigen <mentigen@mentigen.ru>
Signed-off-by: Ilya Kiselev <kis-ilya-a@yandex.ru>
pull/32009/head
Ilya Kiselev 1 month ago
parent 0b9946ae61
commit 5a093e9d8e

@ -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{}

@ -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

@ -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)
}
}

Loading…
Cancel
Save