Skip to content

oras push: support streamed uploading from stdin #2409

Todo

Description

@TerryHowe

Supersedes #1200, which carried the original request and discussion. This issue restates it with an evaluation of the current state, so implementation can start from a settled design.

Request

Allow piping content straight into a push, without a temporary file:

tar -cz dir | sops --encrypt --input-type binary --output-type binary /dev/stdin \
  | oras push localhost:5000/artifact:v1 -

The pull side (oras pull --output -) was #346.

Feasibility

The library work that used to block this is done. oras-go v3.0.0, which the CLI already depends on, ships content.UnsafePusher. It computes the digest and size while writing. The remote repository (chunked upload, 8 MiB buffers), oci.Store (--oci-layout) and memory.Store all implement it.

What's left is CLI work, and three structural points make it more than adding a flag:

  1. oras push stages layers in a file store. runPush builds a file.Store, loadFiles adds every layer from a path, then the command packs a manifest and runs oras.Copy from a union of the memory and file stores. file.Store doesn't implement UnsafePush and can't take a stream. The stdin layer has to go straight to the destination with UnsafePush before PackManifest, and its returned descriptor joins the layer list. CopyGraph checks the destination first, so it skips that layer.
  2. The progress wrappers hide the interface. track.NewTarget wraps the destination in graphTarget and variants, so a type check for content.UnsafePusher fails. The wrappers must forward UnsafePush, or the stdin push uses the unwrapped target (no progress bar for that layer).
  3. Stdin can only be read once. If a remote push fails midway there's no retry. Per the oras-go docs, the push fails outright when the registry doesn't support chunked uploads or advertises OCI-Chunk-Min-Length above 32 MiB.

Risks

  • Registry compatibility is the main one: registries without chunked upload fail after stdin is consumed. Needs a clear error pointing to a temp-file workaround; an optional spool-to-temp fallback is worth considering.
  • Size limit: oras-go's default cap is 4 GiB (ErrSizeExceedsLimit); document it.
  • Stdin conflicts: - with --password-stdin / --identity-token-stdin must be rejected. Reuse option.CheckStdinConflict, as blob push and manifest push already do.
  • Backward compatibility: low. - is new syntax for oras push; for oras blob push, dropping the --size/digest requirement only loosens a check. A supplied digest must still be verified.

Proposed UX (to settle before coding)

  • Name: require an explicit name (--stdin-name <name>, or a title for "-" in --annotation-file) instead of silently defaulting to stdin.bin. A default can be added later without breaking anyone; removing one would be a breaking change.
  • Media type: --stdin-media-type <type>, defaulting to the same layer media type used for files. This replaces the -:<type> form, which needs a -- before it because pflag reads -: as a flag (oras push ref -- -:application/json). The --stdin- prefix pairs with --stdin-name; a --media-type-stdin spelling would wrongly suggest the media type itself is read from stdin, as --password-stdin reads the password.
  • Count: - at most once, alongside any number of normal files.
  • Stdin is exclusive: - cannot be combined with --password-stdin or --identity-token-stdin, since only one of them can consume stdin. Reject the combination up front with option.CheckStdinConflict, before anything is read or pushed, as oras blob push - and oras manifest push - already do.
cat data.json | oras push localhost:5000/artifact:v1 - \
  --stdin-name data.json --stdin-media-type application/json

Suggested plan

  1. oras blob push first, as its own PR. When --size or the digest is missing, use UnsafePush and print the computed digest. Update the examples.
  2. oras push: pull - out of the file references before loadFiles; push it with UnsafePush (media type + title annotation, Size: -1, no digest); merge --annotation-file annotations; add the descriptor to the layers; pack and copy as usual. Handle --dry-run (must not read stdin, or reject -) and --oci-layout.
  3. Progress: add an UnsafePush passthrough to the track wrappers, or ship without progress for the stdin layer and follow up.
  4. Tests:
    • unit: parsing -, conflict checks, name resolution, Windows fileref parsing
    • e2e: pipe into oras push then oras pull and compare; stdin plus normal files; oras blob push with no --size; mismatched supplied digest fails; --oci-layout target; - with --password-stdin rejected; empty stdin (0-byte layer); stdin layer already present in the registry

Related code

Location Why
cmd/oras/root/push.go (runPush, doPushCommand) file store setup, union source, pack and copy; the stdin layer goes here
cmd/oras/root/file.go (loadFiles, addFile) title annotation and name resolution to reuse
cmd/oras/root/blob/push.go current stdin path requiring --size
internal/file/file.go (PrepareBlobContent) size/digest checks to relax
cmd/oras/internal/display/status/track/target.go wrappers that hide UnsafePusher
cmd/oras/internal/option/remote.go (CheckStdinConflict) stdin conflict check
cmd/oras/internal/fileref/{unix,windows}.go path:mediaType parsing
oras-go content/storage.go, registry/remote/unsafe.go UnsafePusher contract; chunked-upload requirement
Tests: cmd/oras/root/push_test.go, cmd/oras/root/blob/push_test.go, internal/file/file_test.go, cmd/oras/internal/fileref/*_test.go, test/e2e/suite/command/{push,blob}.go existing coverage to extend

@ShravanthReddy offered to take this in #1200 with a working branch, and the plan above is close to theirs. Feedback on the UX points is welcome here.

Activity

  1. added
    enhancement
    help wanted
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions