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

Enable CLI to Pull Config #274

Merged
merged 5 commits into from
May 18, 2021
Merged

Enable CLI to Pull Config #274

merged 5 commits into from
May 18, 2021

Conversation

shizhMSFT
Copy link
Contributor

@shizhMSFT shizhMSFT commented May 17, 2021

Add a new option named --manifest-config to oras pull so that oras can pull the config file as well even if the config is not named. Like oras push, file name with media type should be passed to the --manifest-config option. The media type is optional and its default value is application/vnd.unknown.config.v1+json. The resulted config will be written to the specified file name.

Examples:

$ oras pull --manifest-config config.json localhost:5000/hello:latest
Downloaded a948904f2f0f hi.txt
Downloaded 57f840b6073c config.json
Pulled localhost:5000/hello:latest
Digest: sha256:a5d8f401e10aa320bd7ecabbfbabb89b0e59e599c9fdc6587edbffaf232fa4f3
$ oras pull --manifest-config config.json:application/vnd.unknown.config.v1+json localhost:5000/hello:latest
Downloaded a948904f2f0f hi.txt
Downloaded 57f840b6073c config.json
Pulled localhost:5000/hello:latest
Digest: sha256:a5d8f401e10aa320bd7ecabbfbabb89b0e59e599c9fdc6587edbffaf232fa4f3

Signed-off-by: Shiwei Zhang <[email protected]>
@shizhMSFT shizhMSFT changed the title Allow CLI to Pull Config Enable CLI to Pull Config May 17, 2021
shizhMSFT added 2 commits May 17, 2021 18:50
Signed-off-by: Shiwei Zhang <[email protected]>
@deitch
Copy link
Contributor

deitch commented May 17, 2021

What does passing the media-type do, though? What is the difference in behaviour between passing it or not?

@shizhMSFT
Copy link
Contributor Author

oras needs to know the media type of the config file. If the config media type does not match, oras drop the config. That also achieves sort of optional config.

Of course, we can pull any configs but it requires the oras command line module to fetch the manifest from the complex storage and parse the manifest.

@shizhMSFT shizhMSFT merged commit d400de2 into main May 18, 2021
@shizhMSFT shizhMSFT deleted the shizh/pull_config branch May 18, 2021 03:01
@SteveLasker
Copy link
Contributor

Sorry I couldn't review yesterday.

Why should we have to specify the --manifest-config for oras pull? This means a consumer would have to know the fully qualified reference demo42.azurecr.io/hello-artifact:v1 and the config: --manifest-config config.json:application/vnd.acme.rocket.config

Repro steps

  1. Run CNCF distribution locally
 docker run -it --rm -p 5000:5000 registry
  1. Create a config, and document
echo "hello config" > config.json
echo "hello artifact" > artifact.txt
  1. Push the artifact, and the config
oras push localhost:5000/hello-artifact:v1 \
  --manifest-config config.json:application/vnd.acme.rocket.config \
  ./artifact.txt
  1. Create a download directory
mkdir download
cd download
  1. Pull the artifact
oras pull localhost:5000/hello-artifact:v1 \
  --manifest-config config.json

Results

Only the artifact.txt file is returned. The config is missing:

ls
artifact.txt

Workaround

Specify the config mediaType

oras pull localhost:5000/hello-artifact:v1 \
  --manifest-config config.json:application/vnd.acme.rocket.config

Expectation

The config is pulled, as the user shouldn't have to know the fully qualified URL and the config mediaType. The config mediaType is internal details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants