Skip to content

Commit

Permalink
feat: update the implementation of deleting manifest for distribution…
Browse files Browse the repository at this point in the history
…-spec v1.1.0-rc3 (#558)

Support deleting image indexes with a subject

Resolves: #535
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
  • Loading branch information
Wwwsylvia committed Jul 27, 2023
1 parent 79d7081 commit 6ec43e7
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 45 deletions.
12 changes: 8 additions & 4 deletions registry/remote/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,8 @@ func (s *manifestStore) Delete(ctx context.Context, target ocispec.Descriptor) e
// deleteWithIndexing removes the manifest content identified by the descriptor,
// and indexes referrers for the manifest when needed.
func (s *manifestStore) deleteWithIndexing(ctx context.Context, target ocispec.Descriptor) error {
if target.MediaType == spec.MediaTypeArtifactManifest || target.MediaType == ocispec.MediaTypeImageManifest {
switch target.MediaType {
case spec.MediaTypeArtifactManifest, ocispec.MediaTypeImageManifest, ocispec.MediaTypeImageIndex:
if state := s.repo.loadReferrersState(); state == referrersStateSupported {
// referrers API is available, no client-side indexing needed
return s.repo.delete(ctx, target, true)
Expand All @@ -1100,9 +1101,12 @@ func (s *manifestStore) deleteWithIndexing(ctx context.Context, target ocispec.D
return s.repo.delete(ctx, target, true)
}

// indexReferrersForDelete indexes referrers for image or artifact manifest with
// the subject field on manifest delete.
// Reference: https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc1/spec.md#deleting-manifests
// indexReferrersForDelete indexes referrers for manifests with a subject field
// on manifest delete.
//
// References:
// - https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc3/spec.md#deleting-manifests
// - https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc1/spec.md#deleting-manifests
func (s *manifestStore) indexReferrersForDelete(ctx context.Context, desc ocispec.Descriptor, manifestJSON []byte) error {
var manifest struct {
Subject *ocispec.Descriptor `json:"subject"`
Expand Down
Loading

0 comments on commit 6ec43e7

Please sign in to comment.