Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oras push: support streamed uploading from stdin #1200

Open
qweeah opened this issue Dec 11, 2023 · 2 comments
Open

oras push: support streamed uploading from stdin #1200

qweeah opened this issue Dec 11, 2023 · 2 comments
Labels
enhancement New feature or request question Further information is requested
Milestone

Comments

@qweeah
Copy link
Contributor

qweeah commented Dec 11, 2023

Are there any plans to implement this also for the input so that something like the following will be possible:

command-a | command-b | oras push localhost:5000/json-artifact:v1 -

...

oras pull localhost:5000/json-artifact:v1 --output - | jq

Originally posted by @ProbstDJakob in #346 (comment)

@qweeah qweeah added enhancement New feature or request question Further information is requested labels Dec 11, 2023
@qweeah
Copy link
Contributor Author

qweeah commented Dec 11, 2023

Regarding the user experience, here are some to-be-settled designs we need to think of:

  1. How should user provide the name of the blob from stdin?
  2. Besides from tar -c ...., what are the possible commands that can generate the to-be-uploaded stdin? (Asking since oras push <artifact> <folder> can already natively tar and upload the <folder> without invoking tar)

@qweeah qweeah added the triage New issues or PRs to be acknowledged by maintainers label Dec 11, 2023
@ProbstDJakob
Copy link

The following script is a real world example where streaming could come in handy.

Background

We fully manage the life cycle of an OpenShift cluster via a GitLab Pipeline. When creating a cluster with the openshift-install tool some files like terraform state and kube-configs will be created. Those files are needed during the whole life cycle of the cluster (not only in the current pipeline), thus they need to be stored persistently. In our case we use the existing GitLab registry and oras to create an image.

Current way to push the artifacts to the registry

#!/usr/bin/env sh
set -eu

# [...] some preparations

git ls-tree --name-only -r --full-tree HEAD "$CI_PROJECT_DIR/openshift-install" \
  | tar -czC "$CI_PROJECT_DIR" --exclude-from=- openshift-install \
  | sops --encrypt --input-type binary --output-type binary --output "$CI_PROJECT_DIR/openshift-install-artifacts.tar.gz.enc" /dev/stdin

cd "$CI_PROJECT_DIR"
oras push "$ENCRYPTED_OPENSHIFT_INSTALL_ARTIFACTS_IMAGE" openshift-install-artifacts.tar.gz.enc

Possible way to push the artifacts to the registry with pipelining

#!/usr/bin/env sh
set -eu

# [...] some preparations

git ls-tree --name-only -r --full-tree HEAD "$CI_PROJECT_DIR/openshift-install" \
  | tar -czC "$CI_PROJECT_DIR" --exclude-from=- openshift-install \
  | sops --encrypt --input-type binary --output-type binary /dev/stdin \
  | oras push "$ENCRYPTED_OPENSHIFT_INSTALL_ARTIFACTS_IMAGE" -

This way there is no need to create a temporary file and make sure to be in the correct directory in order to include the file without an absolute path which would make the image unable to unpack in other environments (OSs).

Counterpart

See #346 (comment)

@yizha1 yizha1 removed the triage New issues or PRs to be acknowledged by maintainers label Dec 12, 2023
@yizha1 yizha1 added this to the future milestone Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants