Merge pull request #3906 from thaJeztah/update_golangci_lint
update golangci-lint to v1.52, fix linting issues
This commit is contained in:
commit
681d7dcbb3
22 changed files with 127 additions and 121 deletions
|
@ -1,7 +1,5 @@
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- structcheck
|
|
||||||
- varcheck
|
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- gofmt
|
- gofmt
|
||||||
|
@ -14,6 +12,14 @@ linters:
|
||||||
disable:
|
disable:
|
||||||
- errcheck
|
- errcheck
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
revive:
|
||||||
|
rules:
|
||||||
|
# TODO(thaJeztah): temporarily disabled the "unused-parameter" check.
|
||||||
|
# It produces many warnings, and some of those may need to be looked at.
|
||||||
|
- name: unused-parameter
|
||||||
|
disabled: true
|
||||||
|
|
||||||
run:
|
run:
|
||||||
deadline: 2m
|
deadline: 2m
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
ARG GO_VERSION=1.18
|
ARG GO_VERSION=1.18
|
||||||
ARG ALPINE_VERSION=3.16
|
ARG ALPINE_VERSION=3.16
|
||||||
ARG GOLANGCI_LINT_VERSION=v1.45
|
ARG GOLANGCI_LINT_VERSION=v1.52
|
||||||
|
|
||||||
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
|
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/distribution/distribution/v3"
|
"github.com/distribution/distribution/v3"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/reference"
|
"github.com/distribution/distribution/v3/reference"
|
||||||
v2 "github.com/distribution/distribution/v3/registry/api/v2"
|
v2 "github.com/distribution/distribution/v3/registry/api/v2"
|
||||||
"github.com/distribution/distribution/v3/uuid"
|
"github.com/distribution/distribution/v3/uuid"
|
||||||
|
@ -27,7 +27,7 @@ var (
|
||||||
Name: "test",
|
Name: "test",
|
||||||
}
|
}
|
||||||
request = RequestRecord{}
|
request = RequestRecord{}
|
||||||
layers = []schema1.FSLayer{
|
layers = []schema1.FSLayer{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
{
|
{
|
||||||
BlobSum: "asdf",
|
BlobSum: "asdf",
|
||||||
},
|
},
|
||||||
|
@ -35,13 +35,13 @@ var (
|
||||||
BlobSum: "qwer",
|
BlobSum: "qwer",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
m = schema1.Manifest{
|
m = schema1.Manifest{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
Name: repo,
|
Name: repo,
|
||||||
Tag: "latest",
|
Tag: "latest",
|
||||||
FSLayers: layers,
|
FSLayers: layers,
|
||||||
}
|
}
|
||||||
|
|
||||||
sm *schema1.SignedManifest
|
sm *schema1.SignedManifest //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
payload []byte
|
payload []byte
|
||||||
dgst digest.Digest
|
dgst digest.Digest
|
||||||
)
|
)
|
||||||
|
@ -152,7 +152,7 @@ func createTestEnv(t *testing.T, fn testSinkFn) Listener {
|
||||||
t.Fatalf("error generating private key: %v", err)
|
t.Fatalf("error generating private key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sm, err = schema1.Sign(&m, pk)
|
sm, err = schema1.Sign(&m, pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error signing manifest: %v", err)
|
t.Fatalf("error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestEventJSONFormat provides silly test to detect if the event format or
|
// TestEventJSONFormat provides silly test to detect if the event format or
|
||||||
|
@ -116,7 +116,7 @@ func TestEventEnvelopeJSONFormat(t *testing.T) {
|
||||||
|
|
||||||
manifestPush := prototype
|
manifestPush := prototype
|
||||||
manifestPush.ID = "asdf-asdf-asdf-asdf-0"
|
manifestPush.ID = "asdf-asdf-asdf-asdf-0"
|
||||||
manifestPush.Target.MediaType = schema1.MediaTypeSignedManifest
|
manifestPush.Target.MediaType = schema1.MediaTypeSignedManifest //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
manifestPush.Target.Digest = "sha256:0123456789abcdef0"
|
manifestPush.Target.Digest = "sha256:0123456789abcdef0"
|
||||||
manifestPush.Target.Size = 1
|
manifestPush.Target.Size = 1
|
||||||
manifestPush.Target.Length = 1
|
manifestPush.Target.Length = 1
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
events "github.com/docker/go-events"
|
events "github.com/docker/go-events"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -121,11 +121,11 @@ func TestHTTPSink(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
statusCode: http.StatusOK,
|
statusCode: http.StatusOK,
|
||||||
event: createTestEvent("push", "library/test", schema1.MediaTypeSignedManifest),
|
event: createTestEvent("push", "library/test", schema1.MediaTypeSignedManifest), //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
statusCode: http.StatusOK,
|
statusCode: http.StatusOK,
|
||||||
event: createTestEvent("push", "library/test", schema1.MediaTypeSignedManifest),
|
event: createTestEvent("push", "library/test", schema1.MediaTypeSignedManifest), //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
statusCode: http.StatusOK,
|
statusCode: http.StatusOK,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/distribution/distribution/v3"
|
"github.com/distribution/distribution/v3"
|
||||||
"github.com/distribution/distribution/v3/context"
|
"github.com/distribution/distribution/v3/context"
|
||||||
"github.com/distribution/distribution/v3/manifest"
|
"github.com/distribution/distribution/v3/manifest"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/reference"
|
"github.com/distribution/distribution/v3/reference"
|
||||||
"github.com/distribution/distribution/v3/registry/storage"
|
"github.com/distribution/distribution/v3/registry/storage"
|
||||||
"github.com/distribution/distribution/v3/registry/storage/cache/memory"
|
"github.com/distribution/distribution/v3/registry/storage/cache/memory"
|
||||||
|
@ -125,7 +125,7 @@ func checkExerciseRepository(t *testing.T, repository distribution.Repository, r
|
||||||
tag := "thetag"
|
tag := "thetag"
|
||||||
// todo: change this to use Builder
|
// todo: change this to use Builder
|
||||||
|
|
||||||
m := schema1.Manifest{
|
m := schema1.Manifest{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
Versioned: manifest.Versioned{
|
Versioned: manifest.Versioned{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
},
|
},
|
||||||
|
@ -159,10 +159,10 @@ func checkExerciseRepository(t *testing.T, repository distribution.Repository, r
|
||||||
t.Fatalf("unexpected error finishing upload: %v", err)
|
t.Fatalf("unexpected error finishing upload: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.FSLayers = append(m.FSLayers, schema1.FSLayer{
|
m.FSLayers = append(m.FSLayers, schema1.FSLayer{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
BlobSum: dgst,
|
BlobSum: dgst,
|
||||||
})
|
})
|
||||||
m.History = append(m.History, schema1.History{
|
m.History = append(m.History, schema1.History{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
V1Compatibility: "",
|
V1Compatibility: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ func checkExerciseRepository(t *testing.T, repository distribution.Repository, r
|
||||||
t.Fatalf("unexpected error generating key: %v", err)
|
t.Fatalf("unexpected error generating key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sm, err := schema1.Sign(&m, pk)
|
sm, err := schema1.Sign(&m, pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error signing manifest: %v", err)
|
t.Fatalf("unexpected error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,6 +269,7 @@ func TestParseRepositoryInfo(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range refStrings {
|
for _, r := range refStrings {
|
||||||
|
r := r
|
||||||
t.Run(strconv.Itoa(i)+"/"+r, func(t *testing.T) {
|
t.Run(strconv.Itoa(i)+"/"+r, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
named, err := ParseNormalizedNamed(r)
|
named, err := ParseNormalizedNamed(r)
|
||||||
|
@ -531,7 +532,7 @@ func TestNormalizedSplitHostname(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error parsing name: %s", err)
|
t.Errorf("error parsing name: %s", err)
|
||||||
}
|
}
|
||||||
domain, name := SplitHostname(named)
|
domain, name := SplitHostname(named) //nolint:staticcheck // Ignore SA1019: SplitHostname is deprecated.
|
||||||
if domain != tc.domain {
|
if domain != tc.domain {
|
||||||
t.Errorf("unexpected domain: got %q, expected %q", domain, tc.domain)
|
t.Errorf("unexpected domain: got %q, expected %q", domain, tc.domain)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,11 @@ func TestErrorCodes(t *testing.T) {
|
||||||
t.Fatal("errors aren't loaded!")
|
t.Fatal("errors aren't loaded!")
|
||||||
}
|
}
|
||||||
|
|
||||||
for ec, desc := range errorCodeToDescriptors {
|
for ec := range errorCodeToDescriptors {
|
||||||
|
ec := ec
|
||||||
t.Run(ec.String(), func(t *testing.T) {
|
t.Run(ec.String(), func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
desc := errorCodeToDescriptors[ec]
|
||||||
if ec != desc.Code {
|
if ec != desc.Code {
|
||||||
t.Fatalf("error code in descriptor isn't correct, %q != %q", ec, desc.Code)
|
t.Fatalf("error code in descriptor isn't correct, %q != %q", ec, desc.Code)
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,7 +526,7 @@ func TestNewAccessControllerPemBlock(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ac.(*accessController).rootCerts.Subjects()) != 2 {
|
if len(ac.(*accessController).rootCerts.Subjects()) != 2 { //nolint:staticcheck // FIXME(thaJeztah): ignore SA1019: ac.(*accessController).rootCerts.Subjects has been deprecated since Go 1.18: if s was returned by SystemCertPool, Subjects will not include the system roots. (staticcheck)
|
||||||
t.Fatal("accessController has the wrong number of certificates")
|
t.Fatal("accessController has the wrong number of certificates")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,5 @@ func assertStringListEqual(t *testing.T, expected []string, actual []string) {
|
||||||
if v != actual[i] {
|
if v != actual[i] {
|
||||||
t.Errorf("expected %d. item to be %q, got %q", i, v, actual[i])
|
t.Errorf("expected %d. item to be %q, got %q", i, v, actual[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"github.com/distribution/distribution/v3"
|
"github.com/distribution/distribution/v3"
|
||||||
"github.com/distribution/distribution/v3/context"
|
"github.com/distribution/distribution/v3/context"
|
||||||
"github.com/distribution/distribution/v3/manifest"
|
"github.com/distribution/distribution/v3/manifest"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/reference"
|
"github.com/distribution/distribution/v3/reference"
|
||||||
"github.com/distribution/distribution/v3/registry/api/errcode"
|
"github.com/distribution/distribution/v3/registry/api/errcode"
|
||||||
v2 "github.com/distribution/distribution/v3/registry/api/v2"
|
v2 "github.com/distribution/distribution/v3/registry/api/v2"
|
||||||
|
@ -917,18 +917,18 @@ func TestBlobMount(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRandomSchemaV1Manifest(name reference.Named, tag string, blobCount int) (*schema1.SignedManifest, digest.Digest, []byte) {
|
func newRandomSchemaV1Manifest(name reference.Named, tag string, blobCount int) (*schema1.SignedManifest, digest.Digest, []byte) { //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
blobs := make([]schema1.FSLayer, blobCount)
|
blobs := make([]schema1.FSLayer, blobCount) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
history := make([]schema1.History, blobCount)
|
history := make([]schema1.History, blobCount) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
|
|
||||||
for i := 0; i < blobCount; i++ {
|
for i := 0; i < blobCount; i++ {
|
||||||
dgst, blob := newRandomBlob((i % 5) * 16)
|
dgst, blob := newRandomBlob((i % 5) * 16)
|
||||||
|
|
||||||
blobs[i] = schema1.FSLayer{BlobSum: dgst}
|
blobs[i] = schema1.FSLayer{BlobSum: dgst} //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
history[i] = schema1.History{V1Compatibility: fmt.Sprintf("{\"Hex\": \"%x\"}", blob)}
|
history[i] = schema1.History{V1Compatibility: fmt.Sprintf("{\"Hex\": \"%x\"}", blob)} //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
}
|
}
|
||||||
|
|
||||||
m := schema1.Manifest{
|
m := schema1.Manifest{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
Name: name.String(),
|
Name: name.String(),
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
Architecture: "x86",
|
Architecture: "x86",
|
||||||
|
@ -944,7 +944,7 @@ func newRandomSchemaV1Manifest(name reference.Named, tag string, blobCount int)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sm, err := schema1.Sign(&m, pk)
|
sm, err := schema1.Sign(&m, pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -970,7 +970,7 @@ func addTestManifestWithEtag(repo reference.Named, reference string, content []b
|
||||||
Headers: http.Header(map[string][]string{
|
Headers: http.Header(map[string][]string{
|
||||||
"Content-Length": {"0"},
|
"Content-Length": {"0"},
|
||||||
"Last-Modified": {time.Now().Add(-1 * time.Second).Format(time.ANSIC)},
|
"Last-Modified": {time.Now().Add(-1 * time.Second).Format(time.ANSIC)},
|
||||||
"Content-Type": {schema1.MediaTypeSignedManifest},
|
"Content-Type": {schema1.MediaTypeSignedManifest}, //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -980,7 +980,7 @@ func addTestManifestWithEtag(repo reference.Named, reference string, content []b
|
||||||
Headers: http.Header(map[string][]string{
|
Headers: http.Header(map[string][]string{
|
||||||
"Content-Length": {fmt.Sprint(len(content))},
|
"Content-Length": {fmt.Sprint(len(content))},
|
||||||
"Last-Modified": {time.Now().Add(-1 * time.Second).Format(time.ANSIC)},
|
"Last-Modified": {time.Now().Add(-1 * time.Second).Format(time.ANSIC)},
|
||||||
"Content-Type": {schema1.MediaTypeSignedManifest},
|
"Content-Type": {schema1.MediaTypeSignedManifest}, //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,9 +988,9 @@ func addTestManifestWithEtag(repo reference.Named, reference string, content []b
|
||||||
}
|
}
|
||||||
|
|
||||||
func contentDigestString(mediatype string, content []byte) string {
|
func contentDigestString(mediatype string, content []byte) string {
|
||||||
if mediatype == schema1.MediaTypeSignedManifest {
|
if mediatype == schema1.MediaTypeSignedManifest { //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
m, _, _ := distribution.UnmarshalManifest(mediatype, content)
|
m, _, _ := distribution.UnmarshalManifest(mediatype, content)
|
||||||
content = m.(*schema1.SignedManifest).Canonical
|
content = m.(*schema1.SignedManifest).Canonical //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
}
|
}
|
||||||
return digest.Canonical.FromBytes(content).String()
|
return digest.Canonical.FromBytes(content).String()
|
||||||
}
|
}
|
||||||
|
@ -1061,7 +1061,7 @@ func addTestManifestWithoutDigestHeader(repo reference.Named, reference string,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkEqualManifest(m1, m2 *schema1.SignedManifest) error {
|
func checkEqualManifest(m1, m2 *schema1.SignedManifest) error { //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if m1.Name != m2.Name {
|
if m1.Name != m2.Name {
|
||||||
return fmt.Errorf("name does not match %q != %q", m1.Name, m2.Name)
|
return fmt.Errorf("name does not match %q != %q", m1.Name, m2.Name)
|
||||||
}
|
}
|
||||||
|
@ -1092,12 +1092,12 @@ func TestV1ManifestFetch(t *testing.T) {
|
||||||
repo, _ := reference.WithName("test.example.com/repo")
|
repo, _ := reference.WithName("test.example.com/repo")
|
||||||
m1, dgst, _ := newRandomSchemaV1Manifest(repo, "latest", 6)
|
m1, dgst, _ := newRandomSchemaV1Manifest(repo, "latest", 6)
|
||||||
var m testutil.RequestResponseMap
|
var m testutil.RequestResponseMap
|
||||||
_, pl, err := m1.Payload()
|
_, pl, err := m1.Payload() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
addTestManifest(repo, dgst.String(), schema1.MediaTypeSignedManifest, pl, &m)
|
addTestManifest(repo, dgst.String(), schema1.MediaTypeSignedManifest, pl, &m) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
addTestManifest(repo, "latest", schema1.MediaTypeSignedManifest, pl, &m)
|
addTestManifest(repo, "latest", schema1.MediaTypeSignedManifest, pl, &m) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
addTestManifest(repo, "badcontenttype", "text/html", pl, &m)
|
addTestManifest(repo, "badcontenttype", "text/html", pl, &m)
|
||||||
|
|
||||||
e, c := testServer(m)
|
e, c := testServer(m)
|
||||||
|
@ -1124,7 +1124,7 @@ func TestV1ManifestFetch(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
v1manifest, ok := manifest.(*schema1.SignedManifest)
|
v1manifest, ok := manifest.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Unexpected manifest type from Get: %T", manifest)
|
t.Fatalf("Unexpected manifest type from Get: %T", manifest)
|
||||||
}
|
}
|
||||||
|
@ -1138,7 +1138,7 @@ func TestV1ManifestFetch(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
v1manifest, ok = manifest.(*schema1.SignedManifest)
|
v1manifest, ok = manifest.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Unexpected manifest type from Get: %T", manifest)
|
t.Fatalf("Unexpected manifest type from Get: %T", manifest)
|
||||||
}
|
}
|
||||||
|
@ -1155,7 +1155,7 @@ func TestV1ManifestFetch(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
v1manifest, ok = manifest.(*schema1.SignedManifest)
|
v1manifest, ok = manifest.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Unexpected manifest type from Get: %T", manifest)
|
t.Fatalf("Unexpected manifest type from Get: %T", manifest)
|
||||||
}
|
}
|
||||||
|
@ -1298,7 +1298,7 @@ func TestManifestPut(t *testing.T) {
|
||||||
repo, _ := reference.WithName("test.example.com/repo/delete")
|
repo, _ := reference.WithName("test.example.com/repo/delete")
|
||||||
m1, dgst, _ := newRandomSchemaV1Manifest(repo, "other", 6)
|
m1, dgst, _ := newRandomSchemaV1Manifest(repo, "other", 6)
|
||||||
|
|
||||||
_, payload, err := m1.Payload()
|
_, payload, err := m1.Payload() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1506,11 +1506,11 @@ func TestObtainsManifestForTagWithoutHeaders(t *testing.T) {
|
||||||
|
|
||||||
var m testutil.RequestResponseMap
|
var m testutil.RequestResponseMap
|
||||||
m1, dgst, _ := newRandomSchemaV1Manifest(repo, "latest", 6)
|
m1, dgst, _ := newRandomSchemaV1Manifest(repo, "latest", 6)
|
||||||
_, pl, err := m1.Payload()
|
_, pl, err := m1.Payload() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
addTestManifestWithoutDigestHeader(repo, "1.0.0", schema1.MediaTypeSignedManifest, pl, &m)
|
addTestManifestWithoutDigestHeader(repo, "1.0.0", schema1.MediaTypeSignedManifest, pl, &m) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
|
|
||||||
e, c := testServer(m)
|
e, c := testServer(m)
|
||||||
defer c()
|
defer c()
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"github.com/distribution/distribution/v3/configuration"
|
"github.com/distribution/distribution/v3/configuration"
|
||||||
"github.com/distribution/distribution/v3/manifest"
|
"github.com/distribution/distribution/v3/manifest"
|
||||||
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/manifest/schema2"
|
"github.com/distribution/distribution/v3/manifest/schema2"
|
||||||
"github.com/distribution/distribution/v3/reference"
|
"github.com/distribution/distribution/v3/reference"
|
||||||
"github.com/distribution/distribution/v3/registry/api/errcode"
|
"github.com/distribution/distribution/v3/registry/api/errcode"
|
||||||
|
@ -1278,13 +1278,13 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
// Attempt to push unsigned manifest with missing layers
|
// Attempt to push unsigned manifest with missing layers
|
||||||
unsignedManifest := &schema1.Manifest{
|
unsignedManifest := &schema1.Manifest{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
Versioned: manifest.Versioned{
|
Versioned: manifest.Versioned{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
},
|
},
|
||||||
Name: imageName.Name(),
|
Name: imageName.Name(),
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
FSLayers: []schema1.FSLayer{
|
FSLayers: []schema1.FSLayer{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
{
|
{
|
||||||
BlobSum: "asdf",
|
BlobSum: "asdf",
|
||||||
},
|
},
|
||||||
|
@ -1292,7 +1292,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
BlobSum: "qwer",
|
BlobSum: "qwer",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
History: []schema1.History{
|
History: []schema1.History{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
{
|
{
|
||||||
V1Compatibility: "",
|
V1Compatibility: "",
|
||||||
},
|
},
|
||||||
|
@ -1316,7 +1316,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
// sign the manifest and still get some interesting errors.
|
// sign the manifest and still get some interesting errors.
|
||||||
sm, err := schema1.Sign(unsignedManifest, env.pk)
|
sm, err := schema1.Sign(unsignedManifest, env.pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error signing manifest: %v", err)
|
t.Fatalf("error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1358,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
|
|
||||||
// -------------------
|
// -------------------
|
||||||
// Push the signed manifest with all layers pushed.
|
// Push the signed manifest with all layers pushed.
|
||||||
signedManifest, err := schema1.Sign(unsignedManifest, env.pk)
|
signedManifest, err := schema1.Sign(unsignedManifest, env.pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error signing manifest: %v", err)
|
t.Fatalf("unexpected error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -1401,7 +1401,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
"ETag": []string{fmt.Sprintf(`"%s"`, dgst)},
|
"ETag": []string{fmt.Sprintf(`"%s"`, dgst)},
|
||||||
})
|
})
|
||||||
|
|
||||||
var fetchedManifest schema1.SignedManifest
|
var fetchedManifest schema1.SignedManifest //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
dec := json.NewDecoder(resp.Body)
|
dec := json.NewDecoder(resp.Body)
|
||||||
|
|
||||||
if err := dec.Decode(&fetchedManifest); err != nil {
|
if err := dec.Decode(&fetchedManifest); err != nil {
|
||||||
|
@ -1424,7 +1424,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
"ETag": []string{fmt.Sprintf(`"%s"`, dgst)},
|
"ETag": []string{fmt.Sprintf(`"%s"`, dgst)},
|
||||||
})
|
})
|
||||||
|
|
||||||
var fetchedManifestByDigest schema1.SignedManifest
|
var fetchedManifestByDigest schema1.SignedManifest //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
dec = json.NewDecoder(resp.Body)
|
dec = json.NewDecoder(resp.Body)
|
||||||
if err := dec.Decode(&fetchedManifestByDigest); err != nil {
|
if err := dec.Decode(&fetchedManifestByDigest); err != nil {
|
||||||
t.Fatalf("error decoding fetched manifest: %v", err)
|
t.Fatalf("error decoding fetched manifest: %v", err)
|
||||||
|
@ -1435,7 +1435,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
// check signature was roundtripped
|
// check signature was roundtripped
|
||||||
signatures, err := fetchedManifestByDigest.Signatures()
|
signatures, err := fetchedManifestByDigest.Signatures() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1445,7 +1445,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-sign, push and pull the same digest
|
// Re-sign, push and pull the same digest
|
||||||
sm2, err := schema1.Sign(&fetchedManifestByDigest.Manifest, env.pk)
|
sm2, err := schema1.Sign(&fetchedManifestByDigest.Manifest, env.pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1453,7 +1453,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
// Re-push with a few different Content-Types. The official schema1
|
// Re-push with a few different Content-Types. The official schema1
|
||||||
// content type should work, as should application/json with/without a
|
// content type should work, as should application/json with/without a
|
||||||
// charset.
|
// charset.
|
||||||
resp = putManifest(t, "re-putting signed manifest", manifestDigestURL, schema1.MediaTypeSignedManifest, sm2)
|
resp = putManifest(t, "re-putting signed manifest", manifestDigestURL, schema1.MediaTypeSignedManifest, sm2) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
checkResponse(t, "re-putting signed manifest", resp, http.StatusCreated)
|
checkResponse(t, "re-putting signed manifest", resp, http.StatusCreated)
|
||||||
resp = putManifest(t, "re-putting signed manifest", manifestDigestURL, "application/json", sm2)
|
resp = putManifest(t, "re-putting signed manifest", manifestDigestURL, "application/json", sm2)
|
||||||
checkResponse(t, "re-putting signed manifest", resp, http.StatusCreated)
|
checkResponse(t, "re-putting signed manifest", resp, http.StatusCreated)
|
||||||
|
@ -1476,7 +1476,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
// check only 1 signature is returned
|
// check only 1 signature is returned
|
||||||
signatures, err = fetchedManifestByDigest.Signatures()
|
signatures, err = fetchedManifestByDigest.Signatures() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1542,10 +1542,10 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
|
|
||||||
// Attempt to put a manifest with mismatching FSLayer and History array cardinalities
|
// Attempt to put a manifest with mismatching FSLayer and History array cardinalities
|
||||||
|
|
||||||
unsignedManifest.History = append(unsignedManifest.History, schema1.History{
|
unsignedManifest.History = append(unsignedManifest.History, schema1.History{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
V1Compatibility: "",
|
V1Compatibility: "",
|
||||||
})
|
})
|
||||||
invalidSigned, err := schema1.Sign(unsignedManifest, env.pk)
|
invalidSigned, err := schema1.Sign(unsignedManifest, env.pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error signing manifest")
|
t.Fatalf("error signing manifest")
|
||||||
}
|
}
|
||||||
|
@ -1863,12 +1863,12 @@ func testManifestAPISchema2(t *testing.T, env *testEnv, imageName reference.Name
|
||||||
|
|
||||||
checkResponse(t, "fetching uploaded manifest as schema1", resp, http.StatusOK)
|
checkResponse(t, "fetching uploaded manifest as schema1", resp, http.StatusOK)
|
||||||
|
|
||||||
m, desc, err := distribution.UnmarshalManifest(schema1.MediaTypeManifest, manifestBytes)
|
m, desc, err := distribution.UnmarshalManifest(schema1.MediaTypeManifest, manifestBytes) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error unmarshalling manifest: %v", err)
|
t.Fatalf("unexpected error unmarshalling manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchedSchema1Manifest, ok := m.(*schema1.SignedManifest)
|
fetchedSchema1Manifest, ok := m.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("expecting schema1 manifest")
|
t.Fatalf("expecting schema1 manifest")
|
||||||
}
|
}
|
||||||
|
@ -1993,7 +1993,7 @@ func testManifestAPIManifestList(t *testing.T, env *testEnv, args manifestArgs)
|
||||||
t.Fatalf("Error constructing request: %s", err)
|
t.Fatalf("Error constructing request: %s", err)
|
||||||
}
|
}
|
||||||
// multiple headers in mixed list format to ensure we parse correctly server-side
|
// multiple headers in mixed list format to ensure we parse correctly server-side
|
||||||
req.Header.Set("Accept", fmt.Sprintf(` %s ; q=0.8 , %s ; q=0.5 `, manifestlist.MediaTypeManifestList, schema1.MediaTypeSignedManifest))
|
req.Header.Set("Accept", fmt.Sprintf(` %s ; q=0.8 , %s ; q=0.5 `, manifestlist.MediaTypeManifestList, schema1.MediaTypeSignedManifest)) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
req.Header.Add("Accept", schema2.MediaTypeManifest)
|
req.Header.Add("Accept", schema2.MediaTypeManifest)
|
||||||
resp, err = http.DefaultClient.Do(req)
|
resp, err = http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2097,12 +2097,12 @@ func testManifestAPIManifestList(t *testing.T, env *testEnv, args manifestArgs)
|
||||||
|
|
||||||
checkResponse(t, "fetching uploaded manifest list as schema1", resp, http.StatusOK)
|
checkResponse(t, "fetching uploaded manifest list as schema1", resp, http.StatusOK)
|
||||||
|
|
||||||
m, desc, err := distribution.UnmarshalManifest(schema1.MediaTypeManifest, manifestBytes)
|
m, desc, err := distribution.UnmarshalManifest(schema1.MediaTypeManifest, manifestBytes) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error unmarshalling manifest: %v", err)
|
t.Fatalf("unexpected error unmarshalling manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchedSchema1Manifest, ok := m.(*schema1.SignedManifest)
|
fetchedSchema1Manifest, ok := m.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("expecting schema1 manifest")
|
t.Fatalf("expecting schema1 manifest")
|
||||||
}
|
}
|
||||||
|
@ -2300,7 +2300,7 @@ func newTestEnvMirror(t *testing.T, deleteEnabled bool) *testEnv {
|
||||||
RemoteURL: upstreamEnv.server.URL,
|
RemoteURL: upstreamEnv.server.URL,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
config.Compatibility.Schema1.Enabled = true
|
config.Compatibility.Schema1.Enabled = true //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
|
|
||||||
return newTestEnvWithConfig(t, &config)
|
return newTestEnvWithConfig(t, &config)
|
||||||
}
|
}
|
||||||
|
@ -2316,7 +2316,7 @@ func newTestEnv(t *testing.T, deleteEnabled bool) *testEnv {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Compatibility.Schema1.Enabled = true
|
config.Compatibility.Schema1.Enabled = true //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
config.HTTP.Headers = headerConfig
|
config.HTTP.Headers = headerConfig
|
||||||
|
|
||||||
return newTestEnvWithConfig(t, &config)
|
return newTestEnvWithConfig(t, &config)
|
||||||
|
@ -2356,8 +2356,8 @@ func putManifest(t *testing.T, msg, url, contentType string, v interface{}) *htt
|
||||||
var body []byte
|
var body []byte
|
||||||
|
|
||||||
switch m := v.(type) {
|
switch m := v.(type) {
|
||||||
case *schema1.SignedManifest:
|
case *schema1.SignedManifest: //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
_, pl, err := m.Payload()
|
_, pl, err := m.Payload() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error getting payload: %v", err)
|
t.Fatalf("error getting payload: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -2710,18 +2710,18 @@ func createRepository(env *testEnv, t *testing.T, imageName string, tag string)
|
||||||
t.Fatalf("unable to parse reference: %v", err)
|
t.Fatalf("unable to parse reference: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsignedManifest := &schema1.Manifest{
|
unsignedManifest := &schema1.Manifest{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
Versioned: manifest.Versioned{
|
Versioned: manifest.Versioned{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
},
|
},
|
||||||
Name: imageName,
|
Name: imageName,
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
FSLayers: []schema1.FSLayer{
|
FSLayers: []schema1.FSLayer{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
{
|
{
|
||||||
BlobSum: "asdf",
|
BlobSum: "asdf",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
History: []schema1.History{
|
History: []schema1.History{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
{
|
{
|
||||||
V1Compatibility: "",
|
V1Compatibility: "",
|
||||||
},
|
},
|
||||||
|
@ -2743,7 +2743,7 @@ func createRepository(env *testEnv, t *testing.T, imageName string, tag string)
|
||||||
pushLayer(t, env.builder, imageNameRef, dgst, uploadURLBase, rs)
|
pushLayer(t, env.builder, imageNameRef, dgst, uploadURLBase, rs)
|
||||||
}
|
}
|
||||||
|
|
||||||
signedManifest, err := schema1.Sign(unsignedManifest, env.pk)
|
signedManifest, err := schema1.Sign(unsignedManifest, env.pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error signing manifest: %v", err)
|
t.Fatalf("unexpected error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -2784,17 +2784,17 @@ func TestRegistryAsCacheMutationAPIs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manifest upload
|
// Manifest upload
|
||||||
m := &schema1.Manifest{
|
m := &schema1.Manifest{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
Versioned: manifest.Versioned{
|
Versioned: manifest.Versioned{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
},
|
},
|
||||||
Name: imageName.Name(),
|
Name: imageName.Name(),
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
FSLayers: []schema1.FSLayer{},
|
FSLayers: []schema1.FSLayer{}, //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
History: []schema1.History{},
|
History: []schema1.History{}, //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
}
|
}
|
||||||
|
|
||||||
sm, err := schema1.Sign(m, env.pk)
|
sm, err := schema1.Sign(m, env.pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error signing manifest: %v", err)
|
t.Fatalf("error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -2836,7 +2836,7 @@ func TestProxyManifestGetByTag(t *testing.T) {
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
truthConfig.Compatibility.Schema1.Enabled = true
|
truthConfig.Compatibility.Schema1.Enabled = true //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
truthConfig.HTTP.Headers = headerConfig
|
truthConfig.HTTP.Headers = headerConfig
|
||||||
|
|
||||||
imageName, _ := reference.WithName("foo/bar")
|
imageName, _ := reference.WithName("foo/bar")
|
||||||
|
@ -2855,7 +2855,7 @@ func TestProxyManifestGetByTag(t *testing.T) {
|
||||||
RemoteURL: truthEnv.server.URL,
|
RemoteURL: truthEnv.server.URL,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
proxyConfig.Compatibility.Schema1.Enabled = true
|
proxyConfig.Compatibility.Schema1.Enabled = true //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
proxyConfig.HTTP.Headers = headerConfig
|
proxyConfig.HTTP.Headers = headerConfig
|
||||||
|
|
||||||
proxyEnv := newTestEnvWithConfig(t, &proxyConfig)
|
proxyEnv := newTestEnvWithConfig(t, &proxyConfig)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
dcontext "github.com/distribution/distribution/v3/context"
|
dcontext "github.com/distribution/distribution/v3/context"
|
||||||
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
||||||
"github.com/distribution/distribution/v3/manifest/ocischema"
|
"github.com/distribution/distribution/v3/manifest/ocischema"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/manifest/schema2"
|
"github.com/distribution/distribution/v3/manifest/schema2"
|
||||||
"github.com/distribution/distribution/v3/reference"
|
"github.com/distribution/distribution/v3/reference"
|
||||||
"github.com/distribution/distribution/v3/registry/api/errcode"
|
"github.com/distribution/distribution/v3/registry/api/errcode"
|
||||||
|
@ -260,7 +260,7 @@ func (imh *manifestHandler) convertSchema2Manifest(schema2Manifest *schema2.Dese
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder := schema1.NewConfigManifestBuilder(imh.Repository.Blobs(imh), imh.Context.App.trustKey, ref, configJSON)
|
builder := schema1.NewConfigManifestBuilder(imh.Repository.Blobs(imh), imh.Context.App.trustKey, ref, configJSON) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
for _, d := range schema2Manifest.Layers {
|
for _, d := range schema2Manifest.Layers {
|
||||||
if err := builder.AppendReference(d); err != nil {
|
if err := builder.AppendReference(d); err != nil {
|
||||||
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err))
|
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err))
|
||||||
|
@ -272,7 +272,7 @@ func (imh *manifestHandler) convertSchema2Manifest(schema2Manifest *schema2.Dese
|
||||||
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err))
|
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
imh.Digest = digest.FromBytes(manifest.(*schema1.SignedManifest).Canonical)
|
imh.Digest = digest.FromBytes(manifest.(*schema1.SignedManifest).Canonical) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
|
|
||||||
return manifest, nil
|
return manifest, nil
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ func (imh *manifestHandler) applyResourcePolicy(manifest distribution.Manifest)
|
||||||
|
|
||||||
var class string
|
var class string
|
||||||
switch m := manifest.(type) {
|
switch m := manifest.(type) {
|
||||||
case *schema1.SignedManifest:
|
case *schema1.SignedManifest: //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
class = imageClass
|
class = imageClass
|
||||||
case *schema2.DeserializedManifest:
|
case *schema2.DeserializedManifest:
|
||||||
switch m.Config.MediaType {
|
switch m.Config.MediaType {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/distribution/distribution/v3"
|
"github.com/distribution/distribution/v3"
|
||||||
"github.com/distribution/distribution/v3/manifest"
|
"github.com/distribution/distribution/v3/manifest"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/reference"
|
"github.com/distribution/distribution/v3/reference"
|
||||||
"github.com/distribution/distribution/v3/registry/client/auth"
|
"github.com/distribution/distribution/v3/registry/client/auth"
|
||||||
"github.com/distribution/distribution/v3/registry/client/auth/challenge"
|
"github.com/distribution/distribution/v3/registry/client/auth/challenge"
|
||||||
|
@ -151,7 +151,7 @@ func newManifestStoreTestEnv(t *testing.T, name, tag string) *manifestStoreTestE
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateRepo(ctx context.Context, t *testing.T, repository distribution.Repository, name, tag string) (digest.Digest, error) {
|
func populateRepo(ctx context.Context, t *testing.T, repository distribution.Repository, name, tag string) (digest.Digest, error) {
|
||||||
m := schema1.Manifest{
|
m := schema1.Manifest{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
Versioned: manifest.Versioned{
|
Versioned: manifest.Versioned{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
},
|
},
|
||||||
|
@ -183,7 +183,7 @@ func populateRepo(ctx context.Context, t *testing.T, repository distribution.Rep
|
||||||
t.Fatalf("unexpected error generating private key: %v", err)
|
t.Fatalf("unexpected error generating private key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sm, err := schema1.Sign(&m, pk)
|
sm, err := schema1.Sign(&m, pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error signing manifest: %v", err)
|
t.Fatalf("error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,11 +221,10 @@ func (registry *Registry) ListenAndServe() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsConf := &tls.Config{
|
tlsConf := &tls.Config{
|
||||||
ClientAuth: tls.NoClientCert,
|
ClientAuth: tls.NoClientCert,
|
||||||
NextProtos: nextProtos(config),
|
NextProtos: nextProtos(config),
|
||||||
MinVersion: tlsMinVersion,
|
MinVersion: tlsMinVersion,
|
||||||
PreferServerCipherSuites: true,
|
CipherSuites: tlsCipherSuites,
|
||||||
CipherSuites: tlsCipherSuites,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.HTTP.TLS.LetsEncrypt.CacheFile != "" {
|
if config.HTTP.TLS.LetsEncrypt.CacheFile != "" {
|
||||||
|
@ -262,7 +261,7 @@ func (registry *Registry) ListenAndServe() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, subj := range pool.Subjects() {
|
for _, subj := range pool.Subjects() { //nolint:staticcheck // FIXME(thaJeztah): ignore SA1019: ac.(*accessController).rootCerts.Subjects has been deprecated since Go 1.18: if s was returned by SystemCertPool, Subjects will not include the system roots. (staticcheck)
|
||||||
dcontext.GetLogger(registry.app).Debugf("CA Subject: %s", string(subj))
|
dcontext.GetLogger(registry.app).Debugf("CA Subject: %s", string(subj))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ func makeRepo(ctx context.Context, t *testing.T, name string, reg distribution.N
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest, err := testutil.MakeSchema1Manifest(getKeys(layers))
|
manifest, err := testutil.MakeSchema1Manifest(getKeys(layers)) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ func uploadRandomSchema1Image(t *testing.T, repository distribution.Repository)
|
||||||
digests = append(digests, digest)
|
digests = append(digests, digest)
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest, err := testutil.MakeSchema1Manifest(digests)
|
manifest, err := testutil.MakeSchema1Manifest(digests) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("%v", err)
|
t.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
|
@ -232,12 +232,12 @@ func TestDeleteManifestIfTagNotFound(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct manifests
|
// Construct manifests
|
||||||
manifest1, err := testutil.MakeSchema1Manifest(getKeys(randomLayers1))
|
manifest1, err := testutil.MakeSchema1Manifest(getKeys(randomLayers1)) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to make manifest: %v", err)
|
t.Fatalf("failed to make manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest2, err := testutil.MakeSchema1Manifest(getKeys(randomLayers2))
|
manifest2, err := testutil.MakeSchema1Manifest(getKeys(randomLayers2)) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to make manifest: %v", err)
|
t.Fatalf("failed to make manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ func TestDeletionWithSharedLayer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct manifests
|
// Construct manifests
|
||||||
manifest1, err := testutil.MakeSchema1Manifest(getKeys(randomLayers1))
|
manifest1, err := testutil.MakeSchema1Manifest(getKeys(randomLayers1)) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to make manifest: %v", err)
|
t.Fatalf("failed to make manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/distribution/distribution/v3/manifest"
|
"github.com/distribution/distribution/v3/manifest"
|
||||||
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
||||||
"github.com/distribution/distribution/v3/manifest/ocischema"
|
"github.com/distribution/distribution/v3/manifest/ocischema"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/manifest/schema2"
|
"github.com/distribution/distribution/v3/manifest/schema2"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
@ -130,7 +130,7 @@ func (ms *manifestStore) Put(ctx context.Context, manifest distribution.Manifest
|
||||||
dcontext.GetLogger(ms.ctx).Debug("(*manifestStore).Put")
|
dcontext.GetLogger(ms.ctx).Debug("(*manifestStore).Put")
|
||||||
|
|
||||||
switch manifest.(type) {
|
switch manifest.(type) {
|
||||||
case *schema1.SignedManifest:
|
case *schema1.SignedManifest: //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
return ms.schema1Handler.Put(ctx, manifest, ms.skipDependencyVerification)
|
return ms.schema1Handler.Put(ctx, manifest, ms.skipDependencyVerification)
|
||||||
case *schema2.DeserializedManifest:
|
case *schema2.DeserializedManifest:
|
||||||
return ms.schema2Handler.Put(ctx, manifest, ms.skipDependencyVerification)
|
return ms.schema2Handler.Put(ctx, manifest, ms.skipDependencyVerification)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/distribution/distribution/v3/manifest"
|
"github.com/distribution/distribution/v3/manifest"
|
||||||
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
||||||
"github.com/distribution/distribution/v3/manifest/ocischema"
|
"github.com/distribution/distribution/v3/manifest/ocischema"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/reference"
|
"github.com/distribution/distribution/v3/reference"
|
||||||
"github.com/distribution/distribution/v3/registry/storage/cache/memory"
|
"github.com/distribution/distribution/v3/registry/storage/cache/memory"
|
||||||
"github.com/distribution/distribution/v3/registry/storage/driver"
|
"github.com/distribution/distribution/v3/registry/storage/driver"
|
||||||
|
@ -79,7 +79,7 @@ func testManifestStorage(t *testing.T, schema1Enabled bool, options ...RegistryO
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m := schema1.Manifest{
|
m := schema1.Manifest{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
Versioned: manifest.Versioned{
|
Versioned: manifest.Versioned{
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
},
|
},
|
||||||
|
@ -97,10 +97,10 @@ func testManifestStorage(t *testing.T, schema1Enabled bool, options ...RegistryO
|
||||||
}
|
}
|
||||||
|
|
||||||
testLayers[dgst] = rs
|
testLayers[dgst] = rs
|
||||||
m.FSLayers = append(m.FSLayers, schema1.FSLayer{
|
m.FSLayers = append(m.FSLayers, schema1.FSLayer{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
BlobSum: dgst,
|
BlobSum: dgst,
|
||||||
})
|
})
|
||||||
m.History = append(m.History, schema1.History{
|
m.History = append(m.History, schema1.History{ //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
V1Compatibility: "",
|
V1Compatibility: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ func testManifestStorage(t *testing.T, schema1Enabled bool, options ...RegistryO
|
||||||
t.Fatalf("unexpected error generating private key: %v", err)
|
t.Fatalf("unexpected error generating private key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sm, merr := schema1.Sign(&m, pk)
|
sm, merr := schema1.Sign(&m, pk) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if merr != nil {
|
if merr != nil {
|
||||||
t.Fatalf("error signing manifest: %v", err)
|
t.Fatalf("error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ func testManifestStorage(t *testing.T, schema1Enabled bool, options ...RegistryO
|
||||||
t.Fatalf("unexpected error fetching manifest: %v", err)
|
t.Fatalf("unexpected error fetching manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchedManifest, ok := fromStore.(*schema1.SignedManifest)
|
fetchedManifest, ok := fromStore.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("unexpected manifest type from signedstore")
|
t.Fatalf("unexpected manifest type from signedstore")
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ func testManifestStorage(t *testing.T, schema1Enabled bool, options ...RegistryO
|
||||||
t.Fatalf("fetched payload does not match original payload: %q != %q", fetchedManifest.Canonical, sm.Canonical)
|
t.Fatalf("fetched payload does not match original payload: %q != %q", fetchedManifest.Canonical, sm.Canonical)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, pl, err := fetchedManifest.Payload()
|
_, pl, err := fetchedManifest.Payload() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error getting payload %#v", err)
|
t.Fatalf("error getting payload %#v", err)
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ func testManifestStorage(t *testing.T, schema1Enabled bool, options ...RegistryO
|
||||||
t.Fatalf("unexpected error fetching manifest by digest: %v", err)
|
t.Fatalf("unexpected error fetching manifest by digest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
byDigestManifest, ok := fetchedByDigest.(*schema1.SignedManifest)
|
byDigestManifest, ok := fetchedByDigest.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("unexpected manifest type from signedstore")
|
t.Fatalf("unexpected manifest type from signedstore")
|
||||||
}
|
}
|
||||||
|
@ -246,11 +246,11 @@ func testManifestStorage(t *testing.T, schema1Enabled bool, options ...RegistryO
|
||||||
t.Fatalf("unexpected error generating private key: %v", err)
|
t.Fatalf("unexpected error generating private key: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sm2, err := schema1.Sign(&m, pk2)
|
sm2, err := schema1.Sign(&m, pk2) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error signing manifest: %v", err)
|
t.Fatalf("unexpected error signing manifest: %v", err)
|
||||||
}
|
}
|
||||||
_, pl, err = sm2.Payload()
|
_, pl, err = sm2.Payload() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error getting payload %#v", err)
|
t.Fatalf("error getting payload %#v", err)
|
||||||
}
|
}
|
||||||
|
@ -278,16 +278,16 @@ func testManifestStorage(t *testing.T, schema1Enabled bool, options ...RegistryO
|
||||||
t.Fatalf("unexpected error fetching manifest: %v", err)
|
t.Fatalf("unexpected error fetching manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fetched, ok := fromStore.(*schema1.SignedManifest)
|
fetched, ok := fromStore.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("unexpected type from signed manifeststore : %T", fetched)
|
t.Fatalf("unexpected type from signed manifeststore : %T", fetched)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := schema1.Verify(fetched); err != nil {
|
if _, err := schema1.Verify(fetched); err != nil { //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
t.Fatalf("unexpected error verifying manifest: %v", err)
|
t.Fatalf("unexpected error verifying manifest: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, pl, err = fetched.Payload()
|
_, pl, err = fetched.Payload() //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error getting payload %#v", err)
|
t.Fatalf("error getting payload %#v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/distribution/distribution/v3"
|
"github.com/distribution/distribution/v3"
|
||||||
dcontext "github.com/distribution/distribution/v3/context"
|
dcontext "github.com/distribution/distribution/v3/context"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/manifest/schema2"
|
"github.com/distribution/distribution/v3/manifest/schema2"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
)
|
)
|
||||||
|
@ -110,7 +110,7 @@ func (ms *schema2ManifestHandler) verifyManifest(ctx context.Context, mnfst sche
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case schema2.MediaTypeManifest, schema1.MediaTypeManifest:
|
case schema2.MediaTypeManifest, schema1.MediaTypeManifest: //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
var exists bool
|
var exists bool
|
||||||
exists, err = manifestService.Exists(ctx, descriptor.Digest)
|
exists, err = manifestService.Exists(ctx, descriptor.Digest)
|
||||||
if err != nil || !exists {
|
if err != nil || !exists {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/distribution/distribution/v3"
|
"github.com/distribution/distribution/v3"
|
||||||
dcontext "github.com/distribution/distribution/v3/context"
|
dcontext "github.com/distribution/distribution/v3/context"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/reference"
|
"github.com/distribution/distribution/v3/reference"
|
||||||
"github.com/docker/libtrust"
|
"github.com/docker/libtrust"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
|
@ -49,7 +49,7 @@ func (ms *signedManifestHandler) Unmarshal(ctx context.Context, dgst digest.Dige
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var sm schema1.SignedManifest
|
var sm schema1.SignedManifest //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if err := json.Unmarshal(raw, &sm); err != nil {
|
if err := json.Unmarshal(raw, &sm); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func (ms *signedManifestHandler) Unmarshal(ctx context.Context, dgst digest.Dige
|
||||||
func (ms *signedManifestHandler) Put(ctx context.Context, manifest distribution.Manifest, skipDependencyVerification bool) (digest.Digest, error) {
|
func (ms *signedManifestHandler) Put(ctx context.Context, manifest distribution.Manifest, skipDependencyVerification bool) (digest.Digest, error) {
|
||||||
dcontext.GetLogger(ms.ctx).Debug("(*signedManifestHandler).Put")
|
dcontext.GetLogger(ms.ctx).Debug("(*signedManifestHandler).Put")
|
||||||
|
|
||||||
sm, ok := manifest.(*schema1.SignedManifest)
|
sm, ok := manifest.(*schema1.SignedManifest) //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("non-schema1 manifest put to signedManifestHandler: %T", manifest)
|
return "", fmt.Errorf("non-schema1 manifest put to signedManifestHandler: %T", manifest)
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func (ms *signedManifestHandler) Put(ctx context.Context, manifest distribution.
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
mt := schema1.MediaTypeManifest
|
mt := schema1.MediaTypeManifest //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
payload := sm.Canonical
|
payload := sm.Canonical
|
||||||
|
|
||||||
revision, err := ms.blobStore.Put(ctx, mt, payload)
|
revision, err := ms.blobStore.Put(ctx, mt, payload)
|
||||||
|
@ -84,7 +84,7 @@ func (ms *signedManifestHandler) Put(ctx context.Context, manifest distribution.
|
||||||
// perspective of the registry. It ensures that the signature is valid for the
|
// perspective of the registry. It ensures that the signature is valid for the
|
||||||
// enclosed payload. As a policy, the registry only tries to store valid
|
// enclosed payload. As a policy, the registry only tries to store valid
|
||||||
// content, leaving trust policies of that content up to consumers.
|
// content, leaving trust policies of that content up to consumers.
|
||||||
func (ms *signedManifestHandler) verifyManifest(ctx context.Context, mnfst schema1.SignedManifest, skipDependencyVerification bool) error {
|
func (ms *signedManifestHandler) verifyManifest(ctx context.Context, mnfst schema1.SignedManifest, skipDependencyVerification bool) error { //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
var errs distribution.ErrManifestVerification
|
var errs distribution.ErrManifestVerification
|
||||||
|
|
||||||
if len(mnfst.Name) > reference.NameTotalLengthMax {
|
if len(mnfst.Name) > reference.NameTotalLengthMax {
|
||||||
|
@ -108,7 +108,7 @@ func (ms *signedManifestHandler) verifyManifest(ctx context.Context, mnfst schem
|
||||||
len(mnfst.History), len(mnfst.FSLayers)))
|
len(mnfst.History), len(mnfst.FSLayers)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := schema1.Verify(&mnfst); err != nil {
|
if _, err := schema1.Verify(&mnfst); err != nil { //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
switch err {
|
switch err {
|
||||||
case libtrust.ErrMissingSignatureKey, libtrust.ErrInvalidJSONContent, libtrust.ErrMissingSignatureKey:
|
case libtrust.ErrMissingSignatureKey, libtrust.ErrInvalidJSONContent, libtrust.ErrMissingSignatureKey:
|
||||||
errs = append(errs, distribution.ErrManifestUnverified{})
|
errs = append(errs, distribution.ErrManifestUnverified{})
|
||||||
|
@ -122,7 +122,7 @@ func (ms *signedManifestHandler) verifyManifest(ctx context.Context, mnfst schem
|
||||||
}
|
}
|
||||||
|
|
||||||
if !skipDependencyVerification {
|
if !skipDependencyVerification {
|
||||||
for _, fsLayer := range mnfst.References() {
|
for _, fsLayer := range mnfst.References() { //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
_, err := ms.repository.Blobs(ctx).Stat(ctx, fsLayer.Digest)
|
_, err := ms.repository.Blobs(ctx).Stat(ctx, fsLayer.Digest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != distribution.ErrBlobUnknown {
|
if err != distribution.ErrBlobUnknown {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/distribution/distribution/v3/context"
|
"github.com/distribution/distribution/v3/context"
|
||||||
"github.com/distribution/distribution/v3/manifest"
|
"github.com/distribution/distribution/v3/manifest"
|
||||||
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
"github.com/distribution/distribution/v3/manifest/manifestlist"
|
||||||
"github.com/distribution/distribution/v3/manifest/schema1"
|
"github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck // Ignore SA1019: "github.com/distribution/distribution/v3/manifest/schema1" is deprecated, as it's used for backward compatibility.
|
||||||
"github.com/distribution/distribution/v3/manifest/schema2"
|
"github.com/distribution/distribution/v3/manifest/schema2"
|
||||||
"github.com/docker/libtrust"
|
"github.com/docker/libtrust"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
|
|
Loading…
Reference in a new issue