chore: update golang (to 1.20.x) and golangci-linter (#1388)

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
Ramkumar Chinchani 2023-04-27 00:09:46 -07:00 committed by GitHub
parent 9cc990d7ca
commit 635d07ae04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 41 additions and 42 deletions

View File

@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
# Run benchmark with `go test -bench` and stores the output to a file
- name: Run benchmark
run: make BENCH_OUTPUT=ci-cd run-bench

View File

@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE

View File

@ -39,7 +39,7 @@ jobs:
uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Check out source code
uses: actions/checkout@v3

View File

@ -21,7 +21,7 @@ jobs:
uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Check out source code
uses: actions/checkout@v3
- name: Install dependencies

View File

@ -31,7 +31,7 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE
@ -105,8 +105,8 @@ jobs:
./bin/zot-linux-amd64 serve test/cluster/config-minio3.json &
sleep 10
# run tests
skopeo --debug copy --format=oci --dest-tls-verify=false docker://ghcr.io/project-zot/golang:1.19 docker://localhost:8080/golang:1.19
skopeo --debug copy --src-tls-verify=false docker://localhost:8080/golang:1.19 oci:golang:1.19
skopeo --debug copy --format=oci --dest-tls-verify=false docker://ghcr.io/project-zot/golang:1.20 docker://localhost:8080/golang:1.20
skopeo --debug copy --src-tls-verify=false docker://localhost:8080/golang:1.20 oci:golang:1.20
echo "{\"name\":\"foo\",\"value\":\"bar\"}" > config.json
echo "hello world" > artifact.txt
oras push --plain-http localhost:8080/hello-artifact:v2 \

View File

@ -49,7 +49,7 @@ jobs:
uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Install dependencies
run: |

View File

@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE

View File

@ -19,13 +19,13 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: '1.19'
go-version: '1.20'
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.49.0
version: v1.52.2
# Optional: working directory, useful for monorepos
# working-directory: somedir

View File

@ -25,7 +25,7 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE

View File

@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Install go-licenses
run: go install github.com/google/go-licenses@latest
- name: Check for forbidden licenses

View File

@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE

View File

@ -20,11 +20,11 @@ jobs:
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Install go 1.19
- name: Install go 1.20
uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Checkout this PR
uses: actions/checkout@v3
- name: Start zot server

View File

@ -17,8 +17,6 @@ jobs:
strategy:
matrix:
golang_version:
- "1.18"
- "1.19"
- "1.20"
runs-on: ubuntu-latest
steps:

View File

@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE

View File

@ -25,7 +25,7 @@ jobs:
uses: actions/setup-go@v4
with:
cache: false
go-version: 1.19.x
go-version: 1.20.x
- name: Checkout
uses: actions/checkout@v3
- name: Build zot

View File

@ -10,7 +10,7 @@ TOOLSDIR := $(shell pwd)/hack/tools
PATH := bin:$(TOOLSDIR)/bin:$(PATH)
STACKER := $(shell which stacker)
GOLINTER := $(TOOLSDIR)/bin/golangci-lint
GOLINTER_VERSION := v1.49.0
GOLINTER_VERSION := v1.52.2
NOTATION := $(TOOLSDIR)/bin/notation
NOTATION_VERSION := 1.0.0-rc.2
COSIGN := $(TOOLSDIR)/bin/cosign

View File

@ -6,7 +6,7 @@ import (
"fmt"
"io"
"log"
mrand "math/rand"
"math/rand"
"net/http"
"os"
"path"
@ -904,7 +904,8 @@ func getRandomSize(probabilityRange []float64) (int, int) {
//nolint:gosec
func flipFunc(probabilityRange []float64) int {
mrand.Seed(time.Now().UTC().UnixNano())
seed := time.Now().UTC().UnixNano()
mrand := rand.New(rand.NewSource(seed))
toss := mrand.Float64()
for idx, r := range probabilityRange {

2
go.mod
View File

@ -1,6 +1,6 @@
module zotregistry.io/zot
go 1.19
go 1.20
require (
github.com/99designs/gqlgen v0.17.29

View File

@ -5,7 +5,7 @@ run:
linters:
enable-all: true
disable: funlen,gocognit,exhaustivestruct,paralleltest,forbidigo,ireturn,wrapcheck,exhaustive,maintidx,exhaustruct,nosnakecase,interfacer,structcheck,varcheck,deadcode,ifshort,golint,scopelint,maligned,rowserrcheck,sqlclosecheck
disable: funlen,gocognit,exhaustivestruct,paralleltest,forbidigo,ireturn,wrapcheck,exhaustive,maintidx,exhaustruct,nosnakecase,interfacer,structcheck,varcheck,deadcode,ifshort,golint,scopelint,maligned,rowserrcheck,sqlclosecheck,revive,musttag
linters-settings:
dupl:

View File

@ -21,7 +21,7 @@ func SetupSwaggerRoutes(conf *config.Config, router *mux.Router, authFunc mux.Mi
log log.Logger,
) {
log.Info().Msg("setting up swagger route")
// swagger swagger "/swagger/v2/index.html"
// swagger "/swagger/v2/index.html"
swgRouter := router.PathPrefix("/swagger/v2/").Subrouter()
swgRouter.Use(authFunc)
swgRouter.Methods("GET").Handler(httpSwagger.WrapHandler)

View File

@ -11,15 +11,14 @@ import (
"github.com/gorilla/mux"
"zotregistry.io/zot/pkg/api/config"
"zotregistry.io/zot/pkg/log" //nolint:goimports
// as required by swaggo.
"zotregistry.io/zot/pkg/log"
_ "zotregistry.io/zot/swagger"
)
func SetupSwaggerRoutes(conf *config.Config, router *mux.Router, authFunc mux.MiddlewareFunc,
log log.Logger,
) {
// swagger swagger "/swagger/v2/index.html"
// swagger "/swagger/v2/index.html"
log.Warn().Msg("skipping enabling swagger because given zot binary " +
"doesn't include this feature, please build a binary that does so")
}

View File

@ -30,7 +30,7 @@ func TestHandlers(t *testing.T) {
mockrepoDB := mocks.RepoDBMock{}
Convey("No repo in request", t, func() {
request := httptest.NewRequest("GET", UserprefsBaseURL+"", strings.NewReader("My string"))
request := httptest.NewRequest(http.MethodGet, UserprefsBaseURL+"", strings.NewReader("My string"))
response := httptest.NewRecorder()
extensions.PutStar(response, request, mockrepoDB, log)
@ -45,7 +45,7 @@ func TestHandlers(t *testing.T) {
})
Convey("Empty repo in request", t, func() {
request := httptest.NewRequest("GET", UserprefsBaseURL+"?repo=", strings.NewReader("My string"))
request := httptest.NewRequest(http.MethodGet, UserprefsBaseURL+"?repo=", strings.NewReader("My string"))
response := httptest.NewRecorder()
extensions.PutStar(response, request, mockrepoDB, log)
@ -60,7 +60,7 @@ func TestHandlers(t *testing.T) {
})
Convey("ToggleStarRepo different errors", t, func() {
request := httptest.NewRequest("GET", UserprefsBaseURL+"?repo=test",
request := httptest.NewRequest(http.MethodGet, UserprefsBaseURL+"?repo=test",
strings.NewReader("My string"))
Convey("ErrRepoMetaNotFound", func() {

View File

@ -111,7 +111,8 @@ func generateTestData(dbDir string) error { //nolint: gocyclo
return err
}
if err = os.WriteFile(path.Join(dbDir, "zot-nonreadable-test", "index.json"), buf, 0o111); err != nil {
if err = os.WriteFile(path.Join(dbDir, "zot-nonreadable-test", "index.json"), //nolint:gosec // test code
buf, 0o111); err != nil {
return err
}

View File

@ -27,7 +27,9 @@ import (
"zotregistry.io/zot/pkg/meta/repodb"
localCtx "zotregistry.io/zot/pkg/requestcontext"
"zotregistry.io/zot/pkg/storage"
) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.
)
// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.
const (
querySizeLimit = 256

View File

@ -14,7 +14,7 @@ const (
CosignType = "cosign"
)
// Used to model changes to an object after a call to the the DB.
// Used to model changes to an object after a call to the DB.
type ToggleState int
const (

View File

@ -501,7 +501,7 @@ func RunRepoDBTests(repoDB repodb.RepoDB, preparationFuncs ...func() error) {
So(err, ShouldBeNil)
So(repoMeta.Stars, ShouldEqual, 0)
repoMeta, err = repoDB.GetRepoMeta("badRepo")
_, err = repoDB.GetRepoMeta("badRepo")
So(err, ShouldNotBeNil)
})
@ -2663,7 +2663,7 @@ func generateTestImage() ([]byte, []byte, error) {
// init layers with random values
for i := range layers {
//nolint:gosec
_, err := rand.Read(layers[i])
_, err := rand.Read(layers[i]) //nolint:staticcheck
if err != nil {
return []byte{}, []byte{}, err
}

View File

@ -132,7 +132,7 @@ func toStringIfOk(cacheDriverConfig map[string]interface{}, param string, log lo
}
if str == "" {
log.Error().Msgf("parsing CacheDriver config failed, field '%s' is is empty", param)
log.Error().Msgf("parsing CacheDriver config failed, field '%s' is empty", param)
return "", false
}

View File

@ -203,7 +203,6 @@ func CheckIfIndexNeedsUpdate(index *ispec.Index, desc *ispec.Descriptor,
manifest := manifest
if reference == manifest.Digest.String() {
// nothing changed, so don't update
desc = &manifest
updateIndex = false
break
@ -213,7 +212,6 @@ func CheckIfIndexNeedsUpdate(index *ispec.Index, desc *ispec.Descriptor,
if ok && v == reference {
if manifest.Digest.String() == desc.Digest.String() {
// nothing changed, so don't update
desc = &manifest
updateIndex = false
break

View File

@ -1458,7 +1458,7 @@ func (is *ObjectStorage) getOriginalBlobFromDisk(duplicateBlobs []string) (strin
}
func (is *ObjectStorage) getOriginalBlob(digest godigest.Digest, duplicateBlobs []string) (string, error) {
originalBlob := ""
var originalBlob string
var err error

View File

@ -1229,7 +1229,7 @@ func TestGenerateNotationCerts(t *testing.T) {
So(err, ShouldBeNil)
signingKeysBuf, err := json.Marshal(notconfig.SigningKeys{})
So(err, ShouldBeNil)
err = os.WriteFile(filePath, signingKeysBuf, 0o555)
err = os.WriteFile(filePath, signingKeysBuf, 0o555) //nolint:gosec // test code
So(err, ShouldBeNil)
err = test.GenerateNotationCerts(t.TempDir(), "cert")
So(err, ShouldNotBeNil)