From 7103af026470e757d5a7aac45eabb5d56fb5cbb9 Mon Sep 17 00:00:00 2001 From: Shengwen YU Date: Thu, 29 Feb 2024 19:33:29 +0800 Subject: [PATCH] feat: bump up golang-runtime from 1.20.7 to 1.21.7 (#20046) * feat: bump up golang-runtime from 1.20.7 to 1.21.7 Signed-off-by: Shengwen Yu * fix: update code to comply golangci-lint Signed-off-by: Shengwen Yu * fix: update the mocks per the change of source code Signed-off-by: Shengwen Yu --------- Signed-off-by: Shengwen Yu --- .github/workflows/CI.yml | 20 ++++----- .github/workflows/build-package.yml | 4 +- .github/workflows/conformance_test.yml | 4 +- CONTRIBUTING.md | 42 +++++++++---------- Makefile | 4 +- make/photon/golang/Dockerfile | 2 +- make/photon/registry/Dockerfile.binary | 2 +- make/photon/trivy-adapter/Dockerfile.binary | 2 +- make/photon/trivy-adapter/builder.sh | 2 +- src/common/rbac/project/evaluator.go | 2 +- src/common/rbac/system/evaluator.go | 2 +- src/common/security/secret/context.go | 2 +- src/common/security/v2token/context.go | 2 +- src/common/utils/test/registryctl.go | 2 +- src/common/utils/uaa/fake_client.go | 2 +- .../artifact/annotation/v1alpha1.go | 2 +- .../artifact/processor/base/index.go | 8 ++-- .../artifact/processor/base/manifest.go | 8 ++-- .../artifact/processor/chart/chart.go | 6 +-- .../artifact/processor/cnab/cnab.go | 4 +- src/controller/artifact/processor/default.go | 6 +-- .../artifact/processor/image/index.go | 2 +- .../artifact/processor/image/manifest_v1.go | 8 ++-- .../artifact/processor/image/manifest_v2.go | 4 +- .../artifact/processor/wasm/wasm.go | 4 +- src/controller/config/controller.go | 2 +- .../event/handler/internal/artifact.go | 4 +- src/controller/gc/callback.go | 2 +- src/controller/health/controller.go | 2 +- src/controller/p2p/preheat/controller.go | 2 +- src/controller/project/controller.go | 3 +- src/controller/proxy/controller.go | 19 +++++---- src/controller/proxy/local.go | 2 +- src/controller/proxy/manifestcache.go | 4 +- src/controller/quota/controller.go | 6 +-- .../quota/driver/project/project.go | 2 +- .../replication/transfer/image/transfer.go | 2 +- src/controller/scan/callback.go | 2 +- src/controller/systemartifact/callback.go | 2 +- src/controller/systeminfo/controller.go | 10 ++--- src/controller/task/sweep.go | 2 +- src/core/auth/authenticator.go | 12 +++--- src/core/auth/authproxy/auth.go | 13 +++--- src/core/auth/authproxy/test/server.go | 6 +-- src/core/auth/db/db.go | 2 +- src/core/auth/oidc/oidc.go | 4 +- src/core/service/token/creator.go | 2 +- src/core/session/session.go | 16 +++---- src/go.mod | 2 +- src/go.sum | 19 +++++++++ .../job/impl/gc/garbage_collection.go | 2 +- .../job/impl/notification/webhook_job.go | 4 +- src/jobservice/job/impl/purge/purge.go | 2 +- .../job/impl/replication/replication.go | 2 +- .../impl/scandataexport/scan_data_export.go | 12 +++--- .../job/impl/systemartifact/cleanup.go | 4 +- src/jobservice/logger/getter_factory.go | 2 +- src/jobservice/runner/redis.go | 7 ++-- src/jobservice/runtime/bootstrap.go | 8 ++-- src/jobservice/worker/cworker/c_worker.go | 6 +-- src/jobservice/worker/cworker/reaper.go | 2 +- src/lib/cache/memory/memory.go | 10 ++--- src/lib/config/config.go | 2 +- src/lib/config/metadata/type.go | 4 +- src/lib/encrypt/keyprovider.go | 4 +- src/lib/orm/query.go | 2 +- src/lib/redis/redisclient.go | 7 ++-- src/lib/selector/selectors/index/index.go | 2 +- src/lib/selector/selectors/label/selector.go | 2 +- .../selector/selectors/severity/selector.go | 2 +- .../selector/selectors/signature/selector.go | 2 +- src/pkg/audit/forward.go | 2 +- src/pkg/blob/models/blob.go | 6 +-- src/pkg/cached/base_manager.go | 4 +- src/pkg/config/inmemory/manager.go | 2 +- src/pkg/config/manager.go | 4 +- src/pkg/config/rest/rest.go | 4 +- src/pkg/exporter/exporter.go | 4 +- src/pkg/factory.go | 2 +- src/pkg/jobmonitor/pool.go | 2 +- src/pkg/jobmonitor/queue.go | 2 +- src/pkg/jobmonitor/redis.go | 8 ++-- src/pkg/jobmonitor/worker.go | 2 +- src/pkg/ldap/manager.go | 6 +-- src/pkg/member/dao/dao.go | 2 +- src/pkg/notifier/event/event.go | 2 +- src/pkg/notifier/formats/default.go | 2 +- src/pkg/oidc/testutils.go | 2 +- .../p2p/preheat/provider/auth/none_handler.go | 2 +- src/pkg/permission/evaluator/admin/admin.go | 2 +- .../evaluator/rbac/casbin_adapter.go | 8 ++-- .../permission/evaluator/rbac/casbin_match.go | 2 +- src/pkg/permission/evaluator/rbac/rbac.go | 2 +- src/pkg/project/models/project.go | 8 ++-- src/pkg/quota/types/resources.go | 2 +- src/pkg/reg/adapter/aliacr/adapter.go | 2 +- src/pkg/reg/adapter/githubcr/adapter.go | 2 +- src/pkg/reg/adapter/huawei/huawei_adapter.go | 2 +- src/pkg/reg/adapter/huawei/image_registry.go | 6 +-- src/pkg/reg/adapter/jfrog/adapter.go | 2 +- src/pkg/reg/adapter/native/adapter.go | 4 +- src/pkg/reg/manager.go | 6 +-- src/pkg/registry/auth/null/authorizer.go | 2 +- src/pkg/registry/client.go | 6 +-- src/pkg/repository/model/model.go | 2 +- src/pkg/retention/launcher.go | 2 +- src/pkg/retention/policy/rule/index/index.go | 2 +- .../policy/rule/nothing/evaluator.go | 2 +- src/pkg/scan/dao/scan/vulnerability.go | 16 +++---- src/pkg/scan/dao/scan/vulnerability_test.go | 2 +- src/pkg/scan/export/filter_processor.go | 14 +++---- .../scan/postprocessors/report_converters.go | 4 +- src/pkg/scan/report/summary.go | 2 +- src/pkg/scan/rest/auth/no_auth.go | 2 +- src/pkg/scan/rest/v1/client.go | 2 +- src/pkg/scheduler/periodic_job.go | 4 +- src/pkg/signature/notary/helper.go | 2 +- src/pkg/task/sweep_job.go | 2 +- src/pkg/task/task.go | 4 +- src/pkg/user/dao/user.go | 2 +- src/registryctl/api/health.go | 2 +- src/server/middleware/blob/copy_artifact.go | 2 +- .../blob/post_initiate_blob_upload.go | 2 +- src/server/middleware/blob/put_manifest.go | 2 +- src/server/middleware/cosign/cosign.go | 2 +- src/server/middleware/nydus/nydus.go | 2 +- .../quota/post_initiate_blob_upload.go | 2 +- .../middleware/quota/put_blob_upload.go | 2 +- src/server/middleware/quota/put_manifest.go | 2 +- src/server/middleware/quota/quota.go | 2 +- src/server/middleware/quota/util.go | 2 +- src/server/middleware/quota/util_test.go | 4 +- src/server/middleware/repoproxy/proxy.go | 4 +- src/server/middleware/subject/subject.go | 2 +- src/server/registry/catalog.go | 2 +- src/server/route.go | 2 +- src/server/v2.0/handler/artifact.go | 6 +-- src/server/v2.0/handler/base.go | 10 ++--- src/server/v2.0/handler/config.go | 4 +- src/server/v2.0/handler/gc.go | 4 +- src/server/v2.0/handler/handler.go | 4 +- src/server/v2.0/handler/health.go | 2 +- src/server/v2.0/handler/jobservice.go | 4 +- src/server/v2.0/handler/model/project.go | 6 +-- src/server/v2.0/handler/model/scanner.go | 4 +- src/server/v2.0/handler/ping.go | 2 +- src/server/v2.0/handler/preheat.go | 4 +- src/server/v2.0/handler/project_metadata.go | 2 - src/server/v2.0/handler/purge.go | 2 +- src/server/v2.0/handler/registry.go | 4 +- src/server/v2.0/handler/replication.go | 2 +- src/server/v2.0/handler/repository.go | 2 +- src/server/v2.0/handler/retention.go | 4 +- src/server/v2.0/handler/scan.go | 2 +- src/server/v2.0/handler/scan_all.go | 10 ++--- src/server/v2.0/handler/scanexport.go | 16 +++---- src/server/v2.0/handler/statistic.go | 2 +- src/server/v2.0/handler/sys_cve_allowlist.go | 2 +- src/server/v2.0/handler/systeminfo.go | 6 +-- src/server/v2.0/handler/user.go | 2 +- src/server/v2.0/handler/webhook.go | 2 +- src/server/version.go | 2 +- .../scan/dao/scan/vulnerability_record_dao.go | 4 +- .../pkg/scan/export/filter_processor.go | 24 +++++------ tests/ci/distro_installer.sh | 4 +- tests/ci/ut_install.sh | 2 +- 166 files changed, 374 insertions(+), 360 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 32e34474d..180c98581 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -33,10 +33,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.20 + - name: Set up Go 1.21 uses: actions/setup-go@v1 with: - go-version: 1.20.7 + go-version: 1.21.7 id: go - uses: actions/checkout@v3 with: @@ -94,10 +94,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.20 + - name: Set up Go 1.21 uses: actions/setup-go@v1 with: - go-version: 1.20.7 + go-version: 1.21.7 id: go - uses: actions/checkout@v3 with: @@ -149,10 +149,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.20 + - name: Set up Go 1.21 uses: actions/setup-go@v1 with: - go-version: 1.20.7 + go-version: 1.21.7 id: go - uses: actions/checkout@v3 with: @@ -204,10 +204,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.20 + - name: Set up Go 1.21 uses: actions/setup-go@v1 with: - go-version: 1.20.7 + go-version: 1.21.7 id: go - uses: actions/checkout@v3 with: @@ -257,10 +257,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.20 + - name: Set up Go 1.21 uses: actions/setup-go@v1 with: - go-version: 1.20.7 + go-version: 1.21.7 id: go - uses: actions/checkout@v3 with: diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml index 0e3b36269..18a9b3d15 100644 --- a/.github/workflows/build-package.yml +++ b/.github/workflows/build-package.yml @@ -23,10 +23,10 @@ jobs: with: version: '430.0.0' - run: gcloud info - - name: Set up Go 1.20 + - name: Set up Go 1.21 uses: actions/setup-go@v1 with: - go-version: 1.20.7 + go-version: 1.21.7 id: go - name: Setup Docker uses: docker-practice/actions-setup-docker@master diff --git a/.github/workflows/conformance_test.yml b/.github/workflows/conformance_test.yml index ae329c84e..dce2a6b0d 100644 --- a/.github/workflows/conformance_test.yml +++ b/.github/workflows/conformance_test.yml @@ -25,10 +25,10 @@ jobs: credentials_json: '${{ secrets.GCP_CREDENTIALS }}' - uses: google-github-actions/setup-gcloud@v0 - run: gcloud info - - name: Set up Go 1.20 + - name: Set up Go 1.21 uses: actions/setup-go@v1 with: - go-version: 1.20.7 + go-version: 1.21.7 id: go - uses: actions/checkout@v3 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 959b9b916..b6bdb20e5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -145,27 +145,27 @@ The folder graph below shows the structure of the source code folder `harbor/src #### Go Harbor backend is written in [Go](http://golang.org/). If you don't have a Harbor backend service development environment, please [set one up](https://golang.org/doc/install). -| Harbor | Requires Go | -|----------|---------------| -| 1.1 | 1.7.3 | -| 1.2 | 1.7.3 | -| 1.3 | 1.9.2 | -| 1.4 | 1.9.2 | -| 1.5 | 1.9.2 | -| 1.6 | 1.9.2 | -| 1.7 | 1.9.2 | -| 1.8 | 1.11.2 | -| 1.9 | 1.12.12 | -| 1.10 | 1.12.12 | -| 2.0 | 1.13.15 | -| 2.1 | 1.14.13 | -| 2.2 | 1.15.6 | -| 2.3 | 1.15.12 | -| 2.4 | 1.17.7 | -| 2.5 | 1.17.7 | -| 2.6 | 1.18.6 | -| 2.7 | 1.19.4 | -| 2.8 | 1.20.7 | +| Harbor | Requires Go | +|----------|-------------| +| 1.1 | 1.7.3 | +| 1.2 | 1.7.3 | +| 1.3 | 1.9.2 | +| 1.4 | 1.9.2 | +| 1.5 | 1.9.2 | +| 1.6 | 1.9.2 | +| 1.7 | 1.9.2 | +| 1.8 | 1.11.2 | +| 1.9 | 1.12.12 | +| 1.10 | 1.12.12 | +| 2.0 | 1.13.15 | +| 2.1 | 1.14.13 | +| 2.2 | 1.15.6 | +| 2.3 | 1.15.12 | +| 2.4 | 1.17.7 | +| 2.5 | 1.17.7 | +| 2.6 | 1.18.6 | +| 2.7 | 1.19.4 | +| 2.8 | 1.21.7 | Ensure your GOPATH and PATH have been configured in accordance with the Go environment instructions. diff --git a/Makefile b/Makefile index b0c2f8331..af7b22a15 100644 --- a/Makefile +++ b/Makefile @@ -145,7 +145,7 @@ GOINSTALL=$(GOCMD) install GOTEST=$(GOCMD) test GODEP=$(GOTEST) -i GOFMT=gofmt -w -GOVERSION=1.20.7 +GOVERSION=1.21.7 GOBUILDIMAGE=goharbor/golang:$(GOVERSION) PUSHGOIMAGE=false GOBUILDPATHINCONTAINER=/harbor @@ -510,7 +510,7 @@ misspell: @find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error # golangci-lint binary installation or refer to https://golangci-lint.run/usage/install/#local-installation -# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2 +# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2 GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint lint: @echo checking lint diff --git a/make/photon/golang/Dockerfile b/make/photon/golang/Dockerfile index fa6a9972a..46cae02ca 100644 --- a/make/photon/golang/Dockerfile +++ b/make/photon/golang/Dockerfile @@ -12,7 +12,7 @@ ENV GOLANG_VERSION ${GOVERSION} RUN set eux; \ url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \ - sha256="f0a87f1bcae91c4b69f8dc2bc6d7e6bfcd7524fceec130af525058c0c17b1b44"; \ + sha256="13b76a9b2a26823e53062fa841b07087d48ae2ef2936445dc34c4ae03293702c"; \ wget -O go.tgz.asc "$url.asc"; \ wget -O go.tgz "$url"; \ echo "$sha256 *go.tgz" | sha256sum -c -; \ diff --git a/make/photon/registry/Dockerfile.binary b/make/photon/registry/Dockerfile.binary index b3a05c1f8..466954e38 100644 --- a/make/photon/registry/Dockerfile.binary +++ b/make/photon/registry/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM goharbor/golang:1.20.7 +FROM goharbor/golang:1.21.7 ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution ENV BUILDTAGS include_oss include_gcs diff --git a/make/photon/trivy-adapter/Dockerfile.binary b/make/photon/trivy-adapter/Dockerfile.binary index e9003c56b..611ff3e6a 100644 --- a/make/photon/trivy-adapter/Dockerfile.binary +++ b/make/photon/trivy-adapter/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM goharbor/golang:1.20.7 +FROM goharbor/golang:1.21.7 ADD . /go/src/github.com/aquasecurity/harbor-scanner-trivy/ WORKDIR /go/src/github.com/aquasecurity/harbor-scanner-trivy/ diff --git a/make/photon/trivy-adapter/builder.sh b/make/photon/trivy-adapter/builder.sh index 95ebd4225..afa2371ea 100755 --- a/make/photon/trivy-adapter/builder.sh +++ b/make/photon/trivy-adapter/builder.sh @@ -19,7 +19,7 @@ TEMP=$(mktemp -d ${TMPDIR-/tmp}/trivy-adapter.XXXXXX) git clone https://github.com/aquasecurity/harbor-scanner-trivy.git $TEMP cd $TEMP; git checkout $VERSION; cd - -echo "Building Trivy adapter binary based on goharbor/golang:1.20.7..." +echo "Building Trivy adapter binary based on goharbor/golang:1.21.7..." cp Dockerfile.binary $TEMP docker build -f $TEMP/Dockerfile.binary -t trivy-adapter-golang $TEMP diff --git a/src/common/rbac/project/evaluator.go b/src/common/rbac/project/evaluator.go index bba793acf..38f5753c0 100644 --- a/src/common/rbac/project/evaluator.go +++ b/src/common/rbac/project/evaluator.go @@ -58,7 +58,7 @@ func NewBuilderForUser(user *models.User, ctl project.Controller) RBACUserBuilde // NewBuilderForPolicies create a builder for the policies func NewBuilderForPolicies(username string, policies []*types.Policy, filters ...func(*proModels.Project, []*types.Policy) []*types.Policy) RBACUserBuilder { - return func(ctx context.Context, p *proModels.Project) types.RBACUser { + return func(_ context.Context, p *proModels.Project) types.RBACUser { for _, filter := range filters { policies = filter(p, policies) } diff --git a/src/common/rbac/system/evaluator.go b/src/common/rbac/system/evaluator.go index 97c8a3dfc..b17351ccd 100644 --- a/src/common/rbac/system/evaluator.go +++ b/src/common/rbac/system/evaluator.go @@ -11,7 +11,7 @@ import ( // NewEvaluator create evaluator for the system func NewEvaluator(username string, policies []*types.Policy) evaluator.Evaluator { - return namespace.New(NamespaceKind, func(ctx context.Context, ns types.Namespace) evaluator.Evaluator { + return namespace.New(NamespaceKind, func(_ context.Context, _ types.Namespace) evaluator.Evaluator { return rbac.New(&rbacUser{ username: username, policies: policies, diff --git a/src/common/security/secret/context.go b/src/common/security/secret/context.go index 6f639ff6a..ff1c21741 100644 --- a/src/common/security/secret/context.go +++ b/src/common/security/secret/context.go @@ -77,7 +77,7 @@ func (s *SecurityContext) IsSolutionUser() bool { // Can returns whether the user can do action on resource // returns true if the corresponding user of the secret // is jobservice or core service, otherwise returns false -func (s *SecurityContext) Can(ctx context.Context, action types.Action, resource types.Resource) bool { +func (s *SecurityContext) Can(_ context.Context, _ types.Action, _ types.Resource) bool { if s.store == nil { return false } diff --git a/src/common/security/v2token/context.go b/src/common/security/v2token/context.go index bdcaf1a36..ea8eeb1f3 100644 --- a/src/common/security/v2token/context.go +++ b/src/common/security/v2token/context.go @@ -49,7 +49,7 @@ func (t *tokenSecurityCtx) GetMyProjects() ([]*models.Project, error) { return []*models.Project{}, nil } -func (t *tokenSecurityCtx) GetProjectRoles(projectIDOrName interface{}) []int { +func (t *tokenSecurityCtx) GetProjectRoles(_ interface{}) []int { return []int{} } diff --git a/src/common/utils/test/registryctl.go b/src/common/utils/test/registryctl.go index 9af8a6b4d..dff8b52c2 100644 --- a/src/common/utils/test/registryctl.go +++ b/src/common/utils/test/registryctl.go @@ -30,7 +30,7 @@ type GCResult struct { } // NewRegistryCtl returns a mock registry server -func NewRegistryCtl(config map[string]interface{}) (*httptest.Server, error) { +func NewRegistryCtl(_ map[string]interface{}) (*httptest.Server, error) { m := []*RequestHandlerMapping{} gcr := GCResult{true, "hello-world", time.Now(), time.Now()} diff --git a/src/common/utils/uaa/fake_client.go b/src/common/utils/uaa/fake_client.go index bfc4b956d..02cc33984 100644 --- a/src/common/utils/uaa/fake_client.go +++ b/src/common/utils/uaa/fake_client.go @@ -49,7 +49,7 @@ func (fc *FakeClient) GetUserInfo(token string) (*UserInfo, error) { } // UpdateConfig ... -func (fc *FakeClient) UpdateConfig(cfg *ClientConfig) error { +func (fc *FakeClient) UpdateConfig(_ *ClientConfig) error { return nil } diff --git a/src/controller/artifact/annotation/v1alpha1.go b/src/controller/artifact/annotation/v1alpha1.go index 5201688ad..2e8c637b5 100644 --- a/src/controller/artifact/annotation/v1alpha1.go +++ b/src/controller/artifact/annotation/v1alpha1.go @@ -25,7 +25,7 @@ type v1alpha1Parser struct { regCli reg.Client } -func (p *v1alpha1Parser) Parse(ctx context.Context, artifact *artifact.Artifact, manifest []byte) error { +func (p *v1alpha1Parser) Parse(_ context.Context, artifact *artifact.Artifact, manifest []byte) error { if artifact.ManifestMediaType != v1.MediaTypeImageManifest && artifact.ManifestMediaType != schema2.MediaTypeManifest { return nil } diff --git a/src/controller/artifact/processor/base/index.go b/src/controller/artifact/processor/base/index.go index f3e0d5025..985e5c782 100644 --- a/src/controller/artifact/processor/base/index.go +++ b/src/controller/artifact/processor/base/index.go @@ -37,22 +37,22 @@ type IndexProcessor struct { } // AbstractMetadata abstracts metadata of artifact -func (m *IndexProcessor) AbstractMetadata(ctx context.Context, artifact *artifact.Artifact, content []byte) error { +func (m *IndexProcessor) AbstractMetadata(_ context.Context, _ *artifact.Artifact, _ []byte) error { return nil } // AbstractAddition abstracts the addition of artifact -func (m *IndexProcessor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*processor.Addition, error) { +func (m *IndexProcessor) AbstractAddition(_ context.Context, _ *artifact.Artifact, addition string) (*processor.Addition, error) { return nil, errors.New(nil).WithCode(errors.BadRequestCode). WithMessage("addition %s isn't supported", addition) } // GetArtifactType returns the artifact type -func (m *IndexProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (m *IndexProcessor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { return "" } // ListAdditionTypes returns the supported addition types -func (m *IndexProcessor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string { +func (m *IndexProcessor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string { return nil } diff --git a/src/controller/artifact/processor/base/manifest.go b/src/controller/artifact/processor/base/manifest.go index f68e46434..2b7d960e8 100644 --- a/src/controller/artifact/processor/base/manifest.go +++ b/src/controller/artifact/processor/base/manifest.go @@ -64,23 +64,23 @@ func (m *ManifestProcessor) AbstractMetadata(ctx context.Context, artifact *arti } // AbstractAddition abstracts the addition of artifact -func (m *ManifestProcessor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*processor.Addition, error) { +func (m *ManifestProcessor) AbstractAddition(_ context.Context, _ *artifact.Artifact, addition string) (*processor.Addition, error) { return nil, errors.New(nil).WithCode(errors.BadRequestCode). WithMessage("addition %s isn't supported", addition) } // GetArtifactType returns the artifact type -func (m *ManifestProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (m *ManifestProcessor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { return "" } // ListAdditionTypes returns the supported addition types -func (m *ManifestProcessor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string { +func (m *ManifestProcessor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string { return nil } // UnmarshalConfig unmarshal the config blob of the artifact into the specified object "v" -func (m *ManifestProcessor) UnmarshalConfig(ctx context.Context, repository string, manifest []byte, v interface{}) error { +func (m *ManifestProcessor) UnmarshalConfig(_ context.Context, repository string, manifest []byte, v interface{}) error { // unmarshal manifest mani := &v1.Manifest{} if err := json.Unmarshal(manifest, mani); err != nil { diff --git a/src/controller/artifact/processor/chart/chart.go b/src/controller/artifact/processor/chart/chart.go index 8fa213aa2..059d47bbf 100644 --- a/src/controller/artifact/processor/chart/chart.go +++ b/src/controller/artifact/processor/chart/chart.go @@ -58,7 +58,7 @@ type processor struct { chartOperator chart.Operator } -func (p *processor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*ps.Addition, error) { +func (p *processor) AbstractAddition(_ context.Context, artifact *artifact.Artifact, addition string) (*ps.Addition, error) { if addition != AdditionTypeValues && addition != AdditionTypeReadme && addition != AdditionTypeDependencies { return nil, errors.New(nil).WithCode(errors.BadRequestCode). WithMessage("addition %s isn't supported for %s", addition, ArtifactTypeChart) @@ -122,10 +122,10 @@ func (p *processor) AbstractAddition(ctx context.Context, artifact *artifact.Art return nil, nil } -func (p *processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (p *processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { return ArtifactTypeChart } -func (p *processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string { +func (p *processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string { return []string{AdditionTypeValues, AdditionTypeReadme, AdditionTypeDependencies} } diff --git a/src/controller/artifact/processor/cnab/cnab.go b/src/controller/artifact/processor/cnab/cnab.go index 7b2605118..681749b17 100644 --- a/src/controller/artifact/processor/cnab/cnab.go +++ b/src/controller/artifact/processor/cnab/cnab.go @@ -45,7 +45,7 @@ type processor struct { manifestProcessor *base.ManifestProcessor } -func (p *processor) AbstractMetadata(ctx context.Context, art *artifact.Artifact, manifest []byte) error { +func (p *processor) AbstractMetadata(ctx context.Context, art *artifact.Artifact, _ []byte) error { cfgManiDgt := "" // try to get the digest of the manifest that the config layer is referenced by for _, reference := range art.References { @@ -72,6 +72,6 @@ func (p *processor) AbstractMetadata(ctx context.Context, art *artifact.Artifact return p.manifestProcessor.AbstractMetadata(ctx, art, payload) } -func (p *processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (p *processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { return ArtifactTypeCNAB } diff --git a/src/controller/artifact/processor/default.go b/src/controller/artifact/processor/default.go index e8fea66f2..d36b79408 100644 --- a/src/controller/artifact/processor/default.go +++ b/src/controller/artifact/processor/default.go @@ -48,7 +48,7 @@ type defaultProcessor struct { regCli registry.Client } -func (d *defaultProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (d *defaultProcessor) GetArtifactType(_ context.Context, artifact *artifact.Artifact) string { // try to parse the type from the media type strs := artifactTypeRegExp.FindStringSubmatch(artifact.MediaType) if len(strs) == 2 { @@ -57,7 +57,7 @@ func (d *defaultProcessor) GetArtifactType(ctx context.Context, artifact *artifa // can not get the artifact type from the media type, return unknown return ArtifactTypeUnknown } -func (d *defaultProcessor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string { +func (d *defaultProcessor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string { return nil } @@ -126,7 +126,7 @@ func (d *defaultProcessor) AbstractMetadata(ctx context.Context, artifact *artif return nil } -func (d *defaultProcessor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*Addition, error) { +func (d *defaultProcessor) AbstractAddition(_ context.Context, artifact *artifact.Artifact, _ string) (*Addition, error) { // Addition not support for user-defined artifact yet. // It will be support in the future. // return error directly diff --git a/src/controller/artifact/processor/image/index.go b/src/controller/artifact/processor/image/index.go index adb0dda25..99674cb62 100644 --- a/src/controller/artifact/processor/image/index.go +++ b/src/controller/artifact/processor/image/index.go @@ -44,6 +44,6 @@ type indexProcessor struct { *base.IndexProcessor } -func (i *indexProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (i *indexProcessor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { return ArtifactTypeImage } diff --git a/src/controller/artifact/processor/image/manifest_v1.go b/src/controller/artifact/processor/image/manifest_v1.go index d8e41cf7e..3b03876b7 100644 --- a/src/controller/artifact/processor/image/manifest_v1.go +++ b/src/controller/artifact/processor/image/manifest_v1.go @@ -38,7 +38,7 @@ func init() { type manifestV1Processor struct { } -func (m *manifestV1Processor) AbstractMetadata(ctx context.Context, artifact *artifact.Artifact, manifest []byte) error { +func (m *manifestV1Processor) AbstractMetadata(_ context.Context, artifact *artifact.Artifact, manifest []byte) error { mani := &schema1.Manifest{} if err := json.Unmarshal(manifest, mani); err != nil { return err @@ -50,15 +50,15 @@ func (m *manifestV1Processor) AbstractMetadata(ctx context.Context, artifact *ar return nil } -func (m *manifestV1Processor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*processor.Addition, error) { +func (m *manifestV1Processor) AbstractAddition(_ context.Context, _ *artifact.Artifact, addition string) (*processor.Addition, error) { return nil, errors.New(nil).WithCode(errors.BadRequestCode). WithMessage("addition %s isn't supported for %s(manifest version 1)", addition, ArtifactTypeImage) } -func (m *manifestV1Processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (m *manifestV1Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { return ArtifactTypeImage } -func (m *manifestV1Processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string { +func (m *manifestV1Processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string { return nil } diff --git a/src/controller/artifact/processor/image/manifest_v2.go b/src/controller/artifact/processor/image/manifest_v2.go index 7b6560330..2948dac74 100644 --- a/src/controller/artifact/processor/image/manifest_v2.go +++ b/src/controller/artifact/processor/image/manifest_v2.go @@ -112,10 +112,10 @@ func (m *manifestV2Processor) AbstractAddition(ctx context.Context, artifact *ar }, nil } -func (m *manifestV2Processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (m *manifestV2Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { return ArtifactTypeImage } -func (m *manifestV2Processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string { +func (m *manifestV2Processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string { return []string{AdditionTypeBuildHistory} } diff --git a/src/controller/artifact/processor/wasm/wasm.go b/src/controller/artifact/processor/wasm/wasm.go index a499dd592..be6cba8e4 100644 --- a/src/controller/artifact/processor/wasm/wasm.go +++ b/src/controller/artifact/processor/wasm/wasm.go @@ -128,10 +128,10 @@ func (m *Processor) AbstractAddition(ctx context.Context, artifact *artifact.Art }, nil } -func (m *Processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string { +func (m *Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { return ArtifactTypeWASM } -func (m *Processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string { +func (m *Processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string { return []string{AdditionTypeBuildHistory} } diff --git a/src/controller/config/controller.go b/src/controller/config/controller.go index 196ae960f..316c06502 100644 --- a/src/controller/config/controller.go +++ b/src/controller/config/controller.go @@ -169,7 +169,7 @@ func verifySkipAuditLogCfg(ctx context.Context, cfgs map[string]interface{}, mgr } // verifyValueLengthCfg verifies the cfgs which need to check the value max length to align with frontend. -func verifyValueLengthCfg(ctx context.Context, cfgs map[string]interface{}) error { +func verifyValueLengthCfg(_ context.Context, cfgs map[string]interface{}) error { maxValue := maxValueLimitedByLength(common.UIMaxLengthLimitedOfNumber) validateCfgs := []string{ common.TokenExpiration, diff --git a/src/controller/event/handler/internal/artifact.go b/src/controller/event/handler/internal/artifact.go index 284934d5e..a45ca77ff 100644 --- a/src/controller/event/handler/internal/artifact.go +++ b/src/controller/event/handler/internal/artifact.go @@ -144,7 +144,7 @@ func (a *Handler) onPull(ctx context.Context, event *event.ArtifactEvent) error return nil } -func (a *Handler) updatePullTimeInCache(ctx context.Context, event *event.ArtifactEvent) { +func (a *Handler) updatePullTimeInCache(_ context.Context, event *event.ArtifactEvent) { var tagName string if len(event.Tags) != 0 { tagName = event.Tags[0] @@ -158,7 +158,7 @@ func (a *Handler) updatePullTimeInCache(ctx context.Context, event *event.Artifa a.pullTimeStore[key] = time.Now() } -func (a *Handler) addPullCountInCache(ctx context.Context, event *event.ArtifactEvent) { +func (a *Handler) addPullCountInCache(_ context.Context, event *event.ArtifactEvent) { a.pullCountLock.Lock() defer a.pullCountLock.Unlock() diff --git a/src/controller/gc/callback.go b/src/controller/gc/callback.go index d8f33321c..07ab9525d 100644 --- a/src/controller/gc/callback.go +++ b/src/controller/gc/callback.go @@ -48,7 +48,7 @@ func gcCallback(ctx context.Context, p string) error { return err } -func gcTaskStatusChange(ctx context.Context, taskID int64, status string) error { +func gcTaskStatusChange(ctx context.Context, _ int64, status string) error { if status == job.SuccessStatus.String() && config.QuotaPerProjectEnable(ctx) { go func() { err := quota.RefreshForProjects(orm.Context()) diff --git a/src/controller/health/controller.go b/src/controller/health/controller.go index 9b67edc37..5272ee19b 100644 --- a/src/controller/health/controller.go +++ b/src/controller/health/controller.go @@ -41,7 +41,7 @@ type Controller interface { type controller struct{} -func (c *controller) GetHealth(ctx context.Context) *OverallHealthStatus { +func (c *controller) GetHealth(_ context.Context) *OverallHealthStatus { var isHealthy healthy = true components := []*ComponentHealthStatus{} ch := make(chan *ComponentHealthStatus, len(registry)) diff --git a/src/controller/p2p/preheat/controller.go b/src/controller/p2p/preheat/controller.go index 8168f966a..5b3842c86 100644 --- a/src/controller/p2p/preheat/controller.go +++ b/src/controller/p2p/preheat/controller.go @@ -469,7 +469,7 @@ func (c *controller) ListPoliciesByProject(ctx context.Context, project int64, q } // CheckHealth checks the instance health, for test connection -func (c *controller) CheckHealth(ctx context.Context, instance *providerModels.Instance) error { +func (c *controller) CheckHealth(_ context.Context, instance *providerModels.Instance) error { if instance == nil { return errors.New("instance can not be nil") } diff --git a/src/controller/project/controller.go b/src/controller/project/controller.go index 9cdc1c1e8..1fb2feb1f 100644 --- a/src/controller/project/controller.go +++ b/src/controller/project/controller.go @@ -150,9 +150,8 @@ func (c *controller) Exists(ctx context.Context, projectIDOrName interface{}) (b return true, nil } else if errors.IsNotFoundErr(err) { return false, nil - } else { - return false, err } + return false, err } func (c *controller) Get(ctx context.Context, projectIDOrName interface{}, options ...Option) (*models.Project, error) { diff --git a/src/controller/proxy/controller.go b/src/controller/proxy/controller.go index 1b7dc7ef5..015f18e8b 100644 --- a/src/controller/proxy/controller.go +++ b/src/controller/proxy/controller.go @@ -101,15 +101,18 @@ func (c *controller) EnsureTag(ctx context.Context, art lib.ArtifactInfo, tagNam // search the digest in cache and query with trimmed digest var trimmedDigest string err := c.cache.Fetch(ctx, TrimmedManifestlist+art.Digest, &trimmedDigest) - if errors.Is(err, cache.ErrNotFound) { - // skip to update digest, continue - } else if err != nil { - // for other error, return - return err - } else { - // found in redis, update the digest + if err == nil { + // it's found in redis, update the digest art.Digest = trimmedDigest log.Debugf("Found trimmed digest: %v", trimmedDigest) + } else { + // err != nil + if !errors.Is(err, cache.ErrNotFound) { + // for non-NotFound error return the error + return err + } + // else: + // err is a NotFound error, skip to update digest, continue } a, err := c.local.GetManifest(ctx, art) if err != nil { @@ -260,7 +263,7 @@ func (c *controller) ProxyManifest(ctx context.Context, art lib.ArtifactInfo, re return man, nil } -func (c *controller) HeadManifest(ctx context.Context, art lib.ArtifactInfo, remote RemoteInterface) (bool, *distribution.Descriptor, error) { +func (c *controller) HeadManifest(_ context.Context, art lib.ArtifactInfo, remote RemoteInterface) (bool, *distribution.Descriptor, error) { remoteRepo := getRemoteRepo(art) ref := getReference(art) return remote.ManifestExist(remoteRepo, ref) diff --git a/src/controller/proxy/local.go b/src/controller/proxy/local.go index 1df1d012a..9d5488148 100644 --- a/src/controller/proxy/local.go +++ b/src/controller/proxy/local.go @@ -81,7 +81,7 @@ func newLocalHelper() localInterface { return l } -func (l *localHelper) BlobExist(ctx context.Context, art lib.ArtifactInfo) (bool, error) { +func (l *localHelper) BlobExist(_ context.Context, art lib.ArtifactInfo) (bool, error) { return l.registry.BlobExist(art.Repository, art.Digest) } diff --git a/src/controller/proxy/manifestcache.go b/src/controller/proxy/manifestcache.go index 1a717ef6b..515670520 100644 --- a/src/controller/proxy/manifestcache.go +++ b/src/controller/proxy/manifestcache.go @@ -63,7 +63,7 @@ type ManifestListCache struct { } // CacheContent ... -func (m *ManifestListCache) CacheContent(ctx context.Context, remoteRepo string, man distribution.Manifest, art lib.ArtifactInfo, r RemoteInterface, contentType string) { +func (m *ManifestListCache) CacheContent(ctx context.Context, _ string, man distribution.Manifest, art lib.ArtifactInfo, _ RemoteInterface, contentType string) { _, payload, err := man.Payload() if err != nil { log.Errorf("failed to get payload, error %v", err) @@ -171,7 +171,7 @@ type ManifestCache struct { } // CacheContent ... -func (m *ManifestCache) CacheContent(ctx context.Context, remoteRepo string, man distribution.Manifest, art lib.ArtifactInfo, r RemoteInterface, contentType string) { +func (m *ManifestCache) CacheContent(ctx context.Context, remoteRepo string, man distribution.Manifest, art lib.ArtifactInfo, r RemoteInterface, _ string) { var waitBlobs []distribution.Descriptor for n := 0; n < maxManifestWait; n++ { time.Sleep(sleepIntervalSec * time.Second) diff --git a/src/controller/quota/controller.go b/src/controller/quota/controller.go index a95143f68..547e90e74 100644 --- a/src/controller/quota/controller.go +++ b/src/controller/quota/controller.go @@ -198,7 +198,7 @@ func (c *controller) updateUsageWithRetry(ctx context.Context, reference, refere options := []retry.Option{ retry.Timeout(defaultRetryTimeout), retry.Backoff(false), - retry.Callback(func(err error, sleep time.Duration) { + retry.Callback(func(err error, _ time.Duration) { log.G(ctx).Debugf("failed to update the quota usage for %s %s, error: %v", reference, referenceID, err) }), } @@ -284,7 +284,7 @@ func (c *controller) Update(ctx context.Context, u *quota.Quota) error { } // Driver returns quota driver for the reference -func Driver(ctx context.Context, reference string) (driver.Driver, error) { +func Driver(_ context.Context, reference string) (driver.Driver, error) { d, ok := driver.Get(reference) if !ok { return nil, fmt.Errorf("quota not support for %s", reference) @@ -316,7 +316,7 @@ func reserveResources(resources types.ResourceList) func(hardLimits, used types. } func rollbackResources(resources types.ResourceList) func(hardLimits, used types.ResourceList) (types.ResourceList, error) { - return func(hardLimits, used types.ResourceList) (types.ResourceList, error) { + return func(_, used types.ResourceList) (types.ResourceList, error) { newUsed := types.Subtract(used, resources) // ensure that new used is never negative if negativeUsed := types.IsNegative(newUsed); len(negativeUsed) > 0 { diff --git a/src/controller/quota/driver/project/project.go b/src/controller/quota/driver/project/project.go index 34f65d6de..4f1f1121d 100644 --- a/src/controller/quota/driver/project/project.go +++ b/src/controller/quota/driver/project/project.go @@ -42,7 +42,7 @@ type driver struct { blobCtl blob.Controller } -func (d *driver) Enabled(ctx context.Context, key string) (bool, error) { +func (d *driver) Enabled(ctx context.Context, _ string) (bool, error) { // NOTE: every time load the new configurations from the db to get the latest configurations may have performance problem. if err := d.cfg.Load(ctx); err != nil { return false, err diff --git a/src/controller/replication/transfer/image/transfer.go b/src/controller/replication/transfer/image/transfer.go index 79f30e9a6..55bda9646 100644 --- a/src/controller/replication/transfer/image/transfer.go +++ b/src/controller/replication/transfer/image/transfer.go @@ -326,7 +326,7 @@ func (t *transfer) copyChunkWithRetry(srcRepo, dstRepo, digest string, sizeFromD } // tryMountBlob try to check existence and mount, return true if mounted. -func (t *transfer) tryMountBlob(srcRepo, dstRepo, digest string) (bool, error) { +func (t *transfer) tryMountBlob(_, dstRepo, digest string) (bool, error) { if t.shouldStop() { return false, errStopped } diff --git a/src/controller/scan/callback.go b/src/controller/scan/callback.go index 58bdc1b25..8f45a6983 100644 --- a/src/controller/scan/callback.go +++ b/src/controller/scan/callback.go @@ -55,7 +55,7 @@ func init() { } } -func scanAllCallback(ctx context.Context, param string) error { +func scanAllCallback(ctx context.Context, _ string) error { _, err := scanCtl.ScanAll(ctx, task.ExecutionTriggerSchedule, true) return err } diff --git a/src/controller/systemartifact/callback.go b/src/controller/systemartifact/callback.go index ac2591d12..df2f7063f 100644 --- a/src/controller/systemartifact/callback.go +++ b/src/controller/systemartifact/callback.go @@ -23,7 +23,7 @@ func init() { } } -func cleanupCallBack(ctx context.Context, param string) error { +func cleanupCallBack(ctx context.Context, _ string) error { err := cleanupController.Start(ctx, true, task.ExecutionTriggerSchedule) if err != nil { logger.Errorf("System artifact cleanup job encountered errors: %v", err) diff --git a/src/controller/systeminfo/controller.go b/src/controller/systeminfo/controller.go index e7124eb70..86bfa4f48 100644 --- a/src/controller/systeminfo/controller.go +++ b/src/controller/systeminfo/controller.go @@ -131,7 +131,7 @@ func (c *controller) GetInfo(ctx context.Context, opt Options) (*Data, error) { return res, nil } -func (c *controller) GetCapacity(ctx context.Context) (*imagestorage.Capacity, error) { +func (c *controller) GetCapacity(_ context.Context) (*imagestorage.Capacity, error) { systeminfo.Init() return imagestorage.GlobalDriver.Cap() } @@ -142,14 +142,14 @@ func (c *controller) GetCA(ctx context.Context) (io.ReadCloser, error) { if len(testRootCertPath) > 0 { path = testRootCertPath } - if _, err := os.Stat(path); err == nil { + var err error + if _, err = os.Stat(path); err == nil { return os.Open(path) } else if os.IsNotExist(err) { return nil, errors.NotFoundError(fmt.Errorf("cert not found in path: %s", path)) - } else { - logger.Errorf("Failed to stat the cert, path: %s, error: %v", path, err) - return nil, err } + logger.Errorf("Failed to stat the cert, path: %s, error: %v", path, err) + return nil, err } // NewController return an instance of controller diff --git a/src/controller/task/sweep.go b/src/controller/task/sweep.go index 5ebc848d1..cc374aaf6 100644 --- a/src/controller/task/sweep.go +++ b/src/controller/task/sweep.go @@ -52,7 +52,7 @@ func init() { } } -func sweepCallback(ctx context.Context, p string) error { +func sweepCallback(ctx context.Context, _ string) error { params := &SweepParams{ExecRetainCounts: job.GetExecutionSweeperCount()} return SweepCtl.Start(ctx, params, task.ExecutionTriggerSchedule) } diff --git a/src/core/auth/authenticator.go b/src/core/auth/authenticator.go index a2aaa96fb..5503e08ab 100644 --- a/src/core/auth/authenticator.go +++ b/src/core/auth/authenticator.go @@ -88,35 +88,35 @@ type DefaultAuthenticateHelper struct { } // Authenticate ... -func (d *DefaultAuthenticateHelper) Authenticate(ctx context.Context, m models.AuthModel) (*models.User, error) { +func (d *DefaultAuthenticateHelper) Authenticate(_ context.Context, _ models.AuthModel) (*models.User, error) { return nil, ErrNotSupported } // OnBoardUser will check if a user exists in user table, if not insert the user and // put the id in the pointer of user model, if it does exist, fill in the user model based // on the data record of the user -func (d *DefaultAuthenticateHelper) OnBoardUser(ctx context.Context, u *models.User) error { +func (d *DefaultAuthenticateHelper) OnBoardUser(_ context.Context, _ *models.User) error { return ErrNotSupported } // SearchUser - Get user information from account repository -func (d *DefaultAuthenticateHelper) SearchUser(ctx context.Context, username string) (*models.User, error) { +func (d *DefaultAuthenticateHelper) SearchUser(_ context.Context, username string) (*models.User, error) { log.Errorf("Not support searching user, username: %s", username) return nil, libErrors.NotFoundError(ErrNotSupported).WithMessage("%s not found", username) } // PostAuthenticate - Update user information after authenticate, such as OnBoard or sync info etc -func (d *DefaultAuthenticateHelper) PostAuthenticate(ctx context.Context, u *models.User) error { +func (d *DefaultAuthenticateHelper) PostAuthenticate(_ context.Context, _ *models.User) error { return nil } // OnBoardGroup - OnBoardGroup, it will set the ID of the user group, if altGroupName is not empty, take the altGroupName as groupName in harbor DB. -func (d *DefaultAuthenticateHelper) OnBoardGroup(ctx context.Context, u *model.UserGroup, altGroupName string) error { +func (d *DefaultAuthenticateHelper) OnBoardGroup(_ context.Context, _ *model.UserGroup, _ string) error { return ErrNotSupported } // SearchGroup - Search ldap group by group key, groupKey is the unique attribute of group in authenticator, for LDAP, the key is group DN -func (d *DefaultAuthenticateHelper) SearchGroup(ctx context.Context, groupKey string) (*model.UserGroup, error) { +func (d *DefaultAuthenticateHelper) SearchGroup(_ context.Context, groupKey string) (*model.UserGroup, error) { log.Errorf("Not support searching group, group key: %s", groupKey) return nil, libErrors.NotFoundError(ErrNotSupported).WithMessage("%s not found", groupKey) } diff --git a/src/core/auth/authproxy/auth.go b/src/core/auth/authproxy/auth.go index 952a39a00..5f062ae01 100644 --- a/src/core/auth/authproxy/auth.go +++ b/src/core/auth/authproxy/auth.go @@ -102,13 +102,12 @@ func (a *Auth) Authenticate(ctx context.Context, m models.AuthModel) (*models.Us return user, nil } else if resp.StatusCode == http.StatusUnauthorized { return nil, auth.NewErrAuth(string(data)) - } else { - data, err := io.ReadAll(resp.Body) - if err != nil { - log.Warningf("Failed to read response body, error: %v", err) - } - return nil, fmt.Errorf("failed to authenticate, status code: %d, text: %s", resp.StatusCode, string(data)) } + data, err = io.ReadAll(resp.Body) + if err != nil { + log.Warningf("Failed to read response body, error: %v", err) + } + return nil, fmt.Errorf("failed to authenticate, status code: %d, text: %s", resp.StatusCode, string(data)) } func (a *Auth) tokenReview(ctx context.Context, sessionID string) (*models.User, error) { @@ -191,7 +190,7 @@ func (a *Auth) SearchGroup(ctx context.Context, groupKey string) (*model.UserGro } // OnBoardGroup create user group entity in Harbor DB, altGroupName is not used. -func (a *Auth) OnBoardGroup(ctx context.Context, u *model.UserGroup, altGroupName string) error { +func (a *Auth) OnBoardGroup(ctx context.Context, u *model.UserGroup, _ string) error { // if group name provided, on board the user group if len(u.GroupName) == 0 { return errors.New("should provide a group name") diff --git a/src/core/auth/authproxy/test/server.go b/src/core/auth/authproxy/test/server.go index 99972f82f..fb3835cd4 100644 --- a/src/core/auth/authproxy/test/server.go +++ b/src/core/auth/authproxy/test/server.go @@ -58,9 +58,8 @@ func (ah *authHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { _, err := rw.Write([]byte(fmt.Sprintf(`{"session_id": "%s"}`, e.sessionID))) if err != nil { panic(err) - } else { - return } + return } } http.Error(rw, fmt.Sprintf("Do not find entry in entrylist, username: %s", html.EscapeString(u)), http.StatusUnauthorized) @@ -89,9 +88,8 @@ func (rth *reviewTokenHandler) ServeHTTP(rw http.ResponseWriter, req *http.Reque _, err := rw.Write([]byte(fmt.Sprintf(reviewStatusTpl, e.username))) if err != nil { panic(err) - } else { - return } + return } } http.Error(rw, html.EscapeString(fmt.Sprintf("failed to match token: %s, entrylist: %+v", reviewData.Spec.Token, rth.entries)), http.StatusUnauthorized) diff --git a/src/core/auth/db/db.go b/src/core/auth/db/db.go index 715c06705..4772e5d23 100644 --- a/src/core/auth/db/db.go +++ b/src/core/auth/db/db.go @@ -54,7 +54,7 @@ func (d *Auth) SearchUser(ctx context.Context, username string) (*models.User, e } // OnBoardUser - -func (d *Auth) OnBoardUser(ctx context.Context, u *models.User) error { +func (d *Auth) OnBoardUser(_ context.Context, _ *models.User) error { return nil } diff --git a/src/core/auth/oidc/oidc.go b/src/core/auth/oidc/oidc.go index eb9ff1c58..1e265b0f5 100644 --- a/src/core/auth/oidc/oidc.go +++ b/src/core/auth/oidc/oidc.go @@ -16,7 +16,7 @@ type Auth struct { } // SearchGroup is skipped in OIDC mode, so it makes sure any group will be onboarded. -func (a *Auth) SearchGroup(ctx context.Context, groupKey string) (*model.UserGroup, error) { +func (a *Auth) SearchGroup(_ context.Context, groupKey string) (*model.UserGroup, error) { return &model.UserGroup{ GroupName: groupKey, GroupType: common.OIDCGroupType, @@ -24,7 +24,7 @@ func (a *Auth) SearchGroup(ctx context.Context, groupKey string) (*model.UserGro } // OnBoardGroup create user group entity in Harbor DB, altGroupName is not used. -func (a *Auth) OnBoardGroup(ctx context.Context, u *model.UserGroup, altGroupName string) error { +func (a *Auth) OnBoardGroup(ctx context.Context, u *model.UserGroup, _ string) error { // if group name provided, on board the user group if len(u.GroupName) == 0 || u.GroupType != common.OIDCGroupType { return fmt.Errorf("invalid input group for OIDC mode: %v", *u) diff --git a/src/core/service/token/creator.go b/src/core/service/token/creator.go index a2198d510..d0c669274 100644 --- a/src/core/service/token/creator.go +++ b/src/core/service/token/creator.go @@ -145,7 +145,7 @@ type accessFilter interface { type registryFilter struct { } -func (reg registryFilter) filter(ctx context.Context, ctl project.Controller, +func (reg registryFilter) filter(ctx context.Context, _ project.Controller, a *token.ResourceActions) error { // Do not filter if the request is to access registry catalog if a.Name != "catalog" { diff --git a/src/core/session/session.go b/src/core/session/session.go index 80d4b389c..ed67332dd 100644 --- a/src/core/session/session.go +++ b/src/core/session/session.go @@ -47,7 +47,7 @@ type Store struct { } // Set value in redis session -func (rs *Store) Set(ctx context.Context, key, value interface{}) error { +func (rs *Store) Set(_ context.Context, key, value interface{}) error { rs.lock.Lock() defer rs.lock.Unlock() rs.values[key] = value @@ -55,7 +55,7 @@ func (rs *Store) Set(ctx context.Context, key, value interface{}) error { } // Get value in redis session -func (rs *Store) Get(ctx context.Context, key interface{}) interface{} { +func (rs *Store) Get(_ context.Context, key interface{}) interface{} { rs.lock.RLock() defer rs.lock.RUnlock() if v, ok := rs.values[key]; ok { @@ -65,7 +65,7 @@ func (rs *Store) Get(ctx context.Context, key interface{}) interface{} { } // Delete value in redis session -func (rs *Store) Delete(ctx context.Context, key interface{}) error { +func (rs *Store) Delete(_ context.Context, key interface{}) error { rs.lock.Lock() defer rs.lock.Unlock() delete(rs.values, key) @@ -73,7 +73,7 @@ func (rs *Store) Delete(ctx context.Context, key interface{}) error { } // Flush clear all values in redis session -func (rs *Store) Flush(ctx context.Context) error { +func (rs *Store) Flush(_ context.Context) error { rs.lock.Lock() defer rs.lock.Unlock() rs.values = make(map[interface{}]interface{}) @@ -81,12 +81,12 @@ func (rs *Store) Flush(ctx context.Context) error { } // SessionID get redis session id -func (rs *Store) SessionID(ctx context.Context) string { +func (rs *Store) SessionID(_ context.Context) string { return rs.sid } // SessionRelease save session values to redis -func (rs *Store) SessionRelease(ctx context.Context, w http.ResponseWriter) { +func (rs *Store) SessionRelease(ctx context.Context, _ http.ResponseWriter) { b, err := session.EncodeGob(rs.values) if err != nil { return @@ -193,11 +193,11 @@ func (rp *Provider) SessionDestroy(ctx context.Context, sid string) error { } // SessionGC Implement method, no used. -func (rp *Provider) SessionGC(ctx context.Context) { +func (rp *Provider) SessionGC(_ context.Context) { } // SessionAll return all activeSession -func (rp *Provider) SessionAll(ctx context.Context) int { +func (rp *Provider) SessionAll(_ context.Context) int { return 0 } diff --git a/src/go.mod b/src/go.mod index 01427df2d..33f76add1 100644 --- a/src/go.mod +++ b/src/go.mod @@ -1,6 +1,6 @@ module github.com/goharbor/harbor/src -go 1.20 +go 1.21 require ( github.com/FZambia/sentinel v1.1.0 diff --git a/src/go.sum b/src/go.sum index 77a02b8f7..410ef10a9 100644 --- a/src/go.sum +++ b/src/go.sum @@ -119,6 +119,7 @@ github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= +github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Unknwon/goconfig v0.0.0-20160216183935-5f601ca6ef4d h1:RjxaKUAINjr+fYbaYjpdBUZc8R3+wF/Yr2XkDHho4Sg= @@ -389,6 +390,7 @@ github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/docker v20.10.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= +github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go v0.0.0-20160303222718-d30aec9fd63c h1:Ggg7IiOtghyZzn3ozi31kPHpV6qSjMgmesXaWCijYNM= github.com/docker/go v0.0.0-20160303222718-d30aec9fd63c/go.mod h1:CADgU4DSXK5QUlFslkQu2yW2TKzFZcXq/leZfM0UH5Q= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -400,6 +402,7 @@ github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHz github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= @@ -412,11 +415,13 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw= +github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= +github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -441,6 +446,7 @@ github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVB github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -557,6 +563,7 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -662,6 +669,7 @@ github.com/google/certificate-transparency-go v1.0.21 h1:Yf1aXowfZ2nuboBsg7iYGLm github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= github.com/google/flatbuffers v2.0.0+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= +github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -675,6 +683,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v35 v35.2.0/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= @@ -903,6 +912,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= @@ -918,6 +928,7 @@ github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= +github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= @@ -955,6 +966,7 @@ github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOq github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.7 h1:fxWBnXkxfM6sRiuH3bqJ4CfzZojMOLVc0UTsTglEghA= +github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= @@ -984,6 +996,7 @@ github.com/moby/sys/symlink v0.1.0/go.mod h1:GGDODQmbFOjFsXvfLVn3+ZRxkch54RkSiGq github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -1049,6 +1062,7 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= +github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= @@ -1172,6 +1186,7 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= @@ -1190,6 +1205,7 @@ github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9Nz github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= @@ -1276,6 +1292,7 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= @@ -1746,6 +1763,7 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1959,6 +1977,7 @@ k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= +k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk= diff --git a/src/jobservice/job/impl/gc/garbage_collection.go b/src/jobservice/job/impl/gc/garbage_collection.go index aba2990f0..016795ffa 100644 --- a/src/jobservice/job/impl/gc/garbage_collection.go +++ b/src/jobservice/job/impl/gc/garbage_collection.go @@ -83,7 +83,7 @@ func (gc *GarbageCollector) ShouldRetry() bool { } // Validate implements the interface in job/Interface -func (gc *GarbageCollector) Validate(params job.Parameters) error { +func (gc *GarbageCollector) Validate(_ job.Parameters) error { return nil } diff --git a/src/jobservice/job/impl/notification/webhook_job.go b/src/jobservice/job/impl/notification/webhook_job.go index fcefeff04..49e4e698b 100644 --- a/src/jobservice/job/impl/notification/webhook_job.go +++ b/src/jobservice/job/impl/notification/webhook_job.go @@ -46,7 +46,7 @@ func (wj *WebhookJob) ShouldRetry() bool { } // Validate implements the interface in job/Interface -func (wj *WebhookJob) Validate(params job.Parameters) error { +func (wj *WebhookJob) Validate(_ job.Parameters) error { return nil } @@ -84,7 +84,7 @@ func (wj *WebhookJob) init(ctx job.Context, params map[string]interface{}) error } // execute webhook job -func (wj *WebhookJob) execute(ctx job.Context, params map[string]interface{}) error { +func (wj *WebhookJob) execute(_ job.Context, params map[string]interface{}) error { payload := params["payload"].(string) address := params["address"].(string) diff --git a/src/jobservice/job/impl/purge/purge.go b/src/jobservice/job/impl/purge/purge.go index 4dc27642d..9d54d28b7 100644 --- a/src/jobservice/job/impl/purge/purge.go +++ b/src/jobservice/job/impl/purge/purge.go @@ -47,7 +47,7 @@ func (j *Job) ShouldRetry() bool { } // Validate is implementation of same method in Interface. -func (j *Job) Validate(params job.Parameters) error { +func (j *Job) Validate(_ job.Parameters) error { return nil } diff --git a/src/jobservice/job/impl/replication/replication.go b/src/jobservice/job/impl/replication/replication.go index 36b533dd3..740ea3797 100644 --- a/src/jobservice/job/impl/replication/replication.go +++ b/src/jobservice/job/impl/replication/replication.go @@ -73,7 +73,7 @@ func (r *Replication) ShouldRetry() bool { } // Validate does nothing -func (r *Replication) Validate(params job.Parameters) error { +func (r *Replication) Validate(_ job.Parameters) error { return nil } diff --git a/src/jobservice/job/impl/scandataexport/scan_data_export.go b/src/jobservice/job/impl/scandataexport/scan_data_export.go index 14c39cc47..b21e4a389 100644 --- a/src/jobservice/job/impl/scandataexport/scan_data_export.go +++ b/src/jobservice/job/impl/scandataexport/scan_data_export.go @@ -57,7 +57,7 @@ func (sde *ScanDataExport) ShouldRetry() bool { // Validate Indicate whether the parameters of job are valid. // Return: // error if parameters are not valid. NOTES: If no parameters needed, directly return nil. -func (sde *ScanDataExport) Validate(params job.Parameters) error { +func (sde *ScanDataExport) Validate(_ job.Parameters) error { return nil } @@ -190,24 +190,24 @@ func (sde *ScanDataExport) writeCsvFile(ctx job.Context, params job.Parameters, return err } - projectIds := filterCriteria.Projects - if len(projectIds) == 0 { + projectIDs := filterCriteria.Projects + if len(projectIDs) == 0 { return nil } // extract the repository ids if any repositories have been specified - repoIds, err := sde.filterProcessor.ProcessRepositoryFilter(systemContext, filterCriteria.Repositories, projectIds) + repoIDs, err := sde.filterProcessor.ProcessRepositoryFilter(systemContext, filterCriteria.Repositories, projectIDs) if err != nil { return err } - if len(repoIds) == 0 { + if len(repoIDs) == 0 { logger.Infof("No repositories found with specified names: %v", filterCriteria.Repositories) return nil } // filter artifacts by tags - arts, err := sde.filterProcessor.ProcessTagFilter(systemContext, filterCriteria.Tags, repoIds) + arts, err := sde.filterProcessor.ProcessTagFilter(systemContext, filterCriteria.Tags, repoIDs) if err != nil { return err } diff --git a/src/jobservice/job/impl/systemartifact/cleanup.go b/src/jobservice/job/impl/systemartifact/cleanup.go index 1ea7f366d..64b839ab5 100644 --- a/src/jobservice/job/impl/systemartifact/cleanup.go +++ b/src/jobservice/job/impl/systemartifact/cleanup.go @@ -21,11 +21,11 @@ func (c *Cleanup) ShouldRetry() bool { return true } -func (c *Cleanup) Validate(params job.Parameters) error { +func (c *Cleanup) Validate(_ job.Parameters) error { return nil } -func (c *Cleanup) Run(ctx job.Context, params job.Parameters) error { +func (c *Cleanup) Run(ctx job.Context, _ job.Parameters) error { logger := ctx.GetLogger() logger.Infof("Running system data artifact cleanup job...") c.init() diff --git a/src/jobservice/logger/getter_factory.go b/src/jobservice/logger/getter_factory.go index 238b2f479..c17d52055 100644 --- a/src/jobservice/logger/getter_factory.go +++ b/src/jobservice/logger/getter_factory.go @@ -27,6 +27,6 @@ func FileGetterFactory(options ...OptionItem) (getter.Interface, error) { } // DBGetterFactory creates a getter for the DB logger -func DBGetterFactory(options ...OptionItem) (getter.Interface, error) { +func DBGetterFactory(_ ...OptionItem) (getter.Interface, error) { return getter.NewDBGetter(), nil } diff --git a/src/jobservice/runner/redis.go b/src/jobservice/runner/redis.go index a878ae81a..0c0b76c08 100644 --- a/src/jobservice/runner/redis.go +++ b/src/jobservice/runner/redis.go @@ -95,11 +95,10 @@ func (rj *RedisJob) Run(j *work.Job) (err error) { <-time.After(time.Duration(b) * time.Millisecond) span.AddEvent("retrying to get job stat") continue - } else { - // Exit and never try. - // Directly return without retry again as we have no way to restore the stats again. - j.Fails = 10000000000 // never retry } + // Exit and never try. + // Directly return without retry again as we have no way to restore the stats again. + j.Fails = 10000000000 // never retry } // Log error and exit diff --git a/src/jobservice/runtime/bootstrap.go b/src/jobservice/runtime/bootstrap.go index aad3837bb..2cc1ad687 100644 --- a/src/jobservice/runtime/bootstrap.go +++ b/src/jobservice/runtime/bootstrap.go @@ -344,15 +344,15 @@ func (bs *Bootstrap) loadAndRunRedisWorkerPool( // Get a redis connection pool func (bs *Bootstrap) getRedisPool(redisPoolConfig *config.RedisPoolConfig) *redis.Pool { - if pool, err := redislib.GetRedisPool("JobService", redisPoolConfig.RedisURL, &redislib.PoolParam{ + pool, err := redislib.GetRedisPool("JobService", redisPoolConfig.RedisURL, &redislib.PoolParam{ PoolMaxIdle: 6, PoolIdleTimeout: time.Duration(redisPoolConfig.IdleTimeoutSecond) * time.Second, DialConnectionTimeout: dialConnectionTimeout, DialReadTimeout: dialReadTimeout, DialWriteTimeout: dialWriteTimeout, - }); err != nil { + }) + if err != nil { panic(err) - } else { - return pool } + return pool } diff --git a/src/jobservice/worker/cworker/c_worker.go b/src/jobservice/worker/cworker/c_worker.go index 2d2043162..130cd099e 100644 --- a/src/jobservice/worker/cworker/c_worker.go +++ b/src/jobservice/worker/cworker/c_worker.go @@ -154,7 +154,7 @@ func (w *basicWorker) Start() error { logger.Infof("Basic worker is started") // Start the reaper - w.knownJobs.Range(func(k interface{}, v interface{}) bool { + w.knownJobs.Range(func(k interface{}, _ interface{}) bool { w.reaper.jobTypes = append(w.reaper.jobTypes, k.(string)) return true @@ -251,7 +251,7 @@ func (w *basicWorker) Schedule(jobName string, params job.Parameters, runAfterSe } // PeriodicallyEnqueue job -func (w *basicWorker) PeriodicallyEnqueue(jobName string, params job.Parameters, cronSetting string, isUnique bool, webHook string) (*job.Stats, error) { +func (w *basicWorker) PeriodicallyEnqueue(jobName string, params job.Parameters, cronSetting string, _ bool, webHook string) (*job.Stats, error) { p := &period.Policy{ ID: utils.MakeIdentifier(), JobName: jobName, @@ -369,7 +369,7 @@ func (w *basicWorker) StopJob(jobID string) error { } // RetryJob retry the job -func (w *basicWorker) RetryJob(jobID string) error { +func (w *basicWorker) RetryJob(_ string) error { return errors.New("not implemented") } diff --git a/src/jobservice/worker/cworker/reaper.go b/src/jobservice/worker/cworker/reaper.go index 8bf2b165d..601a9e6d0 100644 --- a/src/jobservice/worker/cworker/reaper.go +++ b/src/jobservice/worker/cworker/reaper.go @@ -136,7 +136,7 @@ func (r *reaper) syncOutdatedStats() error { // Loop all the in progress jobs to check if they're really in progress or // status is hung. - h := func(k string, v int64) (err error) { + h := func(k string, _ int64) (err error) { defer func() { if errs.IsObjectNotFoundError(err) { // As the job stats is lost and we don't have chance to restore it, then directly discard it. diff --git a/src/lib/cache/memory/memory.go b/src/lib/cache/memory/memory.go index e80757259..6af6d9f06 100644 --- a/src/lib/cache/memory/memory.go +++ b/src/lib/cache/memory/memory.go @@ -60,7 +60,7 @@ func (c *Cache) Contains(ctx context.Context, key string) bool { } // Delete delete item from cache by key -func (c *Cache) Delete(ctx context.Context, key string) error { +func (c *Cache) Delete(_ context.Context, key string) error { c.storage.Delete(c.opts.Key(key)) return nil } @@ -89,12 +89,12 @@ func (c *Cache) Fetch(ctx context.Context, key string, value interface{}) error } // Ping ping the cache -func (c *Cache) Ping(ctx context.Context) error { +func (c *Cache) Ping(_ context.Context) error { return nil } // Save cache the value by key -func (c *Cache) Save(ctx context.Context, key string, value interface{}, expiration ...time.Duration) error { +func (c *Cache) Save(_ context.Context, key string, value interface{}, expiration ...time.Duration) error { data, err := c.opts.Codec.Encode(value) if err != nil { return fmt.Errorf("failed to encode value, key %s, error: %v", key, err) @@ -118,7 +118,7 @@ func (c *Cache) Save(ctx context.Context, key string, value interface{}, expirat } // Scan scans the keys matched by match string -func (c *Cache) Scan(ctx context.Context, match string) (cache.Iterator, error) { +func (c *Cache) Scan(_ context.Context, match string) (cache.Iterator, error) { var keys []string c.storage.Range(func(k, v interface{}) bool { matched := true @@ -147,7 +147,7 @@ type ScanIterator struct { } // Next checks whether has the next element -func (i *ScanIterator) Next(ctx context.Context) bool { +func (i *ScanIterator) Next(_ context.Context) bool { i.mu.Lock() defer i.mu.Unlock() diff --git a/src/lib/config/config.go b/src/lib/config/config.go index 55446b634..205aefff3 100644 --- a/src/lib/config/config.go +++ b/src/lib/config/config.go @@ -112,7 +112,7 @@ func InitWithSettings(cfgs map[string]interface{}, kp ...encrypt.KeyProvider) { } // GetCfgManager return the current config manager -func GetCfgManager(ctx context.Context) Manager { +func GetCfgManager(_ context.Context) Manager { return DefaultMgr() } diff --git a/src/lib/config/metadata/type.go b/src/lib/config/metadata/type.go index 48ca46347..1bb6ea28b 100644 --- a/src/lib/config/metadata/type.go +++ b/src/lib/config/metadata/type.go @@ -38,7 +38,7 @@ type Type interface { type StringType struct { } -func (t *StringType) validate(str string) error { +func (t *StringType) validate(_ string) error { return nil } @@ -177,7 +177,7 @@ func (t *BoolType) get(str string) (interface{}, error) { type PasswordType struct { } -func (t *PasswordType) validate(str string) error { +func (t *PasswordType) validate(_ string) error { return nil } diff --git a/src/lib/encrypt/keyprovider.go b/src/lib/encrypt/keyprovider.go index 4fe4efaff..f25019e03 100644 --- a/src/lib/encrypt/keyprovider.go +++ b/src/lib/encrypt/keyprovider.go @@ -37,7 +37,7 @@ func NewFileKeyProvider(path string) KeyProvider { } // Get returns the key read from file -func (f *FileKeyProvider) Get(params map[string]interface{}) (string, error) { +func (f *FileKeyProvider) Get(_ map[string]interface{}) (string, error) { b, err := os.ReadFile(f.path) if err != nil { return "", err @@ -51,6 +51,6 @@ type PresetKeyProvider struct { } // Get ... -func (p *PresetKeyProvider) Get(params map[string]interface{}) (string, error) { +func (p *PresetKeyProvider) Get(_ map[string]interface{}) (string, error) { return p.Key, nil } diff --git a/src/lib/orm/query.go b/src/lib/orm/query.go index 6a2233d9c..0e193886a 100644 --- a/src/lib/orm/query.go +++ b/src/lib/orm/query.go @@ -116,7 +116,7 @@ func PaginationOnRawSQL(query *q.Query, sql string, params []interface{}) (strin } // QuerySetterForCount creates the query setter used for count with the sort and pagination information ignored -func QuerySetterForCount(ctx context.Context, model interface{}, query *q.Query, ignoredCols ...string) (orm.QuerySeter, error) { +func QuerySetterForCount(ctx context.Context, model interface{}, query *q.Query, _ ...string) (orm.QuerySeter, error) { query = q.MustClone(query) query.Sorts = nil query.PageSize = 0 diff --git a/src/lib/redis/redisclient.go b/src/lib/redis/redisclient.go index 0b809dbfa..eaea20478 100644 --- a/src/lib/redis/redisclient.go +++ b/src/lib/redis/redisclient.go @@ -70,7 +70,7 @@ func GetRedisPool(name string, rawurl string, param *PoolParam) (*redis.Pool, er Dial: func() (redis.Conn, error) { return redis.DialURL(rawurl) }, - TestOnBorrow: func(c redis.Conn, t time.Time) error { + TestOnBorrow: func(c redis.Conn, _ time.Time) error { _, err := c.Do("PING") return err }, @@ -88,9 +88,8 @@ func GetRedisPool(name string, rawurl string, param *PoolParam) (*redis.Pool, er } knownPool.Store(name, pool) return pool, nil - } else { - return nil, fmt.Errorf("bad redis url: not support scheme %s", u.Scheme) } + return nil, fmt.Errorf("bad redis url: not support scheme %s", u.Scheme) } func getSentinelPool(u *url.URL, param *PoolParam, name string) (*redis.Pool, error) { @@ -158,7 +157,7 @@ func getSentinelPool(u *url.URL, param *PoolParam, name string) (*redis.Pool, er log.Debug(name, "dial redis master:", masterAddr, "db:", db) return redis.Dial("tcp", masterAddr, redisOptions...) }, - TestOnBorrow: func(c redis.Conn, t time.Time) error { + TestOnBorrow: func(c redis.Conn, _ time.Time) error { if !sentinel.TestRole(c, "master") { return fmt.Errorf("check role failed, %s", name) } diff --git a/src/lib/selector/selectors/index/index.go b/src/lib/selector/selectors/index/index.go index 8d308ae5a..5e7864624 100644 --- a/src/lib/selector/selectors/index/index.go +++ b/src/lib/selector/selectors/index/index.go @@ -94,7 +94,7 @@ func Get(kind, decoration, pattern, extras string) (selector.Selector, error) { func Index() []*IndexedMeta { all := make([]*IndexedMeta, 0) - index.Range(func(k, v interface{}) bool { + index.Range(func(_, v interface{}) bool { if item, ok := v.(*indexedItem); ok { all = append(all, item.Meta) return true diff --git a/src/lib/selector/selectors/label/selector.go b/src/lib/selector/selectors/label/selector.go index a95c0754b..fcea7df7f 100644 --- a/src/lib/selector/selectors/label/selector.go +++ b/src/lib/selector/selectors/label/selector.go @@ -50,7 +50,7 @@ func (s *selector) Select(artifacts []*iselector.Candidate) (selected []*iselect } // New is factory method for label selector -func New(decoration string, pattern interface{}, extras string) iselector.Selector { +func New(decoration string, pattern interface{}, _ string) iselector.Selector { labels := make([]string, 0) if pattern != nil { diff --git a/src/lib/selector/selectors/severity/selector.go b/src/lib/selector/selectors/severity/selector.go index 60c6cd096..8a81acf1f 100644 --- a/src/lib/selector/selectors/severity/selector.go +++ b/src/lib/selector/selectors/severity/selector.go @@ -82,7 +82,7 @@ func (s *selector) Select(artifacts []*sl.Candidate) (selected []*sl.Candidate, } // New is factory method for vulnerability severity selector -func New(decoration string, pattern interface{}, extras string) sl.Selector { +func New(decoration string, pattern interface{}, _ string) sl.Selector { var sev int if pattern != nil { sev, _ = pattern.(int) diff --git a/src/lib/selector/selectors/signature/selector.go b/src/lib/selector/selectors/signature/selector.go index cb4a1a166..27c3b3fb4 100644 --- a/src/lib/selector/selectors/signature/selector.go +++ b/src/lib/selector/selectors/signature/selector.go @@ -64,7 +64,7 @@ func (s *selector) Select(artifacts []*sl.Candidate) (selected []*sl.Candidate, } // New is factory method for signature selector -func New(decoration string, pattern interface{}, extras string) sl.Selector { +func New(decoration string, pattern interface{}, _ string) sl.Selector { var e bool if pattern != nil { e, _ = pattern.(bool) diff --git a/src/pkg/audit/forward.go b/src/pkg/audit/forward.go index b2b8f6130..1feb4855b 100644 --- a/src/pkg/audit/forward.go +++ b/src/pkg/audit/forward.go @@ -35,7 +35,7 @@ type LoggerManager struct { } // Init redirect the audit log to the forward endpoint -func (a *LoggerManager) Init(ctx context.Context, logEndpoint string) { +func (a *LoggerManager) Init(_ context.Context, logEndpoint string) { var w io.Writer w, err := syslog.Dial("tcp", logEndpoint, syslog.LOG_INFO, "audit") diff --git a/src/pkg/blob/models/blob.go b/src/pkg/blob/models/blob.go index 24c55f2d2..541b5eed5 100644 --- a/src/pkg/blob/models/blob.go +++ b/src/pkg/blob/models/blob.go @@ -123,7 +123,7 @@ func (b *Blob) IsManifest() bool { } // FilterByArtifactDigest returns orm.QuerySeter with artifact digest filter -func (b *Blob) FilterByArtifactDigest(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (b *Blob) FilterByArtifactDigest(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { v, ok := value.(string) if !ok { return qs @@ -133,7 +133,7 @@ func (b *Blob) FilterByArtifactDigest(ctx context.Context, qs orm.QuerySeter, ke } // FilterByArtifactDigests returns orm.QuerySeter with artifact digests filter -func (b *Blob) FilterByArtifactDigests(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (b *Blob) FilterByArtifactDigests(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { artifactDigests, ok := value.([]string) if !ok { return qs @@ -148,7 +148,7 @@ func (b *Blob) FilterByArtifactDigests(ctx context.Context, qs orm.QuerySeter, k } // FilterByProjectID returns orm.QuerySeter with project id filter -func (b *Blob) FilterByProjectID(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (b *Blob) FilterByProjectID(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { projectID, ok := value.(int64) if !ok { return qs diff --git a/src/pkg/cached/base_manager.go b/src/pkg/cached/base_manager.go index d7bf1cadd..e98c11dbd 100644 --- a/src/pkg/cached/base_manager.go +++ b/src/pkg/cached/base_manager.go @@ -87,12 +87,12 @@ func (bm *BaseManager) WithCacheClient(cc cache.Cache) *BaseManager { } // CacheClient returns the cache client. -func (bm *BaseManager) CacheClient(ctx context.Context) cache.Cache { +func (bm *BaseManager) CacheClient(_ context.Context) cache.Cache { return bm.cacheClient } // ResourceType returns the resource type. -func (bm *BaseManager) ResourceType(ctx context.Context) string { +func (bm *BaseManager) ResourceType(_ context.Context) string { return bm.resourceType } diff --git a/src/pkg/config/inmemory/manager.go b/src/pkg/config/inmemory/manager.go index ad35e3e04..69383e300 100644 --- a/src/pkg/config/inmemory/manager.go +++ b/src/pkg/config/inmemory/manager.go @@ -48,7 +48,7 @@ func (d *Driver) Load(context.Context) (map[string]interface{}, error) { } // Save only save user config setting to driver, for example: database, REST -func (d *Driver) Save(ctx context.Context, cfg map[string]interface{}) error { +func (d *Driver) Save(_ context.Context, cfg map[string]interface{}) error { d.Lock() defer d.Unlock() for k, v := range cfg { diff --git a/src/pkg/config/manager.go b/src/pkg/config/manager.go index c853dd5b3..a26acd170 100644 --- a/src/pkg/config/manager.go +++ b/src/pkg/config/manager.go @@ -134,7 +134,7 @@ func (c *CfgManager) Save(ctx context.Context) error { } // Get ... -func (c *CfgManager) Get(ctx context.Context, key string) *metadata.ConfigureValue { +func (c *CfgManager) Get(_ context.Context, key string) *metadata.ConfigureValue { configValue, err := c.Store.Get(key) if err != nil { log.Debugf("failed to get key %v, error: %v, maybe default value not defined before get", key, err) @@ -144,7 +144,7 @@ func (c *CfgManager) Get(ctx context.Context, key string) *metadata.ConfigureVal } // Set ... -func (c *CfgManager) Set(ctx context.Context, key string, value interface{}) { +func (c *CfgManager) Set(_ context.Context, key string, value interface{}) { configValue, err := metadata.NewCfgValue(key, utils.GetStrValueOfAnyType(value)) if err != nil { log.Errorf("error when setting key: %v, error %v", key, err) diff --git a/src/pkg/config/rest/rest.go b/src/pkg/config/rest/rest.go index 6c709c3e5..2cb09f981 100644 --- a/src/pkg/config/rest/rest.go +++ b/src/pkg/config/rest/rest.go @@ -41,7 +41,7 @@ type Value struct { } // Load - load config data from REST server -func (h *Driver) Load(ctx context.Context) (map[string]interface{}, error) { +func (h *Driver) Load(_ context.Context) (map[string]interface{}, error) { cfgMap := map[string]interface{}{} origMap := map[string]*Value{} log.Infof("get configuration from url: %+v", h.configRESTURL) @@ -59,6 +59,6 @@ func (h *Driver) Load(ctx context.Context) (map[string]interface{}, error) { } // Save - Save config data to REST server by PUT method -func (h *Driver) Save(ctx context.Context, cfg map[string]interface{}) error { +func (h *Driver) Save(_ context.Context, cfg map[string]interface{}) error { return h.client.Put(h.configRESTURL, cfg) } diff --git a/src/pkg/exporter/exporter.go b/src/pkg/exporter/exporter.go index 12771d083..0fb153e11 100644 --- a/src/pkg/exporter/exporter.go +++ b/src/pkg/exporter/exporter.go @@ -68,10 +68,10 @@ func (e *Exporter) RegisterCollector(collectors ...collector) error { return nil } -func newServer(opt *Opt, r *prometheus.Registry) *http.Server { +func newServer(opt *Opt, _ *prometheus.Registry) *http.Server { exporterMux := http.NewServeMux() exporterMux.Handle(opt.MetricsPath, promhttp.Handler()) - exporterMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + exporterMux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(` Harbor Exporter diff --git a/src/pkg/factory.go b/src/pkg/factory.go index c29b6e64e..7f2303db7 100644 --- a/src/pkg/factory.go +++ b/src/pkg/factory.go @@ -94,6 +94,6 @@ func initRepositoryMgr(cacheEnabled bool) { } } -func initManifestManager(cacheEnabled bool) { +func initManifestManager(_ bool) { ManifestMgr = cachedManifest.NewManager() } diff --git a/src/pkg/jobmonitor/pool.go b/src/pkg/jobmonitor/pool.go index c13096180..26468e28f 100644 --- a/src/pkg/jobmonitor/pool.go +++ b/src/pkg/jobmonitor/pool.go @@ -45,7 +45,7 @@ func NewPoolManager() PoolManager { return &poolManager{} } -func (p poolManager) List(ctx context.Context, monitorClient JobServiceMonitorClient) ([]*WorkerPool, error) { +func (p poolManager) List(_ context.Context, monitorClient JobServiceMonitorClient) ([]*WorkerPool, error) { workerPool := make([]*WorkerPool, 0) wh, err := monitorClient.WorkerPoolHeartbeats() if err != nil { diff --git a/src/pkg/jobmonitor/queue.go b/src/pkg/jobmonitor/queue.go index 806ebe57a..626944832 100644 --- a/src/pkg/jobmonitor/queue.go +++ b/src/pkg/jobmonitor/queue.go @@ -30,7 +30,7 @@ func NewQueueClient() QueueManager { return &queueManagerImpl{} } -func (w *queueManagerImpl) List(ctx context.Context, monitClient JobServiceMonitorClient) ([]*Queue, error) { +func (w *queueManagerImpl) List(_ context.Context, monitClient JobServiceMonitorClient) ([]*Queue, error) { resultQueues := make([]*Queue, 0) queues, err := monitClient.Queues() if err != nil { diff --git a/src/pkg/jobmonitor/redis.go b/src/pkg/jobmonitor/redis.go index 212fa8d19..5810e7ecc 100644 --- a/src/pkg/jobmonitor/redis.go +++ b/src/pkg/jobmonitor/redis.go @@ -108,7 +108,7 @@ func (r *redisClientImpl) StopPendingJobs(ctx context.Context, jobType string) ( } // removeJobStatusInRedis remove job status track information from redis, to avoid performance impact when the jobIDs is too large, use batch to remove -func (r *redisClientImpl) removeJobStatusInRedis(ctx context.Context, jobIDs []string) { +func (r *redisClientImpl) removeJobStatusInRedis(_ context.Context, jobIDs []string) { conn := r.redisPool.Get() defer conn.Close() for _, id := range jobIDs { @@ -128,13 +128,13 @@ func (r *redisClientImpl) removeJobStatusInRedis(ctx context.Context, jobIDs []s } } -func (r *redisClientImpl) AllJobTypes(ctx context.Context) ([]string, error) { +func (r *redisClientImpl) AllJobTypes(_ context.Context) ([]string, error) { conn := r.redisPool.Get() defer conn.Close() return redis.Strings(conn.Do("SMEMBERS", fmt.Sprintf("{%s}:known_jobs", r.namespace))) } -func (r *redisClientImpl) PauseJob(ctx context.Context, jobName string) error { +func (r *redisClientImpl) PauseJob(_ context.Context, jobName string) error { log.Infof("pause job type:%s", jobName) redisKeyJobPaused := fmt.Sprintf("{%s}:jobs:%s:paused", r.namespace, jobName) conn := r.redisPool.Get() @@ -143,7 +143,7 @@ func (r *redisClientImpl) PauseJob(ctx context.Context, jobName string) error { return err } -func (r *redisClientImpl) UnpauseJob(ctx context.Context, jobName string) error { +func (r *redisClientImpl) UnpauseJob(_ context.Context, jobName string) error { log.Infof("unpause job %s", jobName) redisKeyJobPaused := fmt.Sprintf("{%s}:jobs:%s:paused", r.namespace, jobName) conn := r.redisPool.Get() diff --git a/src/pkg/jobmonitor/worker.go b/src/pkg/jobmonitor/worker.go index debd4fab8..44d6a1155 100644 --- a/src/pkg/jobmonitor/worker.go +++ b/src/pkg/jobmonitor/worker.go @@ -40,7 +40,7 @@ func NewWorkerManager() WorkerManager { return &workerManagerImpl{taskMgr: task.NewManager()} } -func (w *workerManagerImpl) List(ctx context.Context, monitClient JobServiceMonitorClient, poolID string) ([]*Worker, error) { +func (w *workerManagerImpl) List(_ context.Context, monitClient JobServiceMonitorClient, poolID string) ([]*Worker, error) { wphs, err := monitClient.WorkerPoolHeartbeats() if err != nil { return nil, err diff --git a/src/pkg/ldap/manager.go b/src/pkg/ldap/manager.go index 8692ad97f..d2d2d6cbd 100644 --- a/src/pkg/ldap/manager.go +++ b/src/pkg/ldap/manager.go @@ -35,11 +35,11 @@ func New() Manager { type manager struct { } -func (m *manager) Ping(ctx context.Context, cfg cfgModels.LdapConf) (bool, error) { +func (m *manager) Ping(_ context.Context, cfg cfgModels.LdapConf) (bool, error) { return TestConfig(cfg) } -func (m *manager) SearchUser(ctx context.Context, sess *Session, username string) ([]model.User, error) { +func (m *manager) SearchUser(_ context.Context, sess *Session, username string) ([]model.User, error) { users := make([]model.User, 0) if err := sess.Open(); err != nil { return users, err @@ -119,7 +119,7 @@ func (m *manager) ImportUser(ctx context.Context, sess *Session, ldapImportUsers return failedImportUser, nil } -func (m *manager) SearchGroup(ctx context.Context, sess *Session, groupName, groupDN string) ([]model.Group, error) { +func (m *manager) SearchGroup(_ context.Context, sess *Session, groupName, groupDN string) ([]model.Group, error) { err := sess.Open() if err != nil { return nil, err diff --git a/src/pkg/member/dao/dao.go b/src/pkg/member/dao/dao.go index c06196d72..15e46f06a 100644 --- a/src/pkg/member/dao/dao.go +++ b/src/pkg/member/dao/dao.go @@ -109,7 +109,7 @@ func (d *dao) GetProjectMember(ctx context.Context, queryMember models.Member, q return members, err } -func (d *dao) GetTotalOfProjectMembers(ctx context.Context, projectID int64, query *q.Query, roles ...int) (int, error) { +func (d *dao) GetTotalOfProjectMembers(ctx context.Context, projectID int64, _ *q.Query, roles ...int) (int, error) { log.Debugf("Query condition %+v", projectID) if projectID == 0 { return 0, fmt.Errorf("failed to get total of project members, project id required %v", projectID) diff --git a/src/pkg/notifier/event/event.go b/src/pkg/notifier/event/event.go index 292ffadd6..e81af0ad6 100644 --- a/src/pkg/notifier/event/event.go +++ b/src/pkg/notifier/event/event.go @@ -63,7 +63,7 @@ func (h *HookMetaData) Resolve(evt *Event) error { } // Build an event by metadata -func (e *Event) Build(ctx context.Context, metadata ...Metadata) error { +func (e *Event) Build(_ context.Context, metadata ...Metadata) error { for _, md := range metadata { if err := md.Resolve(e); err != nil { log.Debugf("failed to resolve event metadata: %v", md) diff --git a/src/pkg/notifier/formats/default.go b/src/pkg/notifier/formats/default.go index 070e0bd26..f4a00abbc 100644 --- a/src/pkg/notifier/formats/default.go +++ b/src/pkg/notifier/formats/default.go @@ -66,7 +66,7 @@ type Default struct{} } } */ -func (d *Default) Format(ctx context.Context, he *model.HookEvent) (http.Header, []byte, error) { +func (d *Default) Format(_ context.Context, he *model.HookEvent) (http.Header, []byte, error) { if he == nil { return nil, nil, errors.Errorf("HookEvent should not be nil") } diff --git a/src/pkg/oidc/testutils.go b/src/pkg/oidc/testutils.go index 0bbc2a308..b34877e1f 100644 --- a/src/pkg/oidc/testutils.go +++ b/src/pkg/oidc/testutils.go @@ -12,7 +12,7 @@ type fakeVerifier struct { secret string } -func (fv *fakeVerifier) VerifySecret(ctx context.Context, name string, secret string) (*UserInfo, error) { +func (fv *fakeVerifier) VerifySecret(_ context.Context, name string, secret string) (*UserInfo, error) { if secret != fv.secret { return nil, verifyError(errors.New("mismatch")) } diff --git a/src/pkg/p2p/preheat/provider/auth/none_handler.go b/src/pkg/p2p/preheat/provider/auth/none_handler.go index efa76bbce..fdb6c951e 100644 --- a/src/pkg/p2p/preheat/provider/auth/none_handler.go +++ b/src/pkg/p2p/preheat/provider/auth/none_handler.go @@ -14,7 +14,7 @@ func (nah *NoneAuthHandler) Mode() string { } // Authorize implements @Handler.Authorize -func (nah *NoneAuthHandler) Authorize(req *http.Request, cred *Credential) error { +func (nah *NoneAuthHandler) Authorize(req *http.Request, _ *Credential) error { if req == nil { return errors.New("nil request cannot be authorized") } diff --git a/src/pkg/permission/evaluator/admin/admin.go b/src/pkg/permission/evaluator/admin/admin.go index 612d4e9cb..25431e0c6 100644 --- a/src/pkg/permission/evaluator/admin/admin.go +++ b/src/pkg/permission/evaluator/admin/admin.go @@ -31,7 +31,7 @@ type Evaluator struct { } // HasPermission always return true for the system administrator -func (e *Evaluator) HasPermission(ctx context.Context, resource types.Resource, action types.Action) bool { +func (e *Evaluator) HasPermission(_ context.Context, resource types.Resource, action types.Action) bool { log.Debugf("system administrator %s require %s action for resource %s", e.username, action, resource) // scanner-pull is for scanner to bypass the policy checking so admin user should not have this permission return action != rbac.ActionScannerPull diff --git a/src/pkg/permission/evaluator/rbac/casbin_adapter.go b/src/pkg/permission/evaluator/rbac/casbin_adapter.go index 1b5187d7f..d39cbf1ef 100644 --- a/src/pkg/permission/evaluator/rbac/casbin_adapter.go +++ b/src/pkg/permission/evaluator/rbac/casbin_adapter.go @@ -88,18 +88,18 @@ func (a *adapter) LoadPolicy(model model.Model) error { return nil } -func (a *adapter) SavePolicy(model model.Model) error { +func (a *adapter) SavePolicy(_ model.Model) error { return errNotImplemented } -func (a *adapter) AddPolicy(sec string, ptype string, rule []string) error { +func (a *adapter) AddPolicy(_ string, _ string, _ []string) error { return errNotImplemented } -func (a *adapter) RemovePolicy(sec string, ptype string, rule []string) error { +func (a *adapter) RemovePolicy(_ string, _ string, _ []string) error { return errNotImplemented } -func (a *adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error { +func (a *adapter) RemoveFilteredPolicy(_ string, _ string, _ int, _ ...string) error { return errNotImplemented } diff --git a/src/pkg/permission/evaluator/rbac/casbin_match.go b/src/pkg/permission/evaluator/rbac/casbin_match.go index afd0ddf25..543512b46 100644 --- a/src/pkg/permission/evaluator/rbac/casbin_match.go +++ b/src/pkg/permission/evaluator/rbac/casbin_match.go @@ -40,7 +40,7 @@ func (s *regexpStore) Get(key string, build func(string) *regexp.Regexp) *regexp func (s *regexpStore) Purge() { var keys []interface{} - s.entries.Range(func(key, value interface{}) bool { + s.entries.Range(func(key, _ interface{}) bool { keys = append(keys, key) return true }) diff --git a/src/pkg/permission/evaluator/rbac/rbac.go b/src/pkg/permission/evaluator/rbac/rbac.go index 77bb1f668..ec52cabd0 100644 --- a/src/pkg/permission/evaluator/rbac/rbac.go +++ b/src/pkg/permission/evaluator/rbac/rbac.go @@ -34,7 +34,7 @@ type Evaluator struct { } // HasPermission returns true when the rbac user has action permission for the resource -func (e *Evaluator) HasPermission(ctx context.Context, resource types.Resource, action types.Action) bool { +func (e *Evaluator) HasPermission(_ context.Context, resource types.Resource, action types.Action) bool { e.once.Do(func() { e.enforcer = makeEnforcer(e.rbacUser) }) diff --git a/src/pkg/project/models/project.go b/src/pkg/project/models/project.go index 712bc85eb..5a379468a 100644 --- a/src/pkg/project/models/project.go +++ b/src/pkg/project/models/project.go @@ -148,7 +148,7 @@ func (p *Project) AutoScan() bool { } // FilterByPublic returns orm.QuerySeter with public filter -func (p *Project) FilterByPublic(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (p *Project) FilterByPublic(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { subQuery := `SELECT project_id FROM project_metadata WHERE name = 'public' AND value = '%s'` if isTrue(value) { subQuery = fmt.Sprintf(subQuery, "true") @@ -159,7 +159,7 @@ func (p *Project) FilterByPublic(ctx context.Context, qs orm.QuerySeter, key str } // FilterByOwner returns orm.QuerySeter with owner filter -func (p *Project) FilterByOwner(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (p *Project) FilterByOwner(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { username, ok := value.(string) if !ok { return qs @@ -169,7 +169,7 @@ func (p *Project) FilterByOwner(ctx context.Context, qs orm.QuerySeter, key stri } // FilterByMember returns orm.QuerySeter with member filter -func (p *Project) FilterByMember(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (p *Project) FilterByMember(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { query, ok := value.(*MemberQuery) if !ok { return qs @@ -197,7 +197,7 @@ func (p *Project) FilterByMember(ctx context.Context, qs orm.QuerySeter, key str } // FilterByNames returns orm.QuerySeter with name filter -func (p *Project) FilterByNames(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (p *Project) FilterByNames(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { query, ok := value.(*NamesQuery) if !ok { return qs diff --git a/src/pkg/quota/types/resources.go b/src/pkg/quota/types/resources.go index 306bf9059..38d177c6f 100644 --- a/src/pkg/quota/types/resources.go +++ b/src/pkg/quota/types/resources.go @@ -46,7 +46,7 @@ func (resource ResourceName) FormatValue(value int64) string { type ResourceList map[ResourceName]int64 // Validate validates this resource list -func (resources ResourceList) Validate(formats strfmt.Registry) error { +func (resources ResourceList) Validate(_ strfmt.Registry) error { return nil } diff --git a/src/pkg/reg/adapter/aliacr/adapter.go b/src/pkg/reg/adapter/aliacr/adapter.go index 8e83440e4..f7525b961 100644 --- a/src/pkg/reg/adapter/aliacr/adapter.go +++ b/src/pkg/reg/adapter/aliacr/adapter.go @@ -325,7 +325,7 @@ func (a *adapter) FetchArtifacts(filters []*model.Filter) (resources []*model.Re return } -func (a *adapter) listReposByNamespace(region string, namespace string, c *cr.Client) (repos []aliRepo, err error) { +func (a *adapter) listReposByNamespace(_ string, namespace string, c *cr.Client) (repos []aliRepo, err error) { var reposReq = cr.CreateGetRepoListByNamespaceRequest() var reposResp = cr.CreateGetRepoListByNamespaceResponse() reposReq.SetDomain(a.domain) diff --git a/src/pkg/reg/adapter/githubcr/adapter.go b/src/pkg/reg/adapter/githubcr/adapter.go index 5d98085bc..f6809a993 100644 --- a/src/pkg/reg/adapter/githubcr/adapter.go +++ b/src/pkg/reg/adapter/githubcr/adapter.go @@ -193,6 +193,6 @@ func (a *adapter) listArtifacts(repository string, filters []*model.Filter) ([]* return filter.DoFilterArtifacts(artifacts, filters) } -func (a *adapter) DeleteManifest(repository, reference string) error { +func (a *adapter) DeleteManifest(_, _ string) error { return nil } diff --git a/src/pkg/reg/adapter/huawei/huawei_adapter.go b/src/pkg/reg/adapter/huawei/huawei_adapter.go index 9946c5089..f75710ea8 100644 --- a/src/pkg/reg/adapter/huawei/huawei_adapter.go +++ b/src/pkg/reg/adapter/huawei/huawei_adapter.go @@ -146,7 +146,7 @@ func (a *adapter) ListNamespaces(query *model.NamespaceQuery) ([]*model.Namespac } // ConvertResourceMetadata convert resource metadata for Huawei SWR -func (a *adapter) ConvertResourceMetadata(resourceMetadata *model.ResourceMetadata, namespace *model.Namespace) (*model.ResourceMetadata, error) { +func (a *adapter) ConvertResourceMetadata(resourceMetadata *model.ResourceMetadata, _ *model.Namespace) (*model.ResourceMetadata, error) { metadata := &model.ResourceMetadata{ Repository: resourceMetadata.Repository, Vtags: resourceMetadata.Vtags, diff --git a/src/pkg/reg/adapter/huawei/image_registry.go b/src/pkg/reg/adapter/huawei/image_registry.go index ccd9b5aa0..5f2663c49 100644 --- a/src/pkg/reg/adapter/huawei/image_registry.go +++ b/src/pkg/reg/adapter/huawei/image_registry.go @@ -28,7 +28,7 @@ import ( ) // FetchArtifacts gets resources from Huawei SWR -func (a *adapter) FetchArtifacts(filters []*model.Filter) ([]*model.Resource, error) { +func (a *adapter) FetchArtifacts(_ []*model.Filter) ([]*model.Resource, error) { resources := []*model.Resource{} urls := fmt.Sprintf("%s/dockyard/v2/repositories?filter=center::self", a.registry.URL) @@ -111,9 +111,9 @@ func (a *adapter) ManifestExist(repository, reference string) (exist bool, desc } contentType := resp.Header.Get("Content-Type") contentLen := resp.Header.Get("Content-Length") - len, _ := strconv.Atoi(contentLen) + contentLenInt, _ := strconv.Atoi(contentLen) - return exist, &distribution.Descriptor{MediaType: contentType, Size: int64(len)}, nil + return exist, &distribution.Descriptor{MediaType: contentType, Size: int64(contentLenInt)}, nil } // DeleteManifest delete the manifest of Huawei SWR diff --git a/src/pkg/reg/adapter/jfrog/adapter.go b/src/pkg/reg/adapter/jfrog/adapter.go index 7a91a07c9..bcdb1735e 100644 --- a/src/pkg/reg/adapter/jfrog/adapter.go +++ b/src/pkg/reg/adapter/jfrog/adapter.go @@ -342,7 +342,7 @@ func (a *adapter) preparePushBlob(repository string) (string, error) { return "", err } -func (a *adapter) ackPushBlob(repository, digest, location, size string) error { +func (a *adapter) ackPushBlob(repository, digest, location, _ string) error { url := fmt.Sprintf("%s/v2/%s/blobs/uploads/%s?digest=%s", a.registry.URL, repository, location, digest) req, err := http.NewRequest(http.MethodPut, url, nil) if err != nil { diff --git a/src/pkg/reg/adapter/native/adapter.go b/src/pkg/reg/adapter/native/adapter.go index b7cdbf675..8ecd0374e 100644 --- a/src/pkg/reg/adapter/native/adapter.go +++ b/src/pkg/reg/adapter/native/adapter.go @@ -240,11 +240,11 @@ func (a *Adapter) PingSimple() error { } // DeleteTag isn't supported for docker registry -func (a *Adapter) DeleteTag(repository, tag string) error { +func (a *Adapter) DeleteTag(_, _ string) error { return errors.New("the tag deletion isn't supported") } // CanBeMount isn't supported for docker registry -func (a *Adapter) CanBeMount(digest string) (mount bool, repository string, err error) { +func (a *Adapter) CanBeMount(_ string) (mount bool, repository string, err error) { return false, "", nil } diff --git a/src/pkg/reg/manager.go b/src/pkg/reg/manager.go index 7d74408e5..251aec47b 100644 --- a/src/pkg/reg/manager.go +++ b/src/pkg/reg/manager.go @@ -144,7 +144,7 @@ func (m *manager) Delete(ctx context.Context, id int64) error { return m.dao.Delete(ctx, id) } -func (m *manager) CreateAdapter(ctx context.Context, registry *model.Registry) (adapter.Adapter, error) { +func (m *manager) CreateAdapter(_ context.Context, registry *model.Registry) (adapter.Adapter, error) { factory, err := adapter.GetFactory(registry.Type) if err != nil { return nil, err @@ -152,11 +152,11 @@ func (m *manager) CreateAdapter(ctx context.Context, registry *model.Registry) ( return factory.Create(registry) } -func (m *manager) ListRegistryProviderTypes(ctx context.Context) ([]string, error) { +func (m *manager) ListRegistryProviderTypes(_ context.Context) ([]string, error) { return adapter.ListRegisteredAdapterTypes(), nil } -func (m *manager) ListRegistryProviderInfos(ctx context.Context) (infos map[string]*model.AdapterPattern, err error) { +func (m *manager) ListRegistryProviderInfos(_ context.Context) (infos map[string]*model.AdapterPattern, err error) { return adapter.ListRegisteredAdapterInfos(), nil } diff --git a/src/pkg/registry/auth/null/authorizer.go b/src/pkg/registry/auth/null/authorizer.go index 2ec70c595..dcfa79a59 100644 --- a/src/pkg/registry/auth/null/authorizer.go +++ b/src/pkg/registry/auth/null/authorizer.go @@ -27,7 +27,7 @@ func NewAuthorizer() lib.Authorizer { type authorizer struct{} -func (a *authorizer) Modify(req *http.Request) error { +func (a *authorizer) Modify(_ *http.Request) error { // do nothing return nil } diff --git a/src/pkg/registry/client.go b/src/pkg/registry/client.go index 3c0b86ed8..cb6358baa 100644 --- a/src/pkg/registry/client.go +++ b/src/pkg/registry/client.go @@ -281,8 +281,8 @@ func (c *client) ManifestExist(repository, reference string) (bool, *distributio dig := resp.Header.Get("Docker-Content-Digest") contentType := resp.Header.Get("Content-Type") contentLen := resp.Header.Get("Content-Length") - len, _ := strconv.Atoi(contentLen) - return true, &distribution.Descriptor{Digest: digest.Digest(dig), MediaType: contentType, Size: int64(len)}, nil + contentLenInt, _ := strconv.Atoi(contentLen) + return true, &distribution.Descriptor{Digest: digest.Digest(dig), MediaType: contentType, Size: int64(contentLenInt)}, nil } func (c *client) PullManifest(repository, reference string, acceptedMediaTypes ...string) ( @@ -399,7 +399,7 @@ func (c *client) PullBlob(repository, digest string) (int64, io.ReadCloser, erro } // PullBlobChunk pulls the specified blob, but by chunked, refer to https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pull for more details. -func (c *client) PullBlobChunk(repository, digest string, blobSize int64, start, end int64) (int64, io.ReadCloser, error) { +func (c *client) PullBlobChunk(repository, digest string, _ int64, start, end int64) (int64, io.ReadCloser, error) { req, err := http.NewRequest(http.MethodGet, buildBlobURL(c.url, repository, digest), nil) if err != nil { return 0, nil, err diff --git a/src/pkg/repository/model/model.go b/src/pkg/repository/model/model.go index 9ed3f7508..6b1a44a0c 100644 --- a/src/pkg/repository/model/model.go +++ b/src/pkg/repository/model/model.go @@ -42,7 +42,7 @@ type RepoRecord struct { } // FilterByBlobDigest filters the repositories by the blob digest -func (r *RepoRecord) FilterByBlobDigest(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (r *RepoRecord) FilterByBlobDigest(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { digest, ok := value.(string) if !ok || len(digest) == 0 { return qs diff --git a/src/pkg/retention/launcher.go b/src/pkg/retention/launcher.go index 9b1beb0bf..766b67568 100644 --- a/src/pkg/retention/launcher.go +++ b/src/pkg/retention/launcher.go @@ -278,7 +278,7 @@ func getProjects(ctx context.Context, projectMgr project.Manager) ([]*selector.C return candidates, nil } -func getRepositories(ctx context.Context, projectMgr project.Manager, repositoryMgr repository.Manager, projectID int64) ([]*selector.Candidate, error) { +func getRepositories(ctx context.Context, _ project.Manager, repositoryMgr repository.Manager, projectID int64) ([]*selector.Candidate, error) { var candidates []*selector.Candidate /* pro, err := projectMgr.Get(projectID) diff --git a/src/pkg/retention/policy/rule/index/index.go b/src/pkg/retention/policy/rule/index/index.go index 7fd148c9c..1555aedd6 100644 --- a/src/pkg/retention/policy/rule/index/index.go +++ b/src/pkg/retention/policy/rule/index/index.go @@ -253,7 +253,7 @@ func Get(templateID string, parameters rule.Parameters) (rule.Evaluator, error) func Index() []*Metadata { res := make([]*Metadata, 0) - index.Range(func(k, v interface{}) bool { + index.Range(func(_, v interface{}) bool { if item, ok := v.(*indexedItem); ok { res = append(res, item.Meta) return true diff --git a/src/pkg/retention/policy/rule/nothing/evaluator.go b/src/pkg/retention/policy/rule/nothing/evaluator.go index 574186324..e23d428c8 100644 --- a/src/pkg/retention/policy/rule/nothing/evaluator.go +++ b/src/pkg/retention/policy/rule/nothing/evaluator.go @@ -28,7 +28,7 @@ const ( type evaluator struct{} // Process for the "nothing" Evaluator simply returns the input with no error -func (e *evaluator) Process(artifacts []*selector.Candidate) (processed []*selector.Candidate, err error) { +func (e *evaluator) Process(_ []*selector.Candidate) (processed []*selector.Candidate, err error) { return processed, err } diff --git a/src/pkg/scan/dao/scan/vulnerability.go b/src/pkg/scan/dao/scan/vulnerability.go index da59cabe0..d920de81d 100644 --- a/src/pkg/scan/dao/scan/vulnerability.go +++ b/src/pkg/scan/dao/scan/vulnerability.go @@ -50,8 +50,8 @@ type VulnerabilityRecordDao interface { DeleteForReport(ctx context.Context, reportUUID string) (int64, error) // DeleteForDigests deletes vulnerability records for a provided list of digests DeleteForDigests(ctx context.Context, digests ...string) (int64, error) - // GetRecordIdsForScanner gets record ids of vulnerability records for a scanner - GetRecordIdsForScanner(ctx context.Context, registrationUUID string) ([]int, error) + // GetRecordIDsForScanner gets record ids of vulnerability records for a scanner + GetRecordIDsForScanner(ctx context.Context, registrationUUID string) ([]int, error) } // NewVulnerabilityRecordDao returns a new dao to handle vulnerability data @@ -230,17 +230,17 @@ func (v *vulnerabilityRecordDao) DeleteForDigests(ctx context.Context, digests . return numRowsDeleted, nil } -// GetRecordIdsForScanner retrieves the internal Ids of the vulnerability records for a given scanner +// GetRecordIDsForScanner retrieves the internal Ids of the vulnerability records for a given scanner // identified by registrationUUID -func (v *vulnerabilityRecordDao) GetRecordIdsForScanner(ctx context.Context, registrationUUID string) ([]int, error) { - vulnRecordIds := make([]int, 0) +func (v *vulnerabilityRecordDao) GetRecordIDsForScanner(ctx context.Context, registrationUUID string) ([]int, error) { + vulnRecordIDs := make([]int, 0) o, err := orm.FromContext(ctx) if err != nil { return nil, err } - _, err = o.Raw("select id from vulnerability_record where registration_uuid = ?", registrationUUID).QueryRows(&vulnRecordIds) + _, err = o.Raw("select id from vulnerability_record where registration_uuid = ?", registrationUUID).QueryRows(&vulnRecordIDs) if err != nil { - return vulnRecordIds, err + return vulnRecordIDs, err } - return vulnRecordIds, err + return vulnRecordIDs, err } diff --git a/src/pkg/scan/dao/scan/vulnerability_test.go b/src/pkg/scan/dao/scan/vulnerability_test.go index c78cdef2c..9b56ffd67 100644 --- a/src/pkg/scan/dao/scan/vulnerability_test.go +++ b/src/pkg/scan/dao/scan/vulnerability_test.go @@ -180,7 +180,7 @@ func (suite *VulnerabilityTestSuite) TestGetVulnerabilityRecordsForScanner() { // TestGetVulnerabilityRecordIdsForScanner gets vulnerability records for scanner func (suite *VulnerabilityTestSuite) TestGetVulnerabilityRecordIdsForScanner() { - vulns, err := suite.vulnerabilityRecordDao.GetRecordIdsForScanner(suite.Context(), "scannerId1") + vulns, err := suite.vulnerabilityRecordDao.GetRecordIDsForScanner(suite.Context(), "scannerId1") suite.NoError(err, "Error when fetching vulnerability records for report") suite.True(len(vulns) > 0) } diff --git a/src/pkg/scan/export/filter_processor.go b/src/pkg/scan/export/filter_processor.go index 26a99f2e7..b7400c031 100644 --- a/src/pkg/scan/export/filter_processor.go +++ b/src/pkg/scan/export/filter_processor.go @@ -16,8 +16,8 @@ import ( ) type FilterProcessor interface { - ProcessRepositoryFilter(ctx context.Context, filter string, projectIds []int64) ([]int64, error) - ProcessTagFilter(ctx context.Context, filter string, repositoryIds []int64) ([]*artifact.Artifact, error) + ProcessRepositoryFilter(ctx context.Context, filter string, projectIDs []int64) ([]int64, error) + ProcessTagFilter(ctx context.Context, filter string, repositoryIDs []int64) ([]*artifact.Artifact, error) ProcessLabelFilter(ctx context.Context, labelIDs []int64, arts []*artifact.Artifact) ([]*artifact.Artifact, error) } @@ -38,12 +38,12 @@ func NewFilterProcessor() FilterProcessor { } } -func (dfp *DefaultFilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter string, projectIds []int64) ([]int64, error) { +func (dfp *DefaultFilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter string, projectIDs []int64) ([]int64, error) { sel := doublestar.New(doublestar.RepoMatches, filter, "") candidates := make([]*selector.Candidate, 0) allRepoIDs := make([]int64, 0) - for _, projectID := range projectIds { + for _, projectID := range projectIDs { query := q.New(q.KeyWords{"ProjectID": projectID}) allRepos, err := dfp.repoMgr.List(ctx, query) if err != nil { @@ -73,7 +73,7 @@ func (dfp *DefaultFilterProcessor) ProcessRepositoryFilter(ctx context.Context, return repoIDs, nil } -func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter string, repositoryIds []int64) ([]*artifact.Artifact, error) { +func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter string, repositoryIDs []int64) ([]*artifact.Artifact, error) { arts := make([]*artifact.Artifact, 0) opts := &artifact.Option{ WithTag: true, @@ -82,7 +82,7 @@ func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter // WithAccessory: true } // list all artifacts by repository id - for _, repoID := range repositoryIds { + for _, repoID := range repositoryIDs { repoArts, err := dfp.artCtl.List(ctx, q.New(q.KeyWords{"RepositoryID": repoID}), opts) if err != nil { return nil, err @@ -146,7 +146,7 @@ func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter return filteredArts, nil } -func (dfp *DefaultFilterProcessor) ProcessLabelFilter(ctx context.Context, labelIDs []int64, arts []*artifact.Artifact) ([]*artifact.Artifact, error) { +func (dfp *DefaultFilterProcessor) ProcessLabelFilter(_ context.Context, labelIDs []int64, arts []*artifact.Artifact) ([]*artifact.Artifact, error) { // return all artifacts if no label need to be filtered if len(labelIDs) == 0 { return arts, nil diff --git a/src/pkg/scan/postprocessors/report_converters.go b/src/pkg/scan/postprocessors/report_converters.go index e1f67536e..b280e1a81 100644 --- a/src/pkg/scan/postprocessors/report_converters.go +++ b/src/pkg/scan/postprocessors/report_converters.go @@ -93,7 +93,7 @@ func (c *nativeToRelationalSchemaConverter) FromRelationalSchema(ctx context.Con return rp, nil } -func (c *nativeToRelationalSchemaConverter) toSchema(ctx context.Context, reportUUID string, registrationUUID string, digest string, rawReportData string) error { +func (c *nativeToRelationalSchemaConverter) toSchema(ctx context.Context, reportUUID string, registrationUUID string, _ string, rawReportData string) error { var vulnReport vuln.Report err := json.Unmarshal([]byte(rawReportData), &vulnReport) if err != nil { @@ -193,7 +193,7 @@ func (c *nativeToRelationalSchemaConverter) toSchema(ctx context.Context, report return nil } -func (c *nativeToRelationalSchemaConverter) fromSchema(ctx context.Context, reportUUID string, artifactDigest string, reportSummary string, records []*scan.VulnerabilityRecord) (string, error) { +func (c *nativeToRelationalSchemaConverter) fromSchema(_ context.Context, _ string, artifactDigest string, reportSummary string, records []*scan.VulnerabilityRecord) (string, error) { if len(reportSummary) == 0 { return "", nil } diff --git a/src/pkg/scan/report/summary.go b/src/pkg/scan/report/summary.go index 1181f9509..252a61921 100644 --- a/src/pkg/scan/report/summary.go +++ b/src/pkg/scan/report/summary.go @@ -96,7 +96,7 @@ func GenerateSummary(r *scan.Report, options ...Option) (interface{}, error) { type SummaryGenerator func(r *scan.Report, options ...Option) (interface{}, error) // GenerateNativeSummary generates the report summary for the native report. -func GenerateNativeSummary(r *scan.Report, options ...Option) (interface{}, error) { +func GenerateNativeSummary(r *scan.Report, _ ...Option) (interface{}, error) { sum := &vuln.NativeReportSummary{} sum.ReportID = r.UUID sum.StartTime = r.StartTime diff --git a/src/pkg/scan/rest/auth/no_auth.go b/src/pkg/scan/rest/auth/no_auth.go index c41375a4b..4c468b106 100644 --- a/src/pkg/scan/rest/auth/no_auth.go +++ b/src/pkg/scan/rest/auth/no_auth.go @@ -22,7 +22,7 @@ import ( type noAuth struct{} // Authorize the incoming request -func (na *noAuth) Authorize(req *http.Request) error { +func (na *noAuth) Authorize(_ *http.Request) error { // Do nothing return nil } diff --git a/src/pkg/scan/rest/v1/client.go b/src/pkg/scan/rest/v1/client.go index 251ccef1f..86bc2fec8 100644 --- a/src/pkg/scan/rest/v1/client.go +++ b/src/pkg/scan/rest/v1/client.go @@ -97,7 +97,7 @@ func NewClient(url, authType, accessCredential string, skipCertVerify bool) (Cli httpClient: &http.Client{ Timeout: time.Second * 5, Transport: transport, - CheckRedirect: func(req *http.Request, via []*http.Request) error { + CheckRedirect: func(_ *http.Request, _ []*http.Request) error { return http.ErrUseLastResponse }, }, diff --git a/src/pkg/scheduler/periodic_job.go b/src/pkg/scheduler/periodic_job.go index eb067f440..512c4a251 100644 --- a/src/pkg/scheduler/periodic_job.go +++ b/src/pkg/scheduler/periodic_job.go @@ -43,11 +43,11 @@ func (pj *PeriodicJob) ShouldRetry() bool { } // Validate the parameters -func (pj *PeriodicJob) Validate(params job.Parameters) error { +func (pj *PeriodicJob) Validate(_ job.Parameters) error { return nil } // Run the job -func (pj *PeriodicJob) Run(ctx job.Context, params job.Parameters) error { +func (pj *PeriodicJob) Run(ctx job.Context, _ job.Parameters) error { return ctx.Checkin("checkin") } diff --git a/src/pkg/signature/notary/helper.go b/src/pkg/signature/notary/helper.go index 0762a3031..7708d854c 100644 --- a/src/pkg/signature/notary/helper.go +++ b/src/pkg/signature/notary/helper.go @@ -44,7 +44,7 @@ var ( ) func init() { - mockRetriever = func(keyName, alias string, createNew bool, attempts int) (passphrase string, giveup bool, err error) { + mockRetriever = func(_, _ string, _ bool, _ int) (passphrase string, giveup bool, err error) { passphrase = "hardcode" giveup = false err = nil diff --git a/src/pkg/task/sweep_job.go b/src/pkg/task/sweep_job.go index 78f357314..6ee7d49a0 100644 --- a/src/pkg/task/sweep_job.go +++ b/src/pkg/task/sweep_job.go @@ -78,7 +78,7 @@ func (sj *SweepJob) ShouldRetry() bool { } // Validate the parameters of preheat job. -func (sj *SweepJob) Validate(params job.Parameters) error { +func (sj *SweepJob) Validate(_ job.Parameters) error { return nil } diff --git a/src/pkg/task/task.go b/src/pkg/task/task.go index b2d0524fa..a039d7689 100644 --- a/src/pkg/task/task.go +++ b/src/pkg/task/task.go @@ -159,7 +159,7 @@ func (m *manager) createTaskRecord(ctx context.Context, executionID int64, extra }) } -func (m *manager) submitJob(ctx context.Context, id int64, jb *Job) (string, error) { +func (m *manager) submitJob(_ context.Context, id int64, jb *Job) (string, error) { jobData := &models.JobData{ Name: jb.Name, StatusHook: fmt.Sprintf("%s/service/notifications/tasks/%d", m.coreURL, id), @@ -279,6 +279,6 @@ func (m *manager) ExecutionIDsByVendorAndStatus(ctx context.Context, vendorType, return m.dao.ExecutionIDsByVendorAndStatus(ctx, vendorType, status) } -func (m *manager) GetLogByJobID(ctx context.Context, jobID string) (log []byte, err error) { +func (m *manager) GetLogByJobID(_ context.Context, jobID string) (log []byte, err error) { return m.jsClient.GetJobLog(jobID) } diff --git a/src/pkg/user/dao/user.go b/src/pkg/user/dao/user.go index a3f7f8ab8..c209306d6 100644 --- a/src/pkg/user/dao/user.go +++ b/src/pkg/user/dao/user.go @@ -94,7 +94,7 @@ func toCommonUser(u *User) *commonmodels.User { } // FilterByUsernameOrEmail generates the query setter to match username or email column to the same value -func (u *User) FilterByUsernameOrEmail(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter { +func (u *User) FilterByUsernameOrEmail(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter { usernameOrEmail, ok := value.(string) if !ok { return qs diff --git a/src/registryctl/api/health.go b/src/registryctl/api/health.go index 54f0ea8ac..aed792ed0 100644 --- a/src/registryctl/api/health.go +++ b/src/registryctl/api/health.go @@ -21,7 +21,7 @@ import ( ) // Health ... -func Health(w http.ResponseWriter, r *http.Request) { +func Health(w http.ResponseWriter, _ *http.Request) { if err := WriteJSON(w, "healthy"); err != nil { log.Errorf("Failed to write response: %v", err) return diff --git a/src/server/middleware/blob/copy_artifact.go b/src/server/middleware/blob/copy_artifact.go index 15e503944..dfc526a2d 100644 --- a/src/server/middleware/blob/copy_artifact.go +++ b/src/server/middleware/blob/copy_artifact.go @@ -47,7 +47,7 @@ func isSuccess(statusCode int) bool { // CopyArtifactMiddleware middleware to sync the missing associations for the project func CopyArtifactMiddleware() func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if !isSuccess(statusCode) { return nil } diff --git a/src/server/middleware/blob/post_initiate_blob_upload.go b/src/server/middleware/blob/post_initiate_blob_upload.go index 33eb42c11..07a984961 100644 --- a/src/server/middleware/blob/post_initiate_blob_upload.go +++ b/src/server/middleware/blob/post_initiate_blob_upload.go @@ -24,7 +24,7 @@ import ( // PostInitiateBlobUploadMiddleware middleware to add blob to project after mount blob success func PostInitiateBlobUploadMiddleware() func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if statusCode != http.StatusCreated { return nil } diff --git a/src/server/middleware/blob/put_manifest.go b/src/server/middleware/blob/put_manifest.go index e44aac57b..1bb3fbeb8 100644 --- a/src/server/middleware/blob/put_manifest.go +++ b/src/server/middleware/blob/put_manifest.go @@ -49,7 +49,7 @@ func PutManifestMiddleware() func(http.Handler) http.Handler { return probeBlob(r, descriptor.Digest.String()) }) - after := middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + after := middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if statusCode != http.StatusCreated { return nil } diff --git a/src/server/middleware/cosign/cosign.go b/src/server/middleware/cosign/cosign.go index b863dc010..b5efd930a 100644 --- a/src/server/middleware/cosign/cosign.go +++ b/src/server/middleware/cosign/cosign.go @@ -53,7 +53,7 @@ var ( } */ func SignatureMiddleware() func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if statusCode != http.StatusCreated { return nil } diff --git a/src/server/middleware/nydus/nydus.go b/src/server/middleware/nydus/nydus.go index a2a62bf49..a76d66fb9 100644 --- a/src/server/middleware/nydus/nydus.go +++ b/src/server/middleware/nydus/nydus.go @@ -66,7 +66,7 @@ var ( */ func AcceleratorMiddleware() func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if statusCode != http.StatusCreated { return nil } diff --git a/src/server/middleware/quota/post_initiate_blob_upload.go b/src/server/middleware/quota/post_initiate_blob_upload.go index f4653a9c3..09826d883 100644 --- a/src/server/middleware/quota/post_initiate_blob_upload.go +++ b/src/server/middleware/quota/post_initiate_blob_upload.go @@ -34,7 +34,7 @@ func PostInitiateBlobUploadMiddleware() func(http.Handler) http.Handler { }) } -func postInitiateBlobUploadResources(r *http.Request, reference, referenceID string) (types.ResourceList, error) { +func postInitiateBlobUploadResources(r *http.Request, _, referenceID string) (types.ResourceList, error) { query := r.URL.Query() mount := query.Get("mount") if mount == "" { diff --git a/src/server/middleware/quota/put_blob_upload.go b/src/server/middleware/quota/put_blob_upload.go index a21b79fbd..408545ac7 100644 --- a/src/server/middleware/quota/put_blob_upload.go +++ b/src/server/middleware/quota/put_blob_upload.go @@ -34,7 +34,7 @@ func PutBlobUploadMiddleware() func(http.Handler) http.Handler { }) } -func putBlobUploadResources(r *http.Request, reference, referenceID string) (types.ResourceList, error) { +func putBlobUploadResources(r *http.Request, _, referenceID string) (types.ResourceList, error) { logger := log.G(r.Context()).WithFields(log.Fields{"middleware": "quota", "action": "request", "url": r.URL.Path}) size, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) diff --git a/src/server/middleware/quota/put_manifest.go b/src/server/middleware/quota/put_manifest.go index 2b27c3483..1a49ec064 100644 --- a/src/server/middleware/quota/put_manifest.go +++ b/src/server/middleware/quota/put_manifest.go @@ -35,7 +35,7 @@ func PutManifestMiddleware() func(http.Handler) http.Handler { }) } -func putManifestResources(r *http.Request, reference, referenceID string) (types.ResourceList, error) { +func putManifestResources(r *http.Request, _, referenceID string) (types.ResourceList, error) { logger := log.G(r.Context()).WithFields(log.Fields{"middleware": "quota", "action": "request", "url": r.URL.Path}) projectID, _ := strconv.ParseInt(referenceID, 10, 64) diff --git a/src/server/middleware/quota/quota.go b/src/server/middleware/quota/quota.go index 1213ea21f..f4d9b3c40 100644 --- a/src/server/middleware/quota/quota.go +++ b/src/server/middleware/quota/quota.go @@ -191,7 +191,7 @@ type RefreshConfig struct { // RefreshMiddleware middleware which refresh the quota usage after the response success func RefreshMiddleware(config RefreshConfig, skipers ...middleware.Skipper) func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { // skip to refresh quota usage when response is not success if !isSuccess(statusCode) { return nil diff --git a/src/server/middleware/quota/util.go b/src/server/middleware/quota/util.go index c46b6a5ca..e49d1ebc1 100644 --- a/src/server/middleware/quota/util.go +++ b/src/server/middleware/quota/util.go @@ -60,7 +60,7 @@ var ( ) func projectResourcesEvent(level int) func(*http.Request, string, string, string) event.Metadata { - return func(r *http.Request, reference, referenceID string, message string) event.Metadata { + return func(r *http.Request, _, referenceID string, message string) event.Metadata { ctx := r.Context() logger := log.G(ctx).WithFields(log.Fields{"middleware": "quota", "action": "request", "url": r.URL.Path}) diff --git a/src/server/middleware/quota/util_test.go b/src/server/middleware/quota/util_test.go index 870ab1388..b54a690ae 100644 --- a/src/server/middleware/quota/util_test.go +++ b/src/server/middleware/quota/util_test.go @@ -29,8 +29,8 @@ import ( func Test_projectReferenceObject(t *testing.T) { ctl := &project.Controller{} - ctl.On("GetByName", mock.AnythingOfType(""), "library").Return(&proModels.Project{ProjectID: 1}, nil) - ctl.On("GetByName", mock.AnythingOfType(""), "demo").Return(nil, fmt.Errorf("not found")) + ctl.On("GetByName", mock.AnythingOfType("context.todoCtx"), "library").Return(&proModels.Project{ProjectID: 1}, nil) + ctl.On("GetByName", mock.AnythingOfType("context.todoCtx"), "demo").Return(nil, fmt.Errorf("not found")) originalProjectController := projectController defer func() { diff --git a/src/server/middleware/repoproxy/proxy.go b/src/server/middleware/repoproxy/proxy.go index 26155bb8f..c6e4cfe86 100644 --- a/src/server/middleware/repoproxy/proxy.go +++ b/src/server/middleware/repoproxy/proxy.go @@ -217,7 +217,7 @@ func handleManifest(w http.ResponseWriter, r *http.Request, next http.Handler) e return nil } -func proxyManifestGet(ctx context.Context, w http.ResponseWriter, ctl proxy.Controller, p *proModels.Project, art lib.ArtifactInfo, remote proxy.RemoteInterface) error { +func proxyManifestGet(ctx context.Context, w http.ResponseWriter, ctl proxy.Controller, _ *proModels.Project, art lib.ArtifactInfo, remote proxy.RemoteInterface) error { man, err := ctl.ProxyManifest(ctx, art, remote) if err != nil { return err @@ -291,7 +291,7 @@ func DisableBlobAndManifestUploadMiddleware() func(http.Handler) http.Handler { }) } -func proxyManifestHead(ctx context.Context, w http.ResponseWriter, ctl proxy.Controller, p *proModels.Project, art lib.ArtifactInfo, remote proxy.RemoteInterface) error { +func proxyManifestHead(ctx context.Context, w http.ResponseWriter, ctl proxy.Controller, _ *proModels.Project, art lib.ArtifactInfo, remote proxy.RemoteInterface) error { exist, desc, err := ctl.HeadManifest(ctx, art, remote) if err != nil { return err diff --git a/src/server/middleware/subject/subject.go b/src/server/middleware/subject/subject.go index abd609f5c..e0769410e 100644 --- a/src/server/middleware/subject/subject.go +++ b/src/server/middleware/subject/subject.go @@ -56,7 +56,7 @@ import ( } */ func Middleware() func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if statusCode != http.StatusCreated { return nil } diff --git a/src/server/registry/catalog.go b/src/server/registry/catalog.go index 0e9058fe2..71971a584 100644 --- a/src/server/registry/catalog.go +++ b/src/server/registry/catalog.go @@ -118,7 +118,7 @@ func (r *repositoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) } // sendResponse ... -func (r *repositoryHandler) sendResponse(w http.ResponseWriter, req *http.Request, repositoryNames []string) { +func (r *repositoryHandler) sendResponse(w http.ResponseWriter, _ *http.Request, repositoryNames []string) { w.Header().Set("Content-Type", "application/json; charset=utf-8") enc := json.NewEncoder(w) if err := enc.Encode(catalogAPIResponse{ diff --git a/src/server/route.go b/src/server/route.go index ce3df15e3..7a9f03b70 100644 --- a/src/server/route.go +++ b/src/server/route.go @@ -27,7 +27,7 @@ import ( "github.com/goharbor/harbor/src/server/router" ) -func ignoreNotification(w http.ResponseWriter, r *http.Request) { +func ignoreNotification(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) } diff --git a/src/server/v2.0/handler/artifact.go b/src/server/v2.0/handler/artifact.go index c65cda595..35b5c14b1 100644 --- a/src/server/v2.0/handler/artifact.go +++ b/src/server/v2.0/handler/artifact.go @@ -73,7 +73,7 @@ type artifactAPI struct { labelMgr label.Manager } -func (a *artifactAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (a *artifactAPI) Prepare(ctx context.Context, _ string, params interface{}) middleware.Responder { if err := unescapePathParams(params, "RepositoryName"); err != nil { a.SendError(ctx, err) } @@ -430,7 +430,7 @@ func (a *artifactAPI) GetVulnerabilitiesAddition(ctx context.Context, params ope content, _ := json.Marshal(vulnerabilities) - return middleware.ResponderFunc(func(w http.ResponseWriter, p runtime.Producer) { + return middleware.ResponderFunc(func(w http.ResponseWriter, _ runtime.Producer) { w.Header().Set("Content-Type", "application/json") _, _ = w.Write(content) }) @@ -451,7 +451,7 @@ func (a *artifactAPI) GetAddition(ctx context.Context, params operation.GetAddit return a.SendError(ctx, err) } - return middleware.ResponderFunc(func(w http.ResponseWriter, p runtime.Producer) { + return middleware.ResponderFunc(func(w http.ResponseWriter, _ runtime.Producer) { w.Header().Set("Content-Type", addition.ContentType) _, _ = w.Write(addition.Content) }) diff --git a/src/server/v2.0/handler/base.go b/src/server/v2.0/handler/base.go index e7dede69f..ed166392b 100644 --- a/src/server/v2.0/handler/base.go +++ b/src/server/v2.0/handler/base.go @@ -46,12 +46,12 @@ var ( type BaseAPI struct{} // Prepare default prepare for operation -func (*BaseAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (*BaseAPI) Prepare(_ context.Context, _ string, _ interface{}) middleware.Responder { return nil } // SendError returns response for the err -func (*BaseAPI) SendError(ctx context.Context, err error) middleware.Responder { +func (*BaseAPI) SendError(_ context.Context, err error) middleware.Responder { return NewErrResponder(err) } @@ -157,7 +157,7 @@ func (b *BaseAPI) RequireSolutionUserAccess(ctx context.Context) error { } // BuildQuery builds the query model according to the query string -func (b *BaseAPI) BuildQuery(ctx context.Context, query, sort *string, pageNumber, pageSize *int64) (*q.Query, error) { +func (b *BaseAPI) BuildQuery(_ context.Context, query, sort *string, pageNumber, pageSize *int64) (*q.Query, error) { var ( qs string st string @@ -180,7 +180,7 @@ func (b *BaseAPI) BuildQuery(ctx context.Context, query, sort *string, pageNumbe } // Links return Links based on the provided pagination information -func (b *BaseAPI) Links(ctx context.Context, u *url.URL, total, pageNumber, pageSize int64) lib.Links { +func (b *BaseAPI) Links(_ context.Context, u *url.URL, total, pageNumber, pageSize int64) lib.Links { var links lib.Links if pageSize == 0 { return links @@ -235,7 +235,7 @@ type ErrResponder struct { } // WriteResponse ... -func (r *ErrResponder) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { +func (r *ErrResponder) WriteResponse(rw http.ResponseWriter, _ runtime.Producer) { lib_http.SendError(rw, r.err) } diff --git a/src/server/v2.0/handler/config.go b/src/server/v2.0/handler/config.go index b4b82b0c0..3be5fff4f 100644 --- a/src/server/v2.0/handler/config.go +++ b/src/server/v2.0/handler/config.go @@ -38,7 +38,7 @@ func newConfigAPI() *configAPI { return &configAPI{controller: config.Ctl} } -func (c *configAPI) GetConfigurations(ctx context.Context, params configure.GetConfigurationsParams) middleware.Responder { +func (c *configAPI) GetConfigurations(ctx context.Context, _ configure.GetConfigurationsParams) middleware.Responder { if sec, exist := security.FromContext(ctx); exist { if sec.IsSolutionUser() { cfg, err := c.controller.AllConfigs(ctx) @@ -104,7 +104,7 @@ func toCfgMap(conf *models.Configurations) (map[string]interface{}, error) { return cfgMap, nil } -func (c *configAPI) GetInternalconfig(ctx context.Context, params configure.GetInternalconfigParams) middleware.Responder { +func (c *configAPI) GetInternalconfig(ctx context.Context, _ configure.GetInternalconfigParams) middleware.Responder { if err := c.RequireSolutionUserAccess(ctx); err != nil { return c.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/gc.go b/src/server/v2.0/handler/gc.go index d431e9787..a2703c4ff 100644 --- a/src/server/v2.0/handler/gc.go +++ b/src/server/v2.0/handler/gc.go @@ -32,7 +32,7 @@ func newGCAPI() *gcAPI { } } -func (g *gcAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (g *gcAPI) Prepare(_ context.Context, _ string, _ interface{}) middleware.Responder { return nil } @@ -122,7 +122,7 @@ func (g *gcAPI) updateSchedule(ctx context.Context, cronType, cron string, polic return g.createSchedule(ctx, cronType, cron, policy) } -func (g *gcAPI) GetGCSchedule(ctx context.Context, params operation.GetGCScheduleParams) middleware.Responder { +func (g *gcAPI) GetGCSchedule(ctx context.Context, _ operation.GetGCScheduleParams) middleware.Responder { if err := g.RequireSystemAccess(ctx, rbac.ActionRead, rbac.ResourceGarbageCollection); err != nil { return g.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/handler.go b/src/server/v2.0/handler/handler.go index 597756d37..3ebbf4c4e 100644 --- a/src/server/v2.0/handler/handler.go +++ b/src/server/v2.0/handler/handler.go @@ -85,7 +85,7 @@ func New() http.Handler { } // function is called before the Prepare of the operation -func beforePrepare(ctx context.Context, operation string, params interface{}) rmiddleware.Responder { +func beforePrepare(ctx context.Context, operation string, _ interface{}) rmiddleware.Responder { metric.SetMetricOpID(ctx, operation) return nil } @@ -94,6 +94,6 @@ func beforePrepare(ctx context.Context, operation string, params interface{}) rm // it will return directly when bind and validate failed. // The response format of the default ServeError implementation does not match the internal error response format. // So we needed to convert the format to the internal error response format. -func serveError(rw http.ResponseWriter, r *http.Request, err error) { +func serveError(rw http.ResponseWriter, _ *http.Request, err error) { lib_http.SendError(rw, err) } diff --git a/src/server/v2.0/handler/health.go b/src/server/v2.0/handler/health.go index d72ffdefa..130345bf3 100644 --- a/src/server/v2.0/handler/health.go +++ b/src/server/v2.0/handler/health.go @@ -35,7 +35,7 @@ type healthAPI struct { ctl health.Controller } -func (r *healthAPI) GetHealth(ctx context.Context, params operations.GetHealthParams) middleware.Responder { +func (r *healthAPI) GetHealth(ctx context.Context, _ operations.GetHealthParams) middleware.Responder { status := r.ctl.GetHealth(ctx) s := &models.OverallHealthStatus{ Status: status.Status, diff --git a/src/server/v2.0/handler/jobservice.go b/src/server/v2.0/handler/jobservice.go index 33084a2eb..35224c90e 100644 --- a/src/server/v2.0/handler/jobservice.go +++ b/src/server/v2.0/handler/jobservice.go @@ -42,7 +42,7 @@ func newJobServiceAPI() *jobServiceAPI { return &jobServiceAPI{jobCtr: jobmonitor.Ctl} } -func (j *jobServiceAPI) GetWorkerPools(ctx context.Context, params jobservice.GetWorkerPoolsParams) middleware.Responder { +func (j *jobServiceAPI) GetWorkerPools(ctx context.Context, _ jobservice.GetWorkerPoolsParams) middleware.Responder { if err := j.RequireSystemAccess(ctx, rbac.ActionList, rbac.ResourceJobServiceMonitor); err != nil { return j.SendError(ctx, err) } @@ -143,7 +143,7 @@ func toScheduleResponse(schs []*scheduler.Schedule) []*models.ScheduleTask { return result } -func (j *jobServiceAPI) ListJobQueues(ctx context.Context, params jobservice.ListJobQueuesParams) middleware.Responder { +func (j *jobServiceAPI) ListJobQueues(ctx context.Context, _ jobservice.ListJobQueuesParams) middleware.Responder { if err := j.RequireSystemAccess(ctx, rbac.ActionList, rbac.ResourceJobServiceMonitor); err != nil { return j.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/model/project.go b/src/server/v2.0/handler/model/project.go index 1321f2fc0..d821e8c90 100644 --- a/src/server/v2.0/handler/model/project.go +++ b/src/server/v2.0/handler/model/project.go @@ -33,9 +33,9 @@ type Project struct { // ToSwagger converts the project to the swagger model func (p *Project) ToSwagger() *models.Project { - var currentUserRoleIds []int32 + var currentUserRoleIDs []int32 for _, role := range p.RoleList { - currentUserRoleIds = append(currentUserRoleIds, int32(role)) + currentUserRoleIDs = append(currentUserRoleIDs, int32(role)) } var md *models.ProjectMetadata @@ -63,7 +63,7 @@ func (p *Project) ToSwagger() *models.Project { return &models.Project{ CreationTime: strfmt.DateTime(p.CreationTime), CurrentUserRoleID: int64(p.Role), - CurrentUserRoleIds: currentUserRoleIds, + CurrentUserRoleIds: currentUserRoleIDs, CVEAllowlist: &allowlist, Metadata: md, Name: p.Name, diff --git a/src/server/v2.0/handler/model/scanner.go b/src/server/v2.0/handler/model/scanner.go index 6c783f504..271113cd4 100644 --- a/src/server/v2.0/handler/model/scanner.go +++ b/src/server/v2.0/handler/model/scanner.go @@ -30,7 +30,7 @@ type ScannerRegistration struct { } // ToSwagger ... -func (s *ScannerRegistration) ToSwagger(ctx context.Context) *models.ScannerRegistration { +func (s *ScannerRegistration) ToSwagger(_ context.Context) *models.ScannerRegistration { if s.Registration == nil { return nil } @@ -66,7 +66,7 @@ type ScannerMetadata struct { } // ToSwagger ... -func (s *ScannerMetadata) ToSwagger(ctx context.Context) *models.ScannerAdapterMetadata { +func (s *ScannerMetadata) ToSwagger(_ context.Context) *models.ScannerAdapterMetadata { if s.ScannerAdapterMetadata == nil { return nil } diff --git a/src/server/v2.0/handler/ping.go b/src/server/v2.0/handler/ping.go index 887f9849e..697f7d743 100644 --- a/src/server/v2.0/handler/ping.go +++ b/src/server/v2.0/handler/ping.go @@ -16,6 +16,6 @@ func newPingAPI() *pingAPI { return &pingAPI{} } -func (p *pingAPI) GetPing(ctx context.Context, params ping.GetPingParams) middleware.Responder { +func (p *pingAPI) GetPing(_ context.Context, _ ping.GetPingParams) middleware.Responder { return ping.NewGetPingOK().WithPayload("Pong") } diff --git a/src/server/v2.0/handler/preheat.go b/src/server/v2.0/handler/preheat.go index dbfc8e218..9ef889d5c 100644 --- a/src/server/v2.0/handler/preheat.go +++ b/src/server/v2.0/handler/preheat.go @@ -65,7 +65,7 @@ type preheatAPI struct { taskCtl taskCtl.Controller } -func (api *preheatAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (api *preheatAPI) Prepare(_ context.Context, _ string, _ interface{}) middleware.Responder { return nil } @@ -160,7 +160,7 @@ func (api *preheatAPI) ListInstances(ctx context.Context, params operation.ListI WithLink(api.Links(ctx, params.HTTPRequest.URL, total, query.PageNumber, query.PageSize).String()) } -func (api *preheatAPI) ListProviders(ctx context.Context, params operation.ListProvidersParams) middleware.Responder { +func (api *preheatAPI) ListProviders(ctx context.Context, _ operation.ListProvidersParams) middleware.Responder { if err := api.RequireSystemAccess(ctx, rbac.ActionList, rbac.ResourcePreatInstance); err != nil { return api.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/project_metadata.go b/src/server/v2.0/handler/project_metadata.go index 46638bf5f..0102e2311 100644 --- a/src/server/v2.0/handler/project_metadata.go +++ b/src/server/v2.0/handler/project_metadata.go @@ -138,8 +138,6 @@ func (p *projectMetadataAPI) validate(metas map[string]string) (map[string]strin } key, value := "", "" - for key, value = range metas { - } switch key { case proModels.ProMetaPublic, proModels.ProMetaEnableContentTrust, proModels.ProMetaEnableContentTrustCosign, diff --git a/src/server/v2.0/handler/purge.go b/src/server/v2.0/handler/purge.go index f9cd38eec..656776123 100644 --- a/src/server/v2.0/handler/purge.go +++ b/src/server/v2.0/handler/purge.go @@ -252,7 +252,7 @@ func (p *purgeAPI) GetPurgeJobLog(ctx context.Context, params purge.GetPurgeJobL return purge.NewGetPurgeJobLogOK().WithPayload(string(taskLog)) } -func (p *purgeAPI) GetPurgeSchedule(ctx context.Context, params purge.GetPurgeScheduleParams) middleware.Responder { +func (p *purgeAPI) GetPurgeSchedule(ctx context.Context, _ purge.GetPurgeScheduleParams) middleware.Responder { if err := p.RequireSystemAccess(ctx, rbac.ActionRead, rbac.ResourcePurgeAuditLog); err != nil { return p.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/registry.go b/src/server/v2.0/handler/registry.go index 59e6d293a..1cc225286 100644 --- a/src/server/v2.0/handler/registry.go +++ b/src/server/v2.0/handler/registry.go @@ -195,7 +195,7 @@ func (r *registryAPI) GetRegistryInfo(ctx context.Context, params operation.GetR return operation.NewGetRegistryInfoOK().WithPayload(in) } -func (r *registryAPI) ListRegistryProviderTypes(ctx context.Context, params operation.ListRegistryProviderTypesParams) middleware.Responder { +func (r *registryAPI) ListRegistryProviderTypes(ctx context.Context, _ operation.ListRegistryProviderTypesParams) middleware.Responder { if err := r.RequireSystemAccess(ctx, rbac.ActionList, rbac.ResourceReplicationAdapter); err != nil { return r.SendError(ctx, err) } @@ -271,7 +271,7 @@ func (r *registryAPI) PingRegistry(ctx context.Context, params operation.PingReg return operation.NewPingRegistryOK() } -func (r *registryAPI) ListRegistryProviderInfos(ctx context.Context, params operation.ListRegistryProviderInfosParams) middleware.Responder { +func (r *registryAPI) ListRegistryProviderInfos(ctx context.Context, _ operation.ListRegistryProviderInfosParams) middleware.Responder { if err := r.RequireSystemAccess(ctx, rbac.ActionList, rbac.ResourceReplicationAdapter); err != nil { return r.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/replication.go b/src/server/v2.0/handler/replication.go index 88988c781..e9c64c439 100644 --- a/src/server/v2.0/handler/replication.go +++ b/src/server/v2.0/handler/replication.go @@ -46,7 +46,7 @@ type replicationAPI struct { ctl replication.Controller } -func (r *replicationAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (r *replicationAPI) Prepare(_ context.Context, _ string, _ interface{}) middleware.Responder { return nil } diff --git a/src/server/v2.0/handler/repository.go b/src/server/v2.0/handler/repository.go index 3c3701747..e27a9c456 100644 --- a/src/server/v2.0/handler/repository.go +++ b/src/server/v2.0/handler/repository.go @@ -55,7 +55,7 @@ type repositoryAPI struct { artCtl artifact.Controller } -func (r *repositoryAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (r *repositoryAPI) Prepare(ctx context.Context, _ string, params interface{}) middleware.Responder { if err := unescapePathParams(params, "RepositoryName"); err != nil { r.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/retention.go b/src/server/v2.0/handler/retention.go index 1f1154433..f18065dbb 100644 --- a/src/server/v2.0/handler/retention.go +++ b/src/server/v2.0/handler/retention.go @@ -119,7 +119,7 @@ var ( } ) -func (r *retentionAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (r *retentionAPI) Prepare(ctx context.Context, _ string, _ interface{}) middleware.Responder { if err := r.RequireAuthenticated(ctx); err != nil { return r.SendError(ctx, err) } @@ -127,7 +127,7 @@ func (r *retentionAPI) Prepare(ctx context.Context, operation string, params int return nil } -func (r *retentionAPI) GetRentenitionMetadata(ctx context.Context, params operation.GetRentenitionMetadataParams) middleware.Responder { +func (r *retentionAPI) GetRentenitionMetadata(_ context.Context, _ operation.GetRentenitionMetadataParams) middleware.Responder { return operation.NewGetRentenitionMetadataOK().WithPayload(rentenitionMetadataPayload) } diff --git a/src/server/v2.0/handler/scan.go b/src/server/v2.0/handler/scan.go index 7f2645768..8691246e5 100644 --- a/src/server/v2.0/handler/scan.go +++ b/src/server/v2.0/handler/scan.go @@ -41,7 +41,7 @@ type scanAPI struct { scanCtl scan.Controller } -func (s *scanAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (s *scanAPI) Prepare(ctx context.Context, _ string, params interface{}) middleware.Responder { if err := unescapePathParams(params, "RepositoryName"); err != nil { s.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/scan_all.go b/src/server/v2.0/handler/scan_all.go index 1359fe8de..a2d247218 100644 --- a/src/server/v2.0/handler/scan_all.go +++ b/src/server/v2.0/handler/scan_all.go @@ -57,12 +57,12 @@ type scanAllAPI struct { makeCtx func() context.Context } -func (s *scanAllAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (s *scanAllAPI) Prepare(_ context.Context, _ string, _ interface{}) middleware.Responder { return nil } // StopScanAll stops the execution of scan all artifacts. -func (s *scanAllAPI) StopScanAll(ctx context.Context, params operation.StopScanAllParams) middleware.Responder { +func (s *scanAllAPI) StopScanAll(ctx context.Context, _ operation.StopScanAllParams) middleware.Responder { if err := s.requireAccess(ctx, rbac.ActionStop); err != nil { return s.SendError(ctx, err) } @@ -159,7 +159,7 @@ func (s *scanAllAPI) UpdateScanAllSchedule(ctx context.Context, params operation return operation.NewUpdateScanAllScheduleOK() } -func (s *scanAllAPI) GetScanAllSchedule(ctx context.Context, params operation.GetScanAllScheduleParams) middleware.Responder { +func (s *scanAllAPI) GetScanAllSchedule(ctx context.Context, _ operation.GetScanAllScheduleParams) middleware.Responder { if err := s.requireAccess(ctx, rbac.ActionRead); err != nil { return s.SendError(ctx, err) } @@ -171,7 +171,7 @@ func (s *scanAllAPI) GetScanAllSchedule(ctx context.Context, params operation.Ge return operation.NewGetScanAllScheduleOK().WithPayload(model.NewSchedule(schedule).ToSwagger()) } -func (s *scanAllAPI) GetLatestScanAllMetrics(ctx context.Context, params operation.GetLatestScanAllMetricsParams) middleware.Responder { +func (s *scanAllAPI) GetLatestScanAllMetrics(ctx context.Context, _ operation.GetLatestScanAllMetricsParams) middleware.Responder { if err := s.requireAccess(ctx, rbac.ActionRead); err != nil { return s.SendError(ctx, err) } @@ -183,7 +183,7 @@ func (s *scanAllAPI) GetLatestScanAllMetrics(ctx context.Context, params operati return operation.NewGetLatestScanAllMetricsOK().WithPayload(stats) } -func (s *scanAllAPI) GetLatestScheduledScanAllMetrics(ctx context.Context, params operation.GetLatestScheduledScanAllMetricsParams) middleware.Responder { +func (s *scanAllAPI) GetLatestScheduledScanAllMetrics(ctx context.Context, _ operation.GetLatestScheduledScanAllMetricsParams) middleware.Responder { if err := s.requireAccess(ctx, rbac.ActionRead); err != nil { return s.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/scanexport.go b/src/server/v2.0/handler/scanexport.go index 3c07a994d..bd146d9b3 100644 --- a/src/server/v2.0/handler/scanexport.go +++ b/src/server/v2.0/handler/scanexport.go @@ -44,7 +44,7 @@ type scanDataExportAPI struct { userMgr user.Manager } -func (se *scanDataExportAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (se *scanDataExportAPI) Prepare(_ context.Context, _ string, _ interface{}) middleware.Responder { return nil } @@ -76,8 +76,8 @@ func (se *scanDataExportAPI) ExportScanData(ctx context.Context, params operatio } if usr == nil { - error := &models.Error{Message: fmt.Sprintf("User : %s not found", secContext.GetUsername())} - errors := &models.Errors{Errors: []*models.Error{error}} + userErr := &models.Error{Message: fmt.Sprintf("User : %s not found", secContext.GetUsername())} + errors := &models.Errors{Errors: []*models.Error{userErr}} return operation.NewExportScanDataForbidden().WithPayload(errors) } @@ -150,7 +150,7 @@ func (se *scanDataExportAPI) DownloadScanData(ctx context.Context, params operat execution, err := se.scanDataExportCtl.GetExecution(ctx, params.ExecutionID) if err != nil { if notFound := orm.AsNotFoundError(err, "execution with id: %d not found", params.ExecutionID); notFound != nil { - return middleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) { + return middleware.ResponderFunc(func(writer http.ResponseWriter, _ runtime.Producer) { writer.WriteHeader(http.StatusNotFound) }) } @@ -169,14 +169,14 @@ func (se *scanDataExportAPI) DownloadScanData(ctx context.Context, params operat } if secContext.GetUsername() != execution.UserName { - return middleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) { + return middleware.ResponderFunc(func(writer http.ResponseWriter, _ runtime.Producer) { writer.WriteHeader(http.StatusForbidden) }) } // check if the CSV artifact for the execution exists if !execution.FilePresent { - return middleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) { + return middleware.ResponderFunc(func(writer http.ResponseWriter, _ runtime.Producer) { writer.WriteHeader(http.StatusNotFound) }) } @@ -188,7 +188,7 @@ func (se *scanDataExportAPI) DownloadScanData(ctx context.Context, params operat } log.Infof("reading data from file : %s", repositoryName) - return middleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) { + return middleware.ResponderFunc(func(writer http.ResponseWriter, _ runtime.Producer) { defer se.cleanUpArtifact(ctx, repositoryName, execution.ExportDataDigest, params.ExecutionID, file) writer.Header().Set("Content-Type", "text/csv") @@ -202,7 +202,7 @@ func (se *scanDataExportAPI) DownloadScanData(ctx context.Context, params operat }) } -func (se *scanDataExportAPI) GetScanDataExportExecutionList(ctx context.Context, params operation.GetScanDataExportExecutionListParams) middleware.Responder { +func (se *scanDataExportAPI) GetScanDataExportExecutionList(ctx context.Context, _ operation.GetScanDataExportExecutionListParams) middleware.Responder { if err := se.RequireAuthenticated(ctx); err != nil { return se.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/statistic.go b/src/server/v2.0/handler/statistic.go index 51758d948..49b5e4312 100644 --- a/src/server/v2.0/handler/statistic.go +++ b/src/server/v2.0/handler/statistic.go @@ -46,7 +46,7 @@ type statisticAPI struct { systemArtifactMgr systemartifact.Manager } -func (s *statisticAPI) GetStatistic(ctx context.Context, params operation.GetStatisticParams) middleware.Responder { +func (s *statisticAPI) GetStatistic(ctx context.Context, _ operation.GetStatisticParams) middleware.Responder { if err := s.RequireAuthenticated(ctx); err != nil { return s.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/sys_cve_allowlist.go b/src/server/v2.0/handler/sys_cve_allowlist.go index a80fb32dd..859f316b5 100644 --- a/src/server/v2.0/handler/sys_cve_allowlist.go +++ b/src/server/v2.0/handler/sys_cve_allowlist.go @@ -52,7 +52,7 @@ func (s systemCVEAllowListAPI) PutSystemCVEAllowlist(ctx context.Context, params return system_cve_allowlist.NewPutSystemCVEAllowlistOK() } -func (s systemCVEAllowListAPI) GetSystemCVEAllowlist(ctx context.Context, params system_cve_allowlist.GetSystemCVEAllowlistParams) middleware.Responder { +func (s systemCVEAllowListAPI) GetSystemCVEAllowlist(ctx context.Context, _ system_cve_allowlist.GetSystemCVEAllowlistParams) middleware.Responder { if err := s.RequireAuthenticated(ctx); err != nil { return s.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/systeminfo.go b/src/server/v2.0/handler/systeminfo.go index 5b032c1cd..90d186eea 100644 --- a/src/server/v2.0/handler/systeminfo.go +++ b/src/server/v2.0/handler/systeminfo.go @@ -24,7 +24,7 @@ func newSystemInfoAPI() *sysInfoAPI { } } -func (s *sysInfoAPI) GetSystemInfo(ctx context.Context, params systeminfo.GetSystemInfoParams) middleware.Responder { +func (s *sysInfoAPI) GetSystemInfo(ctx context.Context, _ systeminfo.GetSystemInfoParams) middleware.Responder { opt := si.Options{} sc, ok := security.FromContext(ctx) if ok && sc.IsAuthenticated() { @@ -37,7 +37,7 @@ func (s *sysInfoAPI) GetSystemInfo(ctx context.Context, params systeminfo.GetSys return systeminfo.NewGetSystemInfoOK().WithPayload(s.convertInfo(data)) } -func (s *sysInfoAPI) GetCert(ctx context.Context, params systeminfo.GetCertParams) middleware.Responder { +func (s *sysInfoAPI) GetCert(ctx context.Context, _ systeminfo.GetCertParams) middleware.Responder { f, err := s.ctl.GetCA(ctx) if err != nil { return s.SendError(ctx, err) @@ -45,7 +45,7 @@ func (s *sysInfoAPI) GetCert(ctx context.Context, params systeminfo.GetCertParam return systeminfo.NewGetCertOK().WithContentDisposition("attachment; filename=ca.crt").WithPayload(f) } -func (s *sysInfoAPI) GetVolumes(ctx context.Context, params systeminfo.GetVolumesParams) middleware.Responder { +func (s *sysInfoAPI) GetVolumes(ctx context.Context, _ systeminfo.GetVolumesParams) middleware.Responder { if err := s.RequireSystemAccess(ctx, rbac.ActionRead, rbac.ResourceSystemVolumes); err != nil { return s.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/user.go b/src/server/v2.0/handler/user.go index 6df2073f6..4b9c54e4b 100644 --- a/src/server/v2.0/handler/user.go +++ b/src/server/v2.0/handler/user.go @@ -196,7 +196,7 @@ func (u *usersAPI) DeleteUser(ctx context.Context, params operation.DeleteUserPa return operation.NewDeleteUserOK() } -func (u *usersAPI) GetCurrentUserInfo(ctx context.Context, params operation.GetCurrentUserInfoParams) middleware.Responder { +func (u *usersAPI) GetCurrentUserInfo(ctx context.Context, _ operation.GetCurrentUserInfoParams) middleware.Responder { if err := u.RequireAuthenticated(ctx); err != nil { return u.SendError(ctx, err) } diff --git a/src/server/v2.0/handler/webhook.go b/src/server/v2.0/handler/webhook.go index 22a14ffca..256bfaef9 100644 --- a/src/server/v2.0/handler/webhook.go +++ b/src/server/v2.0/handler/webhook.go @@ -53,7 +53,7 @@ type webhookAPI struct { webhookCtl webhook_ctl.Controller } -func (n *webhookAPI) Prepare(ctx context.Context, operation string, params interface{}) middleware.Responder { +func (n *webhookAPI) Prepare(_ context.Context, _ string, _ interface{}) middleware.Responder { return nil } diff --git a/src/server/version.go b/src/server/version.go index 9646b1de5..aa5df146e 100644 --- a/src/server/version.go +++ b/src/server/version.go @@ -32,7 +32,7 @@ type APIVersion struct { } // GetAPIVersion returns the current supported API version -func GetAPIVersion(w http.ResponseWriter, r *http.Request) { +func GetAPIVersion(w http.ResponseWriter, _ *http.Request) { if err := json.NewEncoder(w).Encode(&APIVersion{Version: version}); err != nil { lib_http.SendError(w, err) } diff --git a/src/testing/pkg/scan/dao/scan/vulnerability_record_dao.go b/src/testing/pkg/scan/dao/scan/vulnerability_record_dao.go index 5c9c77152..0a59ea37c 100644 --- a/src/testing/pkg/scan/dao/scan/vulnerability_record_dao.go +++ b/src/testing/pkg/scan/dao/scan/vulnerability_record_dao.go @@ -167,8 +167,8 @@ func (_m *VulnerabilityRecordDao) GetForScanner(ctx context.Context, registratio return r0, r1 } -// GetRecordIdsForScanner provides a mock function with given fields: ctx, registrationUUID -func (_m *VulnerabilityRecordDao) GetRecordIdsForScanner(ctx context.Context, registrationUUID string) ([]int, error) { +// GetRecordIDsForScanner provides a mock function with given fields: ctx, registrationUUID +func (_m *VulnerabilityRecordDao) GetRecordIDsForScanner(ctx context.Context, registrationUUID string) ([]int, error) { ret := _m.Called(ctx, registrationUUID) var r0 []int diff --git a/src/testing/pkg/scan/export/filter_processor.go b/src/testing/pkg/scan/export/filter_processor.go index 7afa9ae6d..8dbf9e8e0 100644 --- a/src/testing/pkg/scan/export/filter_processor.go +++ b/src/testing/pkg/scan/export/filter_processor.go @@ -41,17 +41,17 @@ func (_m *FilterProcessor) ProcessLabelFilter(ctx context.Context, labelIDs []in return r0, r1 } -// ProcessRepositoryFilter provides a mock function with given fields: ctx, filter, projectIds -func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter string, projectIds []int64) ([]int64, error) { - ret := _m.Called(ctx, filter, projectIds) +// ProcessRepositoryFilter provides a mock function with given fields: ctx, filter, projectIDs +func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter string, projectIDs []int64) ([]int64, error) { + ret := _m.Called(ctx, filter, projectIDs) var r0 []int64 var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, []int64) ([]int64, error)); ok { - return rf(ctx, filter, projectIds) + return rf(ctx, filter, projectIDs) } if rf, ok := ret.Get(0).(func(context.Context, string, []int64) []int64); ok { - r0 = rf(ctx, filter, projectIds) + r0 = rf(ctx, filter, projectIDs) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]int64) @@ -59,7 +59,7 @@ func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter s } if rf, ok := ret.Get(1).(func(context.Context, string, []int64) error); ok { - r1 = rf(ctx, filter, projectIds) + r1 = rf(ctx, filter, projectIDs) } else { r1 = ret.Error(1) } @@ -67,17 +67,17 @@ func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter s return r0, r1 } -// ProcessTagFilter provides a mock function with given fields: ctx, filter, repositoryIds -func (_m *FilterProcessor) ProcessTagFilter(ctx context.Context, filter string, repositoryIds []int64) ([]*artifact.Artifact, error) { - ret := _m.Called(ctx, filter, repositoryIds) +// ProcessTagFilter provides a mock function with given fields: ctx, filter, repositoryIDs +func (_m *FilterProcessor) ProcessTagFilter(ctx context.Context, filter string, repositoryIDs []int64) ([]*artifact.Artifact, error) { + ret := _m.Called(ctx, filter, repositoryIDs) var r0 []*artifact.Artifact var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, []int64) ([]*artifact.Artifact, error)); ok { - return rf(ctx, filter, repositoryIds) + return rf(ctx, filter, repositoryIDs) } if rf, ok := ret.Get(0).(func(context.Context, string, []int64) []*artifact.Artifact); ok { - r0 = rf(ctx, filter, repositoryIds) + r0 = rf(ctx, filter, repositoryIDs) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]*artifact.Artifact) @@ -85,7 +85,7 @@ func (_m *FilterProcessor) ProcessTagFilter(ctx context.Context, filter string, } if rf, ok := ret.Get(1).(func(context.Context, string, []int64) error); ok { - r1 = rf(ctx, filter, repositoryIds) + r1 = rf(ctx, filter, repositoryIDs) } else { r1 = ret.Error(1) } diff --git a/tests/ci/distro_installer.sh b/tests/ci/distro_installer.sh index 4fa4e5083..ec056f08a 100755 --- a/tests/ci/distro_installer.sh +++ b/tests/ci/distro_installer.sh @@ -3,5 +3,5 @@ set -x set -e -sudo make package_online GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=dev-gitaction PKGVERSIONTAG=dev-gitaction UIVERSIONTAG=dev-gitaction GOBUILDIMAGE=goharbor/golang:1.20.7 COMPILETAG=compile_golangimage NOTARYFLAG=true TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false -sudo make package_offline GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=dev-gitaction PKGVERSIONTAG=dev-gitaction UIVERSIONTAG=dev-gitaction GOBUILDIMAGE=goharbor/golang:1.20.7 COMPILETAG=compile_golangimage NOTARYFLAG=true TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false +sudo make package_online GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=dev-gitaction PKGVERSIONTAG=dev-gitaction UIVERSIONTAG=dev-gitaction GOBUILDIMAGE=goharbor/golang:1.21.7 COMPILETAG=compile_golangimage NOTARYFLAG=true TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false +sudo make package_offline GOBUILDTAGS="include_oss include_gcs" VERSIONTAG=dev-gitaction PKGVERSIONTAG=dev-gitaction UIVERSIONTAG=dev-gitaction GOBUILDIMAGE=goharbor/golang:1.21.7 COMPILETAG=compile_golangimage NOTARYFLAG=true TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false diff --git a/tests/ci/ut_install.sh b/tests/ci/ut_install.sh index b0954ecf5..33a3c0419 100755 --- a/tests/ci/ut_install.sh +++ b/tests/ci/ut_install.sh @@ -18,7 +18,7 @@ go get -u github.com/client9/misspell/cmd/misspell set -e # binary will be $(go env GOPATH)/bin/golangci-lint # go install/go get installation aren't guaranteed to work. We recommend using binary installation. -curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2 +curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2 sudo service postgresql stop || echo no postgresql need to be stopped sleep 2