-
Notifications
You must be signed in to change notification settings - Fork 174
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
Add OCI Conformance validation with ORAS #257
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# OCI Artifact Registry Conformance Testing | ||
|
||
How do you know a specific registry supports [OCI Artifacts][oci-artifacts]? The following basic tests may be performed against a specific registry to validate the registry provides the extensibility in `mediaTypes`. | ||
|
||
OCI Artifacts uses the `manifest.config.mediaType` to determine what the artifact is. This would be the equivalent of a file extension. | ||
|
||
For a registry to be OCI Artifact capable, it would need to: | ||
|
||
- Accept any value for `oci.image.manifest.config.mediaType` | ||
- Accept any value for `oci.layer.mediaType` | ||
- Accept an empty config object. See [oras config](./config.md) | ||
|
||
For more information on defining an OCI Artifact, see [Artifact Authors Guidance](https://github.com/opencontainers/artifacts/blob/master/artifact-authors.md) | ||
|
||
The following steps use the `oras` cli to push and pull artifacts, testing the restrictions a registry may be applying to the `mediaTypes`, and any logic around parsing the `manifest.config` object to determine platform features of a container image. | ||
|
||
## Environment Variables | ||
|
||
Create a few environment variables to make it easier to execute the commands with copy/paste: | ||
|
||
```bash | ||
REGISTRY=registry.example.io | ||
USER=me | ||
PASSWD=myPassword | ||
REPO=hello-artifact | ||
``` | ||
|
||
## Content Creation | ||
|
||
Create a few files for testing the pushing and pulling of content. | ||
|
||
```bash | ||
mkdir artifact-validation | ||
cd artifact-validation | ||
|
||
echo "Here is an artifact" > artifact.txt | ||
mkdir subdir-1 | ||
cd subdir-1 | ||
echo "sub directory 1 content" > artifact-1-1.txt | ||
echo "sub directory 1 content" > artifact-1-2.txt | ||
cd ../ | ||
|
||
mkdir subdir-2 | ||
cd subdir-2 | ||
echo "sub directory 2 content" > artifact-2-1.txt | ||
echo "sub directory 2 content" > artifact-2-2.txt | ||
cd ../ | ||
|
||
echo '{"version": "0.0.0.0", "name": "value"}' > artifact-config.json | ||
|
||
mkdir output | ||
``` | ||
|
||
## Authenticate with the Registry | ||
|
||
Assuming the registry supports basic auth, login: | ||
|
||
```bash | ||
oras login -u $USER -p $PASSWD $REGISTRY | ||
``` | ||
|
||
## Push with an Artifact Specific Config | ||
|
||
Push a single file artifact, with an artifact specific config object. | ||
|
||
- The `manifest.config` has something specific to the `x.sample` artifact. Since the object isn't of type `application/vnd.docker.container.image.v1+json`, all registry viewing tools should just ignore the content. | ||
- The `manifest.config.mediaType=application/x.sample` | ||
- The `layer.mediaType=application/txt` | ||
- Layer content = `artifact.txt` | ||
|
||
```bash | ||
oras push ${REGISTRY}/$REPO:artifact-config \ | ||
--manifest-config ./artifact-config.json:application/x.sample.v1+json \ | ||
./artifact.txt:application/txt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would you like to use recommended mime types like text/plain? |
||
|
||
oras pull \ | ||
--allow-all \ | ||
--output ./output \ | ||
${REGISTRY}/$REPO:artifact-config | ||
|
||
ls ./output/ | ||
rm ./output/*.* | ||
``` | ||
|
||
## Push Empty Config, Single File | ||
|
||
Push a single file artifact, with a null config. | ||
|
||
- The `manifest.config` object is empty. See [oras config](./config.md) for more details. | ||
- The `manifest.config.mediaType=application/x.sample` | ||
- The `layer.mediaType=application/txt` | ||
- Layer content = `artifact.txt` | ||
|
||
```bash | ||
oras push ${REGISTRY}/$REPO:empty-config \ | ||
--manifest-config /dev/null:application/x.sample \ | ||
./artifact.txt:application/txt | ||
|
||
oras pull \ | ||
--allow-all \ | ||
--output ./output \ | ||
${REGISTRY}/$REPO:empty-config | ||
|
||
ls ./output/ | ||
rm ./output/*.* | ||
``` | ||
|
||
## Push Empty Config, SubDirector | ||
|
||
Push a single file artifact, with a null config. | ||
|
||
- The `manifest.config` object is empty. See [oras config](./config.md) for more details. | ||
- The `manifest.config.mediaType=application/x.sample` | ||
- The `layer.mediaType=application/txt` | ||
- Layer content = a sub directory of a few files, which oras will create tar. | ||
|
||
```bash | ||
oras push ${REGISTRY}/$REPO:multi-file-tar \ | ||
--manifest-config /dev/null:application/x.sample \ | ||
./subdir-1/:application/tar | ||
|
||
oras pull \ | ||
--allow-all \ | ||
--output ./output \ | ||
${REGISTRY}/$REPO:multi-file-tar | ||
|
||
tree ./output/ | ||
rm -r ./output/subdir | ||
``` | ||
|
||
## Push Empty Config, Multiple SubDirectories | ||
|
||
Push a single file artifact, with a null config. | ||
|
||
- The `manifest.config` object is empty. See [oras config](./config.md) for more details. | ||
- The `manifest.config.mediaType=application/x.sample` | ||
- The `layer.mediaType=application/txt` | ||
- Layer contents = two sub directories of a few files, which oras will create tar as separate layers (blobs). | ||
|
||
```bash | ||
oras push ${REGISTRY}/$REPO:multi-dir-tar \ | ||
--manifest-config /dev/null:application/x.sample \ | ||
./subdir-1/:application/tar \ | ||
./subdir-2/:application/tar | ||
|
||
oras pull \ | ||
--allow-all \ | ||
--output ./output \ | ||
${REGISTRY}/$REPO:multi-dir-tar | ||
|
||
tree ./output/ | ||
rm -r ./output/subdir | ||
``` | ||
|
||
[oci-artifacts]: https://github.com/opencontainers/artifacts |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Distribution's auth model is bearer token and not basic. You could call out -