Skip to content

Commit

Permalink
fix: missing Oci-Subject header pushing index with subject
Browse files Browse the repository at this point in the history
Also, run OCI conformance tests from HEAD (vs. 1.0.0)

Signed-off-by: Josh Dolitsky <[email protected]>
  • Loading branch information
jdolitsky committed Jul 5, 2023
1 parent 96d9d31 commit 18f9c3f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
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
}

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
}

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

artifactType = zcommon.GetIndexArtifactType(index)
}

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

0 comments on commit 18f9c3f

Please sign in to comment.