diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b251f7a95..56ef0fb85 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -44,7 +44,7 @@ jobs: - name: Set up Go 1.21 uses: actions/setup-go@v5 with: - go-version: 1.21.4 + go-version: 1.21.5 id: go - uses: actions/checkout@v3 with: @@ -105,7 +105,7 @@ jobs: - name: Set up Go 1.21 uses: actions/setup-go@v5 with: - go-version: 1.21.4 + go-version: 1.21.5 id: go - uses: actions/checkout@v3 with: @@ -160,7 +160,7 @@ jobs: - name: Set up Go 1.21 uses: actions/setup-go@v5 with: - go-version: 1.21.4 + go-version: 1.21.5 id: go - uses: actions/checkout@v3 with: @@ -215,7 +215,7 @@ jobs: - name: Set up Go 1.21 uses: actions/setup-go@v5 with: - go-version: 1.21.4 + go-version: 1.21.5 id: go - uses: actions/checkout@v3 with: @@ -268,7 +268,7 @@ jobs: - name: Set up Go 1.21 uses: actions/setup-go@v5 with: - go-version: 1.21.4 + go-version: 1.21.5 id: go - uses: actions/checkout@v3 with: diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml index 902efbc10..4b11a1a95 100644 --- a/.github/workflows/build-package.yml +++ b/.github/workflows/build-package.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Go 1.21 uses: actions/setup-go@v5 with: - go-version: 1.21.4 + go-version: 1.21.5 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 fd1463f6e..bda571299 100644 --- a/.github/workflows/conformance_test.yml +++ b/.github/workflows/conformance_test.yml @@ -28,7 +28,7 @@ jobs: - name: Set up Go 1.21 uses: actions/setup-go@v5 with: - go-version: 1.21.4 + go-version: 1.21.5 id: go - uses: actions/checkout@v3 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b15588af2..107ac61a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -164,7 +164,7 @@ Harbor backend is written in [Go](http://golang.org/). If you don't have a Harbo | 2.7 | 1.19.4 | | 2.8 | 1.20.6 | | 2.9 | 1.21.3 | -| 2.10 | 1.21.4 | +| 2.10 | 1.21.5 | Ensure your GOPATH and PATH have been configured in accordance with the Go environment instructions. diff --git a/Makefile b/Makefile index b8b0be1bf..81b3ddda5 100644 --- a/Makefile +++ b/Makefile @@ -140,7 +140,7 @@ GOINSTALL=$(GOCMD) install GOTEST=$(GOCMD) test GODEP=$(GOTEST) -i GOFMT=gofmt -w -GOBUILDIMAGE=golang:1.21.4 +GOBUILDIMAGE=golang:1.21.5 GOBUILDPATHINCONTAINER=/harbor # go build @@ -479,7 +479,7 @@ misspell: @find . -type d \( -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.55.2 GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint lint: @echo checking lint diff --git a/make/photon/registry/Dockerfile.binary b/make/photon/registry/Dockerfile.binary index d77f133fe..be98146a6 100644 --- a/make/photon/registry/Dockerfile.binary +++ b/make/photon/registry/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.21.4 +FROM golang:1.21.5 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 9c6d3d4ab..94d71551a 100644 --- a/make/photon/trivy-adapter/Dockerfile.binary +++ b/make/photon/trivy-adapter/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.21.4 +FROM golang:1.21.5 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 7b51c2673..b696b01bb 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 golang:1.21.4..." +echo "Building Trivy adapter binary based on golang:1.21.5..." cp Dockerfile.binary $TEMP docker build -f $TEMP/Dockerfile.binary -t trivy-adapter-golang $TEMP 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 ed3adfd52..a36157218 100644 --- a/src/common/security/v2token/context.go +++ b/src/common/security/v2token/context.go @@ -63,7 +63,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 02d7dbf61..15c464ab2 100644 --- a/src/controller/artifact/annotation/v1alpha1.go +++ b/src/controller/artifact/annotation/v1alpha1.go @@ -39,7 +39,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 a681966b9..af97b1b0f 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 } @@ -127,7 +127,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 1acb09906..c424b2659 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 5cd3e233e..fb212ac87 100644 --- a/src/controller/event/handler/internal/artifact.go +++ b/src/controller/event/handler/internal/artifact.go @@ -159,7 +159,7 @@ func (a *ArtifactEventHandler) onPull(ctx context.Context, event *event.Artifact return nil } -func (a *ArtifactEventHandler) updatePullTimeInCache(ctx context.Context, event *event.ArtifactEvent) { +func (a *ArtifactEventHandler) updatePullTimeInCache(_ context.Context, event *event.ArtifactEvent) { var tagName string if len(event.Tags) != 0 { tagName = event.Tags[0] @@ -173,7 +173,7 @@ func (a *ArtifactEventHandler) updatePullTimeInCache(ctx context.Context, event a.pullTimeStore[key] = time.Now() } -func (a *ArtifactEventHandler) addPullCountInCache(ctx context.Context, event *event.ArtifactEvent) { +func (a *ArtifactEventHandler) 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 04ef73d83..816da7de1 100644 --- a/src/controller/gc/callback.go +++ b/src/controller/gc/callback.go @@ -52,7 +52,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 419533c42..c6c2bdc45 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 bb9c375b6..e1e50e187 100644 --- a/src/controller/p2p/preheat/controller.go +++ b/src/controller/p2p/preheat/controller.go @@ -495,7 +495,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..f068cb71a 100644 --- a/src/controller/project/controller.go +++ b/src/controller/project/controller.go @@ -150,9 +150,9 @@ 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 } + // else + 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 30a06aead..91ce4a5ba 100644 --- a/src/controller/proxy/controller.go +++ b/src/controller/proxy/controller.go @@ -101,7 +101,7 @@ 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) { + if errors.Is(err, cache.ErrNotFound) { // nolint:revive // skip to update digest, continue } else if err != nil { // for other error, return @@ -260,7 +260,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 9843a2e5a..67f6d5cbd 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 ceb690104..421f3bc70 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 29748b15f..570c6ab14 100644 --- a/src/controller/quota/controller.go +++ b/src/controller/quota/controller.go @@ -464,7 +464,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) diff --git a/src/controller/quota/driver/project/project.go b/src/controller/quota/driver/project/project.go index 637cdfda9..4f84d0804 100644 --- a/src/controller/quota/driver/project/project.go +++ b/src/controller/quota/driver/project/project.go @@ -43,7 +43,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/systemartifact/callback.go b/src/controller/systemartifact/callback.go index a0f6bf7d2..1c5f76a9d 100644 --- a/src/controller/systemartifact/callback.go +++ b/src/controller/systemartifact/callback.go @@ -37,7 +37,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 3e1aa93e7..60118676a 100644 --- a/src/controller/systeminfo/controller.go +++ b/src/controller/systeminfo/controller.go @@ -147,7 +147,7 @@ func OIDCProviderName(cfg map[string]interface{}) string { return utils.SafeCastString(cfg[common.OIDCName]) } -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() } @@ -158,14 +158,15 @@ func (c *controller) GetCA(ctx context.Context) (io.ReadCloser, error) { if len(testRootCertPath) > 0 { path = testRootCertPath } - if _, err := os.Stat(path); err == nil { + _, err := os.Stat(path) + if 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 } + // else + 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 5b9489f80..1c03914da 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 20d21bc50..f36da85f2 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..261cdb8cb 100644 --- a/src/core/auth/authproxy/auth.go +++ b/src/core/auth/authproxy/auth.go @@ -102,13 +102,13 @@ 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)) } + // 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)) } func (a *Auth) tokenReview(ctx context.Context, sessionID string) (*models.User, error) { @@ -191,7 +191,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..8c70f90e1 100644 --- a/src/core/auth/authproxy/test/server.go +++ b/src/core/auth/authproxy/test/server.go @@ -58,9 +58,9 @@ 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 } + // else + return } } http.Error(rw, fmt.Sprintf("Do not find entry in entrylist, username: %s", html.EscapeString(u)), http.StatusUnauthorized) @@ -89,9 +89,9 @@ 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 } + // 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 3f6c634b7..a348c7600 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 b07cd708b..3ae944e70 100644 --- a/src/core/auth/oidc/oidc.go +++ b/src/core/auth/oidc/oidc.go @@ -30,7 +30,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, @@ -38,7 +38,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 b71e07d04..a689edffa 100644 --- a/src/core/service/token/creator.go +++ b/src/core/service/token/creator.go @@ -124,7 +124,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 d76f8c01f..77b57f826 100644 --- a/src/core/session/session.go +++ b/src/core/session/session.go @@ -46,7 +46,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 @@ -54,7 +54,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 { @@ -64,7 +64,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) @@ -72,7 +72,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{}) @@ -80,12 +80,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 @@ -192,11 +192,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/jobservice/job/impl/gc/garbage_collection.go b/src/jobservice/job/impl/gc/garbage_collection.go index d3d7646ec..7ae9a0b68 100644 --- a/src/jobservice/job/impl/gc/garbage_collection.go +++ b/src/jobservice/job/impl/gc/garbage_collection.go @@ -91,7 +91,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 e16361298..fec8d0eb9 100644 --- a/src/jobservice/job/impl/notification/webhook_job.go +++ b/src/jobservice/job/impl/notification/webhook_job.go @@ -60,7 +60,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 } @@ -98,7 +98,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 cfc3dc30b..59131456e 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 76d1867c9..93dcb4d9d 100644 --- a/src/jobservice/job/impl/scandataexport/scan_data_export.go +++ b/src/jobservice/job/impl/scandataexport/scan_data_export.go @@ -71,7 +71,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 } diff --git a/src/jobservice/job/impl/systemartifact/cleanup.go b/src/jobservice/job/impl/systemartifact/cleanup.go index 405a41016..5b0461746 100644 --- a/src/jobservice/job/impl/systemartifact/cleanup.go +++ b/src/jobservice/job/impl/systemartifact/cleanup.go @@ -35,11 +35,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 80830273a..9810ee27d 100644 --- a/src/jobservice/logger/getter_factory.go +++ b/src/jobservice/logger/getter_factory.go @@ -41,6 +41,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..5237e6348 100644 --- a/src/jobservice/runner/redis.go +++ b/src/jobservice/runner/redis.go @@ -95,11 +95,11 @@ 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 } + // 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 } // Log error and exit diff --git a/src/jobservice/runtime/bootstrap.go b/src/jobservice/runtime/bootstrap.go index bd2aabd7c..4e356523f 100644 --- a/src/jobservice/runtime/bootstrap.go +++ b/src/jobservice/runtime/bootstrap.go @@ -347,15 +347,16 @@ 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 } + // else + return pool } diff --git a/src/jobservice/worker/cworker/c_worker.go b/src/jobservice/worker/cworker/c_worker.go index 2d2043162..2063e74cd 100644 --- a/src/jobservice/worker/cworker/c_worker.go +++ b/src/jobservice/worker/cworker/c_worker.go @@ -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/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 75ca6a3be..0755b5973 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 ebee6f37d..da938a7fb 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/pool.go b/src/lib/redis/pool.go index 5995a43d1..337375abe 100644 --- a/src/lib/redis/pool.go +++ b/src/lib/redis/pool.go @@ -102,9 +102,9 @@ 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) { 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 88b20931a..19b18491b 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 6b465982b..025166f0d 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 dd623a899..75215af1c 100644 --- a/src/pkg/config/manager.go +++ b/src/pkg/config/manager.go @@ -136,7 +136,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) @@ -146,7 +146,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 99c68d361..c7368c4c0 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 904e36ebe..824e00f97 100644 --- a/src/pkg/exporter/exporter.go +++ b/src/pkg/exporter/exporter.go @@ -82,7 +82,7 @@ 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) { 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 ab18633a4..ff97f8345 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 e7061bb46..a4322cf3e 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 ddf525d34..7886673e4 100644 --- a/src/pkg/jobmonitor/redis.go +++ b/src/pkg/jobmonitor/redis.go @@ -126,7 +126,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 { @@ -146,13 +146,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() @@ -161,7 +161,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 07d0b463b..a6b11720f 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 307371364..48753868e 100644 --- a/src/pkg/ldap/manager.go +++ b/src/pkg/ldap/manager.go @@ -49,11 +49,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 @@ -133,7 +133,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 713358942..1b4b9e411 100644 --- a/src/pkg/member/dao/dao.go +++ b/src/pkg/member/dao/dao.go @@ -111,7 +111,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 16ebb9aad..bed42902e 100644 --- a/src/pkg/notifier/event/event.go +++ b/src/pkg/notifier/event/event.go @@ -77,7 +77,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 f11ba81f0..433bad20e 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 0b439c6ce..d353c4daf 100644 --- a/src/pkg/oidc/testutils.go +++ b/src/pkg/oidc/testutils.go @@ -26,7 +26,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 7645da743..cb639171d 100644 --- a/src/pkg/p2p/preheat/provider/auth/none_handler.go +++ b/src/pkg/p2p/preheat/provider/auth/none_handler.go @@ -28,7 +28,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/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 dc0ef51be..8a878fdc0 100644 --- a/src/pkg/quota/types/resources.go +++ b/src/pkg/quota/types/resources.go @@ -50,7 +50,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 588cbe5d6..a0c66d949 100644 --- a/src/pkg/reg/adapter/aliacr/adapter.go +++ b/src/pkg/reg/adapter/aliacr/adapter.go @@ -339,7 +339,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 0a4e6a4ba..fa6adddaa 100644 --- a/src/pkg/reg/adapter/githubcr/adapter.go +++ b/src/pkg/reg/adapter/githubcr/adapter.go @@ -207,6 +207,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..2037aedc6 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) + lenth, _ := strconv.Atoi(contentLen) - return exist, &distribution.Descriptor{MediaType: contentType, Size: int64(len)}, nil + return exist, &distribution.Descriptor{MediaType: contentType, Size: int64(lenth)}, 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..af3d95186 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 + lenth, _ := strconv.Atoi(contentLen) + return true, &distribution.Descriptor{Digest: digest.Digest(dig), MediaType: contentType, Size: int64(lenth)}, 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/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/export/filter_processor.go b/src/pkg/scan/export/filter_processor.go index cebbb1e2c..a58e2052b 100644 --- a/src/pkg/scan/export/filter_processor.go +++ b/src/pkg/scan/export/filter_processor.go @@ -160,7 +160,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 3acea71dd..538b75ce7 100644 --- a/src/pkg/scan/postprocessors/report_converters.go +++ b/src/pkg/scan/postprocessors/report_converters.go @@ -98,7 +98,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 { @@ -198,7 +198,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/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/securityhub/dao/security.go b/src/pkg/securityhub/dao/security.go index f3dded04e..03506d28a 100644 --- a/src/pkg/securityhub/dao/security.go +++ b/src/pkg/securityhub/dao/security.go @@ -122,7 +122,7 @@ var filterMap = map[string]*filterMetaData{ var applyFilterFunc func(ctx context.Context, key string, query *q.Query) (sqlStr string, params []interface{}) -func exactMatchFilter(ctx context.Context, key string, query *q.Query) (sqlStr string, params []interface{}) { +func exactMatchFilter(_ context.Context, key string, query *q.Query) (sqlStr string, params []interface{}) { if query == nil { return } @@ -138,7 +138,7 @@ func exactMatchFilter(ctx context.Context, key string, query *q.Query) (sqlStr s return } -func rangeFilter(ctx context.Context, key string, query *q.Query) (sqlStr string, params []interface{}) { +func rangeFilter(_ context.Context, key string, query *q.Query) (sqlStr string, params []interface{}) { if query == nil { return } @@ -151,7 +151,7 @@ func rangeFilter(ctx context.Context, key string, query *q.Query) (sqlStr string return } -func tagFilter(ctx context.Context, key string, query *q.Query) (sqlStr string, params []interface{}) { +func tagFilter(ctx context.Context, _ string, query *q.Query) (sqlStr string, params []interface{}) { if query == nil { return } @@ -206,7 +206,7 @@ func (d *dao) TotalArtifactsCount(ctx context.Context, projectID int64) (int64, return count, err } -func (d *dao) Summary(ctx context.Context, scannerUUID string, projectID int64, query *q.Query) (*model.Summary, error) { +func (d *dao) Summary(ctx context.Context, scannerUUID string, projectID int64, _ *q.Query) (*model.Summary, error) { if len(scannerUUID) == 0 || projectID != 0 { return nil, nil } @@ -224,7 +224,7 @@ func (d *dao) Summary(ctx context.Context, scannerUUID string, projectID int64, &sum.FixableCnt) return &sum, err } -func (d *dao) DangerousArtifacts(ctx context.Context, scannerUUID string, projectID int64, query *q.Query) ([]*model.DangerousArtifact, error) { +func (d *dao) DangerousArtifacts(ctx context.Context, scannerUUID string, projectID int64, _ *q.Query) ([]*model.DangerousArtifact, error) { if len(scannerUUID) == 0 || projectID != 0 { return nil, nil } @@ -237,7 +237,7 @@ func (d *dao) DangerousArtifacts(ctx context.Context, scannerUUID string, projec return artifacts, err } -func (d *dao) ScannedArtifactsCount(ctx context.Context, scannerUUID string, projectID int64, query *q.Query) (int64, error) { +func (d *dao) ScannedArtifactsCount(ctx context.Context, scannerUUID string, projectID int64, _ *q.Query) (int64, error) { if len(scannerUUID) == 0 || projectID != 0 { return 0, nil } @@ -249,7 +249,7 @@ func (d *dao) ScannedArtifactsCount(ctx context.Context, scannerUUID string, pro err = o.Raw(scannedArtifactCountSQL, scannerUUID).QueryRow(&cnt) return cnt, err } -func (d *dao) DangerousCVEs(ctx context.Context, scannerUUID string, projectID int64, query *q.Query) ([]*scan.VulnerabilityRecord, error) { +func (d *dao) DangerousCVEs(ctx context.Context, scannerUUID string, projectID int64, _ *q.Query) ([]*scan.VulnerabilityRecord, error) { if len(scannerUUID) == 0 || projectID != 0 { return nil, nil } @@ -266,7 +266,7 @@ func countSQL(strSQL string) string { return fmt.Sprintf(`select count(1) cnt from (%v) as t`, strSQL) } -func (d *dao) CountVulnerabilities(ctx context.Context, registrationUUID string, projectID int64, tuneCount bool, query *q.Query) (int64, error) { +func (d *dao) CountVulnerabilities(ctx context.Context, registrationUUID string, _ int64, tuneCount bool, query *q.Query) (int64, error) { o, err := orm.FromContext(ctx) if err != nil { return 0, err @@ -307,7 +307,7 @@ func (d *dao) countExceedLimit(ctx context.Context, sqlStr string, params []inte return exceed, nil } -func (d *dao) ListVulnerabilities(ctx context.Context, registrationUUID string, projectID int64, query *q.Query) ([]*model.VulnerabilityItem, error) { +func (d *dao) ListVulnerabilities(ctx context.Context, registrationUUID string, _ int64, query *q.Query) ([]*model.VulnerabilityItem, error) { o, err := orm.FromContext(ctx) if err != nil { return nil, err 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 fb52b74af..177f6bee3 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/quota/post_initiate_blob_upload.go b/src/server/middleware/quota/post_initiate_blob_upload.go index efeb8dd33..275ac48b3 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/repoproxy/proxy.go b/src/server/middleware/repoproxy/proxy.go index 78e0e6c07..5fb44a681 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/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 165478582..84d78cc5d 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) } 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 916408f09..b0e4e6958 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 88cf97cb1..5e5c36697 100644 --- a/src/server/v2.0/handler/gc.go +++ b/src/server/v2.0/handler/gc.go @@ -47,7 +47,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 } @@ -158,7 +158,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 e92dfd1b5..2de7f562f 100644 --- a/src/server/v2.0/handler/handler.go +++ b/src/server/v2.0/handler/handler.go @@ -87,7 +87,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 } @@ -96,6 +96,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 cb75625f7..36995a936 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/scanner.go b/src/server/v2.0/handler/model/scanner.go index 9218c4c3a..34d7e6b92 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/permissions.go b/src/server/v2.0/handler/permissions.go index 9d258dc44..d90ad608b 100644 --- a/src/server/v2.0/handler/permissions.go +++ b/src/server/v2.0/handler/permissions.go @@ -42,7 +42,7 @@ func newPermissionsAPIAPI() *permissionsAPI { } } -func (p *permissionsAPI) GetPermissions(ctx context.Context, params permissions.GetPermissionsParams) middleware.Responder { +func (p *permissionsAPI) GetPermissions(ctx context.Context, _ permissions.GetPermissionsParams) middleware.Responder { secCtx, ok := security.FromContext(ctx) if !ok { return p.SendError(ctx, errors.UnauthorizedError(errors.New("security context not found"))) diff --git a/src/server/v2.0/handler/ping.go b/src/server/v2.0/handler/ping.go index 2fd4ad7a5..6e9e5f2a9 100644 --- a/src/server/v2.0/handler/ping.go +++ b/src/server/v2.0/handler/ping.go @@ -30,6 +30,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 9a8f70ad6..2fcf64e14 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..07023fecf 100644 --- a/src/server/v2.0/handler/project_metadata.go +++ b/src/server/v2.0/handler/project_metadata.go @@ -138,8 +138,8 @@ func (p *projectMetadataAPI) validate(metas map[string]string) (map[string]strin } key, value := "", "" - for key, value = range metas { - } + // 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 564d94c6c..64d117aed 100644 --- a/src/server/v2.0/handler/purge.go +++ b/src/server/v2.0/handler/purge.go @@ -256,7 +256,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 d365e2222..2f864aedc 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 e58108241..afe207abe 100644 --- a/src/server/v2.0/handler/retention.go +++ b/src/server/v2.0/handler/retention.go @@ -133,7 +133,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) } @@ -141,7 +141,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 1ae867ac8..3e9ed1bf0 100644 --- a/src/server/v2.0/handler/scan_all.go +++ b/src/server/v2.0/handler/scan_all.go @@ -58,12 +58,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) } @@ -158,7 +158,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) } @@ -170,7 +170,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) } @@ -182,7 +182,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 e31955c3e..520c66f81 100644 --- a/src/server/v2.0/handler/scanexport.go +++ b/src/server/v2.0/handler/scanexport.go @@ -58,7 +58,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 } @@ -90,8 +90,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}} + err := &models.Error{Message: fmt.Sprintf("User : %s not found", secContext.GetUsername())} + errors := &models.Errors{Errors: []*models.Error{err}} return operation.NewExportScanDataForbidden().WithPayload(errors) } @@ -216,7 +216,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 1e51db796..382819c80 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 5d7e46f95..229e7872a 100644 --- a/src/server/v2.0/handler/systeminfo.go +++ b/src/server/v2.0/handler/systeminfo.go @@ -38,7 +38,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() { @@ -51,7 +51,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) @@ -59,7 +59,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 759b7b8a5..1bbe3b7ad 100644 --- a/src/server/v2.0/handler/user.go +++ b/src/server/v2.0/handler/user.go @@ -193,7 +193,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 941343b0d..773864b9f 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/tests/ci/distro_installer.sh b/tests/ci/distro_installer.sh index f97449d84..b946b461a 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=golang:1.21.4 COMPILETAG=compile_golangimage 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=golang:1.21.4 COMPILETAG=compile_golangimage 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=golang:1.21.5 COMPILETAG=compile_golangimage 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=golang:1.21.5 COMPILETAG=compile_golangimage TRIVYFLAG=true HTTPPROXY= PULL_BASE_FROM_DOCKERHUB=false diff --git a/tests/ci/ut_install.sh b/tests/ci/ut_install.sh index b0954ecf5..38cfa8cf2 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.55.2 sudo service postgresql stop || echo no postgresql need to be stopped sleep 2