mirror of
https://github.com/distribution/distribution.git
synced 2025-06-27 15:59:04 +00:00
Merge pull request #4056 from thaJeztah/2.8_backport_update_golang_1.20.8
This commit is contained in:
commit
0fd0b73b61
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.19.9
|
go-version: 1.20.8
|
||||||
|
|
||||||
- name: Dependencies
|
- name: Dependencies
|
||||||
run: |
|
run: |
|
||||||
|
@ -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:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
ARG GO_VERSION=1.19.9
|
ARG GO_VERSION=1.20.8
|
||||||
ARG ALPINE_VERSION=3.16
|
ARG ALPINE_VERSION=3.18
|
||||||
ARG XX_VERSION=1.2.1
|
ARG XX_VERSION=1.2.1
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||||
|
@ -532,7 +532,7 @@ func TestNormalizedSplitHostname(t *testing.T) {
|
|||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
named, err := ParseNormalizedNamed(testcase.input)
|
named, err := ParseNormalizedNamed(testcase.input) //nolint:staticcheck // Ignore SA1019: SplitHostname is deprecated.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failf("error parsing name: %s", err)
|
failf("error parsing name: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
@ -218,7 +217,6 @@ func TestRouterWithBadCharacters(t *testing.T) {
|
|||||||
// with random UTF8 characters not in the 128 bit ASCII range.
|
// with random UTF8 characters not in the 128 bit ASCII range.
|
||||||
// These are not valid characters for the router and we expect
|
// These are not valid characters for the router and we expect
|
||||||
// 404s on every test.
|
// 404s on every test.
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
|
||||||
testCases := make([]routeTestCase, 1000)
|
testCases := make([]routeTestCase, 1000)
|
||||||
for idx := range testCases {
|
for idx := range testCases {
|
||||||
testCases[idx] = routeTestCase{
|
testCases[idx] = routeTestCase{
|
||||||
|
@ -527,7 +527,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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var sbsMu sync.Mutex
|
var sbsMu sync.Mutex
|
||||||
|
var randSource rand.Rand
|
||||||
|
|
||||||
type statsBlobStore struct {
|
type statsBlobStore struct {
|
||||||
stats map[string]int
|
stats map[string]int
|
||||||
@ -195,13 +196,13 @@ func makeTestEnv(t *testing.T, name string) *testEnv {
|
|||||||
func makeBlob(size int) []byte {
|
func makeBlob(size int) []byte {
|
||||||
blob := make([]byte, size)
|
blob := make([]byte, size)
|
||||||
for i := 0; i < size; i++ {
|
for i := 0; i < size; i++ {
|
||||||
blob[i] = byte('A' + rand.Int()%48)
|
blob[i] = byte('A' + randSource.Int()%48)
|
||||||
}
|
}
|
||||||
return blob
|
return blob
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rand.Seed(42)
|
randSource = *rand.New(rand.NewSource(42))
|
||||||
}
|
}
|
||||||
|
|
||||||
func populate(t *testing.T, te *testEnv, blobCount, size, numUnique int) {
|
func populate(t *testing.T, te *testEnv, blobCount, size, numUnique int) {
|
||||||
|
@ -236,11 +236,10 @@ func (registry *Registry) ListenAndServe() error {
|
|||||||
dcontext.GetLogger(registry.app).Infof("restricting TLS cipher suites to: %s", strings.Join(getCipherSuiteNames(tlsCipherSuites), ","))
|
dcontext.GetLogger(registry.app).Infof("restricting TLS cipher suites to: %s", strings.Join(getCipherSuiteNames(tlsCipherSuites), ","))
|
||||||
|
|
||||||
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 != "" {
|
||||||
@ -282,7 +281,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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ package s3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -3,6 +3,7 @@ package testsuites
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
crand "crypto/rand"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -1214,7 +1215,7 @@ func randomFilename(length int64) string {
|
|||||||
var randomBytes = make([]byte, 128<<20)
|
var randomBytes = make([]byte, 128<<20)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
_, _ = rand.Read(randomBytes) // always returns len(randomBytes) and nil error
|
_, _ = crand.Read(randomBytes) // always returns len(randomBytes) and nil error
|
||||||
}
|
}
|
||||||
|
|
||||||
func randomContents(length int64) []byte {
|
func randomContents(length int64) []byte {
|
||||||
|
@ -2,6 +2,7 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
crand "crypto/rand"
|
||||||
"io"
|
"io"
|
||||||
mrand "math/rand"
|
mrand "math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
@ -14,7 +15,7 @@ import (
|
|||||||
func TestSimpleRead(t *testing.T) {
|
func TestSimpleRead(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
content := make([]byte, 1<<20)
|
content := make([]byte, 1<<20)
|
||||||
n, err := mrand.Read(content)
|
n, err := crand.Read(content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error building random data: %v", err)
|
t.Fatalf("unexpected error building random data: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
GOLANGCI_LINT_VERSION="v1.50.1"
|
GOLANGCI_LINT_VERSION="v1.54.2"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Install developer tools to $GOBIN (or $GOPATH/bin if unset)
|
# Install developer tools to $GOBIN (or $GOPATH/bin if unset)
|
||||||
|
@ -3,6 +3,7 @@ package testutil
|
|||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
crand "crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
mrand "math/rand"
|
mrand "math/rand"
|
||||||
@ -45,7 +46,7 @@ func CreateRandomTarFile() (rs io.ReadSeeker, dgst digest.Digest, err error) {
|
|||||||
randomData := make([]byte, fileSize)
|
randomData := make([]byte, fileSize)
|
||||||
|
|
||||||
// Fill up the buffer with some random data.
|
// Fill up the buffer with some random data.
|
||||||
n, err := mrand.Read(randomData)
|
n, err := crand.Read(randomData)
|
||||||
|
|
||||||
if n != len(randomData) {
|
if n != len(randomData) {
|
||||||
return nil, "", fmt.Errorf("short read creating random reader: %v bytes != %v bytes", n, len(randomData))
|
return nil, "", fmt.Errorf("short read creating random reader: %v bytes != %v bytes", n, len(randomData))
|
||||||
|
Loading…
Reference in New Issue
Block a user