Skip to content

Commit aeee3be

Browse files
refactor(artifact): remove oci artifact support
1 parent ef51fd6 commit aeee3be

33 files changed

Lines changed: 317 additions & 1072 deletions

errors/errors.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ var (
6363
ErrManifestConflict = errors.New("manifest: multiple manifests found")
6464
ErrManifestMetaNotFound = errors.New("repodb: image metadata not found for given manifest reference")
6565
ErrManifestDataNotFound = errors.New("repodb: image data not found for given manifest digest")
66-
ErrArtifactDataNotFound = errors.New("repodb: artifact data not found for given digest")
6766
ErrIndexDataNotFount = errors.New("repodb: index data not found for given digest")
6867
ErrRepoMetaNotFound = errors.New("repodb: repo metadata not found for given repo name")
6968
ErrTagMetaNotFound = errors.New("repodb: tag metadata not found for given repo and tag names")

examples/config-dynamodb.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"cacheTablename": "ZotBlobTable",
2121
"repoMetaTablename": "ZotRepoMetadataTable",
2222
"manifestDataTablename": "ZotManifestDataTable",
23-
"artifactDataTablename": "ZotArtifactDataTable",
2423
"versionTablename": "ZotVersion"
2524
}
2625
},

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ require (
494494
)
495495

496496
replace (
497+
github.com/opencontainers/image-spec => github.com/project-zot/image-spec v0.0.0-20230407150525-6fa4879e23d2
497498
github.com/opencontainers/umoci => github.com/project-stacker/umoci v0.0.0-20230228184813-24efbd35e8ef
498499
// v0.3.1-0.20230104082527-d6f58551be3f is taken from github.com/moby/buildkit v0.11.0
499500
// spdx logic write on v0.3.0 and incompatible with v0.3.1-0.20230104082527-d6f58551be3f

go.sum

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,11 +1826,6 @@ github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQ
18261826
github.com/opencontainers/go-digest v1.0.0-rc1.0.20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
18271827
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
18281828
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
1829-
github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
1830-
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
1831-
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
1832-
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221020182949-4df8887994e8 h1:l9vfzobI7tZtG164u1Jf6NqDErHZoqAw8rlvBYQJpVI=
1833-
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221020182949-4df8887994e8/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ=
18341829
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
18351830
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
18361831
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
@@ -1920,6 +1915,8 @@ github.com/proglottis/gpgme v0.1.3 h1:Crxx0oz4LKB3QXc5Ea0J19K/3ICfy3ftr5exgUK1AU
19201915
github.com/proglottis/gpgme v0.1.3/go.mod h1:fPbW/EZ0LvwQtH8Hy7eixhp1eF3G39dtx7GUN+0Gmy0=
19211916
github.com/project-stacker/umoci v0.0.0-20230228184813-24efbd35e8ef h1:PMJXsXS3x5tiwsRrFgMSnjKmeH5c9ppFXrS5NKdIPEo=
19221917
github.com/project-stacker/umoci v0.0.0-20230228184813-24efbd35e8ef/go.mod h1:smZzWUkoRRHivXkcHQN7n+KGHVfR+HKJrtCaI8cMifg=
1918+
github.com/project-zot/image-spec v0.0.0-20230407150525-6fa4879e23d2 h1:Ai5WR7z82o9nNk2XC5MHz0dZkV01zKHOoW339Bn0EY0=
1919+
github.com/project-zot/image-spec v0.0.0-20230407150525-6fa4879e23d2/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8=
19231920
github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
19241921
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
19251922
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=

pkg/api/controller_test.go

Lines changed: 3 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import (
5151
"zotregistry.io/zot/pkg/log"
5252
"zotregistry.io/zot/pkg/meta/repodb/repodbfactory"
5353
"zotregistry.io/zot/pkg/storage"
54-
storageConstants "zotregistry.io/zot/pkg/storage/constants"
5554
"zotregistry.io/zot/pkg/storage/local"
5655
"zotregistry.io/zot/pkg/test"
5756
)
@@ -3457,6 +3456,7 @@ func TestCrossRepoMount(t *testing.T) {
34573456
// wait for dedupe task to run
34583457
time.Sleep(15 * time.Second)
34593458

3459+
// TODO: What is happening here?
34603460
params["mount"] = string(manifestDigest)
34613461
postResponse, err = client.R().
34623462
SetBasicAuth(username, passphrase).SetQueryParams(params).
@@ -4156,6 +4156,8 @@ func TestImageSignatures(t *testing.T) {
41564156
})
41574157
}
41584158

4159+
// TODO: Refactor
4160+
// Here are notes to follow:
41594161
func TestArtifactReferences(t *testing.T) {
41604162
Convey("Validate Artifact References", t, func() {
41614163
// start a new server
@@ -4300,138 +4302,6 @@ func TestArtifactReferences(t *testing.T) {
43004302
So(resp.Header().Get("Content-Type"), ShouldEqual, ispec.MediaTypeImageIndex)
43014303
})
43024304
})
4303-
4304-
Convey("Validate Artifact Manifest Reference", func() {
4305-
resp, err := resty.R().Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", repoName, digest.String()))
4306-
So(err, ShouldBeNil)
4307-
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
4308-
4309-
var referrers ispec.Index
4310-
err = json.Unmarshal(resp.Body(), &referrers)
4311-
So(err, ShouldBeNil)
4312-
So(referrers.Manifests, ShouldBeEmpty)
4313-
4314-
// now upload a reference
4315-
4316-
// upload image config blob
4317-
resp, err = resty.R().Post(baseURL + fmt.Sprintf("/v2/%s/blobs/uploads/", repoName))
4318-
So(err, ShouldBeNil)
4319-
So(resp.StatusCode(), ShouldEqual, http.StatusAccepted)
4320-
loc := test.Location(baseURL, resp)
4321-
cblob, cdigest := test.GetEmptyImageConfig()
4322-
4323-
resp, err = resty.R().
4324-
SetContentLength(true).
4325-
SetHeader("Content-Length", fmt.Sprintf("%d", len(cblob))).
4326-
SetHeader("Content-Type", "application/octet-stream").
4327-
SetQueryParam("digest", cdigest.String()).
4328-
SetBody(cblob).
4329-
Put(loc)
4330-
So(err, ShouldBeNil)
4331-
So(resp.StatusCode(), ShouldEqual, http.StatusCreated)
4332-
4333-
// create a artifact
4334-
manifest := ispec.Artifact{
4335-
MediaType: ispec.MediaTypeArtifactManifest,
4336-
ArtifactType: artifactType,
4337-
Blobs: []ispec.Descriptor{
4338-
{
4339-
MediaType: "application/vnd.oci.image.layer.v1.tar",
4340-
Digest: digest,
4341-
Size: int64(len(content)),
4342-
},
4343-
},
4344-
Subject: &ispec.Descriptor{
4345-
MediaType: ispec.MediaTypeImageManifest,
4346-
Digest: digest,
4347-
Size: int64(len(content)),
4348-
},
4349-
Annotations: map[string]string{
4350-
"key": "val",
4351-
},
4352-
}
4353-
Convey("Using invalid content", func() {
4354-
content := []byte("invalid data")
4355-
So(err, ShouldBeNil)
4356-
mdigest := godigest.FromBytes(content)
4357-
So(mdigest, ShouldNotBeNil)
4358-
resp, err = resty.R().SetHeader("Content-Type", ispec.MediaTypeArtifactManifest).
4359-
SetBody(content).Put(baseURL + fmt.Sprintf("/v2/%s/manifests/%s", repoName, mdigest.String()))
4360-
So(err, ShouldBeNil)
4361-
So(resp.StatusCode(), ShouldEqual, http.StatusBadRequest)
4362-
4363-
// unknown repo will return status not found
4364-
resp, err = resty.R().Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", "unknown", digest.String()))
4365-
So(err, ShouldBeNil)
4366-
So(resp.StatusCode(), ShouldEqual, http.StatusNotFound)
4367-
4368-
resp, err = resty.R().Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", repoName, digest.String()))
4369-
So(err, ShouldBeNil)
4370-
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
4371-
4372-
resp, err = resty.R().SetQueryParams(map[string]string{"artifactType": artifactType}).
4373-
Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", repoName, digest.String()))
4374-
So(err, ShouldBeNil)
4375-
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
4376-
})
4377-
Convey("Using valid content", func() {
4378-
content, err = json.Marshal(manifest)
4379-
So(err, ShouldBeNil)
4380-
mdigest := godigest.FromBytes(content)
4381-
So(mdigest, ShouldNotBeNil)
4382-
resp, err = resty.R().SetHeader("Content-Type", ispec.MediaTypeArtifactManifest).
4383-
SetBody(content).Put(baseURL + fmt.Sprintf("/v2/%s/manifests/%s", repoName, mdigest.String()))
4384-
So(err, ShouldBeNil)
4385-
So(resp.StatusCode(), ShouldEqual, http.StatusCreated)
4386-
4387-
resp, err = resty.R().Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", repoName, digest.String()))
4388-
So(err, ShouldBeNil)
4389-
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
4390-
4391-
resp, err = resty.R().SetQueryParams(map[string]string{"artifact": "invalid"}).
4392-
Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", repoName, digest.String()))
4393-
So(err, ShouldBeNil)
4394-
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
4395-
4396-
resp, err = resty.R().SetQueryParams(map[string]string{"artifactType": "invalid"}).
4397-
Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", repoName, digest.String()))
4398-
So(err, ShouldBeNil)
4399-
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
4400-
4401-
resp, err = resty.R().SetQueryParams(map[string]string{"artifactType": artifactType}).
4402-
Get(baseURL + fmt.Sprintf("/v2/%s/referrers/%s", repoName, digest.String()))
4403-
So(err, ShouldBeNil)
4404-
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
4405-
So(resp.Header().Get("Content-Type"), ShouldEqual, ispec.MediaTypeImageIndex)
4406-
4407-
var index ispec.Index
4408-
err = json.Unmarshal(resp.Body(), &index)
4409-
So(err, ShouldBeNil)
4410-
So(index.Manifests, ShouldNotBeEmpty)
4411-
So(index.Annotations[storageConstants.ReferrerFilterAnnotation], ShouldNotBeEmpty)
4412-
4413-
// filter by multiple artifactTypes
4414-
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet,
4415-
baseURL+fmt.Sprintf("/v2/%s/referrers/%s", repoName, digest.String()), nil)
4416-
So(err, ShouldBeNil)
4417-
values := url.Values{}
4418-
values.Add("artifactType", artifactType)
4419-
values.Add("artifactType", "foobar")
4420-
req.URL.RawQuery = values.Encode()
4421-
rsp, err := http.DefaultClient.Do(req)
4422-
So(err, ShouldBeNil)
4423-
defer rsp.Body.Close()
4424-
So(rsp.StatusCode, ShouldEqual, http.StatusOK)
4425-
So(rsp.Header.Get("Content-Type"), ShouldEqual, ispec.MediaTypeImageIndex)
4426-
body, err := io.ReadAll(rsp.Body)
4427-
So(err, ShouldBeNil)
4428-
err = json.Unmarshal(body, &index)
4429-
So(err, ShouldBeNil)
4430-
So(index.Manifests, ShouldNotBeEmpty)
4431-
So(index.Annotations[storageConstants.ReferrerFilterAnnotation], ShouldNotBeEmpty)
4432-
So(len(strings.Split(index.Annotations[storageConstants.ReferrerFilterAnnotation], ",")), ShouldEqual, 2)
4433-
})
4434-
})
44354305
})
44364306
}
44374307

pkg/cli/client.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,8 @@ func isNotationSigned(ctx context.Context, repo, digestStr string, searchConf se
490490
return false
491491
}
492492

493-
for _, reference := range referrers.Manifests {
494-
if reference.ArtifactType == notreg.ArtifactTypeNotation {
495-
return true
496-
}
493+
if len(referrers.Manifests) > 0 {
494+
return true
497495
}
498496

499497
return false

pkg/common/common.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"unicode/utf8"
1818

1919
"github.com/opencontainers/go-digest"
20+
ispec "github.com/opencontainers/image-spec/specs-go/v1"
2021

2122
"zotregistry.io/zot/pkg/log"
2223
)
@@ -245,3 +246,11 @@ func DContains(slice []digest.Digest, item digest.Digest) bool {
245246

246247
return false
247248
}
249+
250+
func GetManifestArtifactType(manifestContent ispec.Manifest) string {
251+
if manifestContent.ArtifactType != "" {
252+
return manifestContent.ArtifactType
253+
}
254+
255+
return manifestContent.Config.MediaType
256+
}

pkg/extensions/search/convert/repodb.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,14 @@ func ImageManifest2ImageSummary(ctx context.Context, repo, tag string, digest go
288288

289289
var configContent ispec.Image
290290

291-
err = json.Unmarshal(manifestMeta.ConfigBlob, &configContent)
292-
if err != nil {
293-
graphql.AddError(ctx, gqlerror.Errorf("can't unmarshal config blob for image: %s:%s, manifest digest: %s, error: %s",
294-
repo, tag, manifestDigest, err.Error()))
291+
if manifestContent.Config.MediaType == ispec.MediaTypeImageConfig {
292+
err = json.Unmarshal(manifestMeta.ConfigBlob, &configContent)
293+
if err != nil {
294+
graphql.AddError(ctx, gqlerror.Errorf("can't unmarshal config blob for image: %s:%s, manifest digest: %s, error: %s",
295+
repo, tag, manifestDigest, err.Error()))
295296

296-
return &gql_generated.ImageSummary{}, map[string]int64{}, err
297+
return &gql_generated.ImageSummary{}, map[string]int64{}, err
298+
}
297299
}
298300

299301
var (
@@ -450,12 +452,14 @@ func ImageManifest2ManifestSummary(ctx context.Context, repo, tag string, descri
450452

451453
var configContent ispec.Image
452454

453-
err = json.Unmarshal(manifestMeta.ConfigBlob, &configContent)
454-
if err != nil {
455-
graphql.AddError(ctx, gqlerror.Errorf("can't unmarshal config blob for image: %s:%s, manifest digest: %s, error: %s",
456-
repo, tag, digest, err.Error()))
455+
if manifestContent.Config.MediaType == ispec.MediaTypeImageConfig {
456+
err = json.Unmarshal(manifestMeta.ConfigBlob, &configContent)
457+
if err != nil {
458+
graphql.AddError(ctx, gqlerror.Errorf("can't unmarshal config blob for image: %s:%s, manifest digest: %s, error: %s",
459+
repo, tag, digest, err.Error()))
457460

458-
return &gql_generated.ManifestSummary{}, map[string]int64{}, err
461+
return &gql_generated.ManifestSummary{}, map[string]int64{}, err
462+
}
459463
}
460464

461465
var (

pkg/extensions/search/resolver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ func TestGetReferrers(t *testing.T) {
13861386
Convey("GetReferrers return index of descriptors", func() {
13871387
testLogger := log.NewLogger("debug", "")
13881388
referrerDescriptor := ispec.Descriptor{
1389-
MediaType: ispec.MediaTypeArtifactManifest,
1389+
MediaType: ispec.MediaTypeImageManifest,
13901390
ArtifactType: "com.artifact.test",
13911391
Size: 403,
13921392
Digest: godigest.FromString("test"),

0 commit comments

Comments
 (0)