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

fix: missing Oci-Subject header pushing index with subject #1586

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/oci-conformance-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,29 @@ jobs:
RUNNER_TRACKING_ID="" && ./bin/zot-linux-amd64 serve examples/config-conformance.json &
IP=`hostname -I | awk '{print $1}'`
echo "SERVER_URL=http://${IP}:8080" >> $GITHUB_ENV
- name: Run OCI Distribution Spec conformance tests
uses: opencontainers/distribution-spec@main
- name: Checkout OCI distribution-spec at HEAD
uses: actions/checkout@v3
with:
path: distribution-spec
# TODO: change to upstream once the foloowing PR is merged:
# https://github.com/opencontainers/distribution-spec/pull/436
repository: sudo-bmitch/distribution-spec
ref: pr-conformance-index-subject
- name: Build and run OCI distribution-spec conformance from HEAD
env:
OCI_ROOT_URL: ${{ env.SERVER_URL }}
OCI_NAMESPACE: oci-conformance/distribution-test
OCI_TEST_PULL: 1
OCI_TEST_PUSH: 1
OCI_TEST_CONTENT_DISCOVERY: 1
OCI_TEST_CONTENT_MANAGEMENT: 1
OCI_REFERRERS: 1
OCI_HIDE_SKIPPED_WORKFLOWS: 1
run: |
set -x
(cd distribution-spec/ && make conformance-binary)
mv distribution-spec/output/conformance.test .
rm -rf distribution-spec/
./conformance.test
- run: mkdir -p .out/ && mv {report.html,junit.xml} .out/
if: always()
#run: docker run --rm -v $(pwd)/results:/results -w /results -e OCI_ROOT_URL=${{ env.OCI_ROOT_URL }} -e OCI_NAMESPACE="anuvu/zot" -e OCI_TEST_PULL=1 -e OCI_TEST_PUSH=1 -e OCI_TEST_CONTENT_DISCOVERY=1 -e OCI_TEST_CONTENT_MANAGEMENT=1 -e OCI_HIDE_SKIPPED_WORKFLOWS=0 -e OCI_DEBUG="true" ghcr.io/opencontainers/distribution-spec/conformance:db4cc68
Expand Down
13 changes: 13 additions & 0 deletions pkg/storage/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,19 @@ func (is *ImageStoreLocal) PutImageManifest(repo, reference, mediaType string, /
}

artifactType = zcommon.GetManifestArtifactType(manifest)
} else if mediaType == ispec.MediaTypeImageIndex {
var index ispec.Index

err := json.Unmarshal(body, &index)
if err != nil {
return "", "", err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this line cannot be covered by tests because the blob is already unmarshalled/validated at line 463

}

if index.Subject != nil {
subjectDigest = index.Subject.Digest
}

artifactType = zcommon.GetIndexArtifactType(index)
}

updateIndex, oldDgst, err := common.CheckIfIndexNeedsUpdate(&index, &desc, is.log)
Expand Down
13 changes: 13 additions & 0 deletions pkg/storage/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,19 @@ func (is *ObjectStorage) PutImageManifest(repo, reference, mediaType string, //n
}

artifactType = zcommon.GetManifestArtifactType(manifest)
} else if mediaType == ispec.MediaTypeImageIndex {
var index ispec.Index

err := json.Unmarshal(body, &index)
if err != nil {
return "", "", err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this line cannot be covered by tests because the blob is already unmarshalled/validated at line 374.

}

if index.Subject != nil {
subjectDigest = index.Subject.Digest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on a test to cover this.

}

artifactType = zcommon.GetIndexArtifactType(index)
}

updateIndex, oldDgst, err := common.CheckIfIndexNeedsUpdate(&index, &desc, is.log)
Expand Down