Skip to content

Commit a239d6c

Browse files
Use import of OCI structs (#22765) (#22805)
Backport of #22765 Co-authored-by: techknowlogick <techknowlogick@gitea.io>
1 parent ff20146 commit a239d6c

File tree

12 files changed

+90
-326
lines changed

12 files changed

+90
-326
lines changed

assets/go-licenses.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ require (
7575
github.com/niklasfasching/go-org v1.6.5
7676
github.com/oliamb/cutter v0.2.2
7777
github.com/olivere/elastic/v7 v7.0.32
78+
github.com/opencontainers/go-digest v1.0.0
79+
github.com/opencontainers/image-spec v1.1.0-rc2
7880
github.com/pkg/errors v0.9.1
7981
github.com/pquerna/otp v1.3.0
8082
github.com/prometheus/client_golang v1.13.0

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,10 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
11741174
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
11751175
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
11761176
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
1177+
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
1178+
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
1179+
github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034=
1180+
github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ=
11771181
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
11781182
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
11791183
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=

modules/packages/container/metadata.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import (
1111

1212
"code.gitea.io/gitea/modules/json"
1313
"code.gitea.io/gitea/modules/packages/container/helm"
14-
"code.gitea.io/gitea/modules/packages/container/oci"
1514
"code.gitea.io/gitea/modules/validation"
15+
16+
oci "github.com/opencontainers/image-spec/specs-go/v1"
1617
)
1718

1819
const (
@@ -66,8 +67,8 @@ type Metadata struct {
6667
}
6768

6869
// ParseImageConfig parses the metadata of an image config
69-
func ParseImageConfig(mediaType oci.MediaType, r io.Reader) (*Metadata, error) {
70-
if strings.EqualFold(string(mediaType), helm.ConfigMediaType) {
70+
func ParseImageConfig(mt string, r io.Reader) (*Metadata, error) {
71+
if strings.EqualFold(mt, helm.ConfigMediaType) {
7172
return parseHelmConfig(r)
7273
}
7374

modules/packages/container/metadata_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"testing"
1010

1111
"code.gitea.io/gitea/modules/packages/container/helm"
12-
"code.gitea.io/gitea/modules/packages/container/oci"
1312

13+
oci "github.com/opencontainers/image-spec/specs-go/v1"
1414
"github.com/stretchr/testify/assert"
1515
)
1616

@@ -24,7 +24,7 @@ func TestParseImageConfig(t *testing.T) {
2424

2525
configOCI := `{"config": {"labels": {"` + labelAuthors + `": "` + author + `", "` + labelLicenses + `": "` + license + `", "` + labelURL + `": "` + projectURL + `", "` + labelSource + `": "` + repositoryURL + `", "` + labelDocumentation + `": "` + documentationURL + `", "` + labelDescription + `": "` + description + `"}}, "history": [{"created_by": "do it 1"}, {"created_by": "dummy #(nop) do it 2"}]}`
2626

27-
metadata, err := ParseImageConfig(oci.MediaType(oci.MediaTypeImageManifest), strings.NewReader(configOCI))
27+
metadata, err := ParseImageConfig(oci.MediaTypeImageManifest, strings.NewReader(configOCI))
2828
assert.NoError(t, err)
2929

3030
assert.Equal(t, TypeOCI, metadata.Type)
@@ -51,7 +51,7 @@ func TestParseImageConfig(t *testing.T) {
5151

5252
configHelm := `{"description":"` + description + `", "home": "` + projectURL + `", "sources": ["` + repositoryURL + `"], "maintainers":[{"name":"` + author + `"}]}`
5353

54-
metadata, err = ParseImageConfig(oci.MediaType(helm.ConfigMediaType), strings.NewReader(configHelm))
54+
metadata, err = ParseImageConfig(helm.ConfigMediaType, strings.NewReader(configHelm))
5555
assert.NoError(t, err)
5656

5757
assert.Equal(t, TypeHelm, metadata.Type)

modules/packages/container/oci/digest.go

-27
This file was deleted.

modules/packages/container/oci/mediatype.go

-36
This file was deleted.

modules/packages/container/oci/oci.go

-191
This file was deleted.

modules/packages/container/oci/reference.go

-17
This file was deleted.

0 commit comments

Comments
 (0)