Skip to content

feat(push): add -o/--output flag (table|json|yaml) to helm push - #32475

Open
jojinkb wants to merge 1 commit into
helm:mainfrom
jojinkb:feat-push-output-json
Open

feat(push): add -o/--output flag (table|json|yaml) to helm push#32475
jojinkb wants to merge 1 commit into
helm:mainfrom
jojinkb:feat-push-output-json

Conversation

@jojinkb

@jojinkb jojinkb commented Jul 25, 2026

Copy link
Copy Markdown

What this PR does / why we need it:

helm push currently only prints a human-readable summary (Pushed: ... / Digest: ...), which makes it awkward to consume the pushed reference and manifest digest programmatically — e.g. to immediately sign the chart with cosign. This PR adds the standard -o/--output flag (table, json, yaml) to helm push, consistent with helm install, helm status, helm get metadata, etc.

$ helm push mychart-0.1.0.tgz oci://registry.example.com/charts -o json
{"ref":"registry.example.com/charts/mychart:0.1.0","digest":"sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55"}

$ helm push mychart-0.1.0.tgz oci://registry.example.com/charts -o yaml
digest: sha256:e5ef611620fb97704d8751c16bab17fedb68883bfb0edc76f78a70e9173f9b55
ref: registry.example.com/charts/mychart:0.1.0

closes #11735

How it works:

The OCI registry client already returns a *registry.PushResult, but OCIPusher discarded it, so the result never reached the CLI. This PR plumbs it through with purely additive functional options, keeping all public Go SDK signatures unchanged per HIP-0004:

  • pkg/pusher: new WithPushResultHandler(func(*registry.PushResult)) Option; OCIPusher invokes the handler after a successful push.
  • pkg/action: new WithPushResultHandler(...) PushOpt on the push action that forwards the handler to the pusher. Push.Run's signature is unchanged.
  • pkg/cmd: helm push binds the shared output flag, captures the result via the handler, and renders it with the existing pkg/cli/output machinery.

Special notes for your reviewer:

  • Default (table) output is byte-for-byte identical to today: the registry client keeps writing the Pushed:/Digest: summary (including the underscore warning) directly, exactly as before.
  • For json/yaml, the registry client's writer is set to io.Discard so stdout contains only the structured result (this also means the OCI "underscore in ref" warning is not printed in these modes; the ref itself is part of the structured output).
  • The structured output is intentionally minimal (ref + manifest digest, mirroring the table summary). More fields from registry.PushResult (chart/prov digests, sizes) can be added later without breaking consumers; happy to include them now if preferred.
  • The Pusher interface, uploader.UploadTo, and action.Push.Run signatures are deliberately untouched. feat(push): add --output json/yaml/table flag to helm push #32009 implements the same feature by changing those public signatures; this PR takes a non-breaking approach so it can land within v4.
  • The new TestPushCmd exercises the real push path end-to-end against the in-process repotest OCI registry (same infrastructure as TestPullCmd), asserting that -o json/-o yaml stdout parses cleanly and that table output is unchanged.

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

This change was developed with AI assistance (Claude Code); I have reviewed and tested it.

Adds the standard -o/--output flag to 'helm push' so the pushed
reference and manifest digest can be consumed programmatically
(e.g. to sign the chart with cosign).

The push result is plumbed from the OCI registry client to the CLI
through a new, purely additive functional option
(pusher.WithPushResultHandler / action.WithPushResultHandler), so no
public Go SDK signatures change (HIP-0004). The default table output
is byte-for-byte identical to the previous behavior; for json/yaml
the registry client's human-readable summary is suppressed so stdout
contains only the structured result.

Closes helm#11735

Signed-off-by: Jojin <jojin.kb@gmail.com>
@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 25, 2026
@github-actions github-actions Bot added the v4.x Issues and Pull Requests related to the major version v4 label Jul 25, 2026
promptless-for-oss pushed a commit to Promptless/oss-contrib-helm-helm-www that referenced this pull request Jul 25, 2026
…havior)

Enhance the machine-readable output section for helm push: add the -o
short form, a yaml example, a ref/digest field list, and a note on
structured-only stdout in json/yaml modes. Relocate the subsection to
the end of the push subcommand section.

Verified against helm/helm#32475.

Signed-off-by: promptless[bot] <promptless[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files. v4.x Issues and Pull Requests related to the major version v4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Support --output json flag for helm push

1 participant