diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index da8aa2932..66d26df8c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -41,10 +41,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.22 + - name: Set up Go 1.23 uses: actions/setup-go@v5 with: - go-version: 1.22.3 + go-version: 1.23.2 id: go - uses: actions/checkout@v3 with: @@ -102,10 +102,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.22 + - name: Set up Go 1.23 uses: actions/setup-go@v5 with: - go-version: 1.22.3 + go-version: 1.23.2 id: go - uses: actions/checkout@v3 with: @@ -157,10 +157,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.22 + - name: Set up Go 1.23 uses: actions/setup-go@v5 with: - go-version: 1.22.3 + go-version: 1.23.2 id: go - uses: actions/checkout@v3 with: @@ -212,10 +212,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.22 + - name: Set up Go 1.23 uses: actions/setup-go@v5 with: - go-version: 1.22.3 + go-version: 1.23.2 id: go - uses: actions/checkout@v3 with: @@ -265,10 +265,10 @@ jobs: - ubuntu-latest timeout-minutes: 100 steps: - - name: Set up Go 1.22 + - name: Set up Go 1.23 uses: actions/setup-go@v5 with: - go-version: 1.22.3 + go-version: 1.23.2 id: go - uses: actions/checkout@v3 with: diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml index febfd494e..99fcfad12 100644 --- a/.github/workflows/build-package.yml +++ b/.github/workflows/build-package.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Go 1.22 uses: actions/setup-go@v5 with: - go-version: 1.22.3 + go-version: 1.23.2 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 8866a46be..db6725c2c 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.22.3 + go-version: 1.23.2 id: go - uses: actions/checkout@v3 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dabf434bb..fd5dea993 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -142,30 +142,31 @@ The folder graph below shows the structure of the source code folder `harbor/src #### Go Harbor backend is written in [Go](http://golang.org/). If you don't have a Harbor backend service development environment, please [set one up](https://golang.org/doc/install). -| Harbor | Requires Go | -|----------|---------------| -| 1.1 | 1.7.3 | -| 1.2 | 1.7.3 | -| 1.3 | 1.9.2 | -| 1.4 | 1.9.2 | -| 1.5 | 1.9.2 | -| 1.6 | 1.9.2 | -| 1.7 | 1.9.2 | -| 1.8 | 1.11.2 | -| 1.9 | 1.12.12 | -| 1.10 | 1.12.12 | -| 2.0 | 1.13.15 | -| 2.1 | 1.14.13 | -| 2.2 | 1.15.6 | -| 2.3 | 1.15.12 | -| 2.4 | 1.17.7 | -| 2.5 | 1.17.7 | -| 2.6 | 1.18.6 | -| 2.7 | 1.19.4 | -| 2.8 | 1.20.6 | -| 2.9 | 1.21.3 | -| 2.10 | 1.21.8 | -| 2.11 | 1.22.3 | +| Harbor | Requires Go | +|--------|-------------| +| 1.1 | 1.7.3 | +| 1.2 | 1.7.3 | +| 1.3 | 1.9.2 | +| 1.4 | 1.9.2 | +| 1.5 | 1.9.2 | +| 1.6 | 1.9.2 | +| 1.7 | 1.9.2 | +| 1.8 | 1.11.2 | +| 1.9 | 1.12.12 | +| 1.10 | 1.12.12 | +| 2.0 | 1.13.15 | +| 2.1 | 1.14.13 | +| 2.2 | 1.15.6 | +| 2.3 | 1.15.12 | +| 2.4 | 1.17.7 | +| 2.5 | 1.17.7 | +| 2.6 | 1.18.6 | +| 2.7 | 1.19.4 | +| 2.8 | 1.20.6 | +| 2.9 | 1.21.3 | +| 2.10 | 1.21.8 | +| 2.11 | 1.22.3 | +| 2.12 | 1.23.2 | Ensure your GOPATH and PATH have been configured in accordance with the Go environment instructions. diff --git a/Makefile b/Makefile index aff2fdb94..fe354c40d 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ GOINSTALL=$(GOCMD) install GOTEST=$(GOCMD) test GODEP=$(GOTEST) -i GOFMT=gofmt -w -GOBUILDIMAGE=golang:1.22.3 +GOBUILDIMAGE=golang:1.23.2 GOBUILDPATHINCONTAINER=/harbor # go build @@ -312,7 +312,7 @@ gen_apis: lint_apis MOCKERY_IMAGENAME=$(IMAGENAMESPACE)/mockery -MOCKERY_VERSION=v2.43.2 +MOCKERY_VERSION=v2.46.2 MOCKERY=$(RUNCONTAINER)/src ${MOCKERY_IMAGENAME}:${MOCKERY_VERSION} MOCKERY_IMAGE_BUILD_CMD=${DOCKERBUILD} -f ${TOOLSPATH}/mockery/Dockerfile --build-arg GOLANG=${GOBUILDIMAGE} --build-arg MOCKERY_VERSION=${MOCKERY_VERSION} -t ${MOCKERY_IMAGENAME}:$(MOCKERY_VERSION) . diff --git a/make/photon/registry/Dockerfile.binary b/make/photon/registry/Dockerfile.binary index 0098691be..cdc312e03 100644 --- a/make/photon/registry/Dockerfile.binary +++ b/make/photon/registry/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.22.3 +FROM golang:1.23.2 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 84d7c1ce0..61bfdeef0 100644 --- a/make/photon/trivy-adapter/Dockerfile.binary +++ b/make/photon/trivy-adapter/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.22.3 +FROM golang:1.23.2 ADD . /go/src/github.com/goharbor/harbor-scanner-trivy/ WORKDIR /go/src/github.com/goharbor/harbor-scanner-trivy/ diff --git a/make/photon/trivy-adapter/builder.sh b/make/photon/trivy-adapter/builder.sh index b70499b38..eba579960 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/goharbor/harbor-scanner-trivy.git $TEMP cd $TEMP; git checkout $VERSION; cd - -echo "Building Trivy adapter binary based on golang:1.22.3..." +echo "Building Trivy adapter binary based on golang:1.23.2..." cp Dockerfile.binary $TEMP docker build -f $TEMP/Dockerfile.binary -t trivy-adapter-golang $TEMP diff --git a/src/common/rbac/project/evaluator.go b/src/common/rbac/project/evaluator.go index bba793acf..38f5753c0 100644 --- a/src/common/rbac/project/evaluator.go +++ b/src/common/rbac/project/evaluator.go @@ -58,7 +58,7 @@ func NewBuilderForUser(user *models.User, ctl project.Controller) RBACUserBuilde // NewBuilderForPolicies create a builder for the policies func NewBuilderForPolicies(username string, policies []*types.Policy, filters ...func(*proModels.Project, []*types.Policy) []*types.Policy) RBACUserBuilder { - return func(ctx context.Context, p *proModels.Project) types.RBACUser { + return func(_ context.Context, p *proModels.Project) types.RBACUser { for _, filter := range filters { policies = filter(p, policies) } diff --git a/src/common/rbac/system/evaluator.go b/src/common/rbac/system/evaluator.go index e16ab1067..02d33e2cf 100644 --- a/src/common/rbac/system/evaluator.go +++ b/src/common/rbac/system/evaluator.go @@ -25,7 +25,7 @@ import ( // NewEvaluator create evaluator for the system func NewEvaluator(username string, policies []*types.Policy) evaluator.Evaluator { - return namespace.New(NamespaceKind, func(ctx context.Context, ns types.Namespace) evaluator.Evaluator { + return namespace.New(NamespaceKind, func(_ context.Context, _ types.Namespace) evaluator.Evaluator { return rbac.New(&rbacUser{ username: username, policies: policies, diff --git a/src/controller/artifact/annotation/v1alpha1.go b/src/controller/artifact/annotation/v1alpha1.go index 6ca4605e1..df88e42ee 100644 --- a/src/controller/artifact/annotation/v1alpha1.go +++ b/src/controller/artifact/annotation/v1alpha1.go @@ -106,7 +106,7 @@ func parseV1alpha1Icon(artifact *artifact.Artifact, manifest *v1.Manifest, reg r switch contentType { case GIF, PNG, JPEG: default: - return errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("unsupported content type: %s", contentType) + return errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("unsupported content type: %s", contentType) } artifact.Icon = iconDigest return nil diff --git a/src/controller/artifact/controller.go b/src/controller/artifact/controller.go index 4bcea401f..f7c7cfd26 100644 --- a/src/controller/artifact/controller.go +++ b/src/controller/artifact/controller.go @@ -307,7 +307,7 @@ func (c *controller) getByTag(ctx context.Context, repository, tag string, optio } if len(tags) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("artifact %s:%s not found", repository, tag) + WithMessagef("artifact %s:%s not found", repository, tag) } return c.Get(ctx, tags[0].ArtifactID, option) } diff --git a/src/controller/artifact/processor/base/index.go b/src/controller/artifact/processor/base/index.go index 985e5c782..3262b41ce 100644 --- a/src/controller/artifact/processor/base/index.go +++ b/src/controller/artifact/processor/base/index.go @@ -44,7 +44,7 @@ func (m *IndexProcessor) AbstractMetadata(_ context.Context, _ *artifact.Artifac // AbstractAddition abstracts the addition of artifact 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) + WithMessagef("addition %s isn't supported", addition) } // GetArtifactType returns the artifact type diff --git a/src/controller/artifact/processor/base/manifest.go b/src/controller/artifact/processor/base/manifest.go index 2b7d960e8..ad6e7cda1 100644 --- a/src/controller/artifact/processor/base/manifest.go +++ b/src/controller/artifact/processor/base/manifest.go @@ -66,7 +66,7 @@ func (m *ManifestProcessor) AbstractMetadata(ctx context.Context, artifact *arti // AbstractAddition abstracts the addition of artifact 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) + WithMessagef("addition %s isn't supported", addition) } // GetArtifactType returns the artifact type diff --git a/src/controller/artifact/processor/chart/chart.go b/src/controller/artifact/processor/chart/chart.go index e7df72b56..131ed7298 100644 --- a/src/controller/artifact/processor/chart/chart.go +++ b/src/controller/artifact/processor/chart/chart.go @@ -61,7 +61,7 @@ type processor struct { 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) + WithMessagef("addition %s isn't supported for %s", addition, ArtifactTypeChart) } m, _, err := p.RegCli.PullManifest(artifact.RepositoryName, artifact.Digest) diff --git a/src/controller/artifact/processor/default.go b/src/controller/artifact/processor/default.go index af97b1b0f..5cb2ad175 100644 --- a/src/controller/artifact/processor/default.go +++ b/src/controller/artifact/processor/default.go @@ -132,5 +132,5 @@ func (d *defaultProcessor) AbstractAddition(_ context.Context, artifact *artifac // It will be support in the future. // return error directly return nil, errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("the processor for artifact %s not found, cannot get the addition", artifact.Type) + WithMessagef("the processor for artifact %s not found, cannot get the addition", artifact.Type) } diff --git a/src/controller/artifact/processor/image/manifest_v1.go b/src/controller/artifact/processor/image/manifest_v1.go index 3b03876b7..8179ad81e 100644 --- a/src/controller/artifact/processor/image/manifest_v1.go +++ b/src/controller/artifact/processor/image/manifest_v1.go @@ -52,7 +52,7 @@ func (m *manifestV1Processor) AbstractMetadata(_ context.Context, artifact *arti 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) + WithMessagef("addition %s isn't supported for %s(manifest version 1)", addition, ArtifactTypeImage) } func (m *manifestV1Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string { diff --git a/src/controller/artifact/processor/image/manifest_v2.go b/src/controller/artifact/processor/image/manifest_v2.go index 2948dac74..b88c2c2b4 100644 --- a/src/controller/artifact/processor/image/manifest_v2.go +++ b/src/controller/artifact/processor/image/manifest_v2.go @@ -87,7 +87,7 @@ func (m *manifestV2Processor) AbstractMetadata(ctx context.Context, artifact *ar func (m *manifestV2Processor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*processor.Addition, error) { if addition != AdditionTypeBuildHistory { return nil, errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("addition %s isn't supported for %s(manifest version 2)", addition, ArtifactTypeImage) + WithMessagef("addition %s isn't supported for %s(manifest version 2)", addition, ArtifactTypeImage) } mani, _, err := m.RegCli.PullManifest(artifact.RepositoryName, artifact.Digest) diff --git a/src/controller/artifact/processor/wasm/wasm.go b/src/controller/artifact/processor/wasm/wasm.go index be6cba8e4..1118ef470 100644 --- a/src/controller/artifact/processor/wasm/wasm.go +++ b/src/controller/artifact/processor/wasm/wasm.go @@ -103,7 +103,7 @@ func (m *Processor) AbstractMetadata(ctx context.Context, art *artifact.Artifact func (m *Processor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*processor.Addition, error) { if addition != AdditionTypeBuildHistory { return nil, errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("addition %s isn't supported for %s(manifest version 2)", addition, ArtifactTypeWASM) + WithMessagef("addition %s isn't supported for %s(manifest version 2)", addition, ArtifactTypeWASM) } mani, _, err := m.RegCli.PullManifest(artifact.RepositoryName, artifact.Digest) diff --git a/src/controller/blob/controller.go b/src/controller/blob/controller.go index f59a457ff..46df973e3 100644 --- a/src/controller/blob/controller.go +++ b/src/controller/blob/controller.go @@ -248,7 +248,7 @@ func (c *controller) Get(ctx context.Context, digest string, options ...Option) if err != nil { return nil, err } else if len(blobs) == 0 { - return nil, errors.NotFoundError(nil).WithMessage("blob %s not found", digest) + return nil, errors.NotFoundError(nil).WithMessagef("blob %s not found", digest) } return blobs[0], nil @@ -363,7 +363,7 @@ func (c *controller) Touch(ctx context.Context, blob *blob.Blob) error { return err } if count == 0 { - return errors.New(nil).WithMessage(fmt.Sprintf("no blob item is updated to StatusNone, id:%d, digest:%s", blob.ID, blob.Digest)).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("no blob item is updated to StatusNone, id:%d, digest:%s", blob.ID, blob.Digest).WithCode(errors.NotFoundCode) } return nil } @@ -375,7 +375,7 @@ func (c *controller) Fail(ctx context.Context, blob *blob.Blob) error { return err } if count == 0 { - return errors.New(nil).WithMessage(fmt.Sprintf("no blob item is updated to StatusDeleteFailed, id:%d, digest:%s", blob.ID, blob.Digest)).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("no blob item is updated to StatusDeleteFailed, id:%d, digest:%s", blob.ID, blob.Digest).WithCode(errors.NotFoundCode) } return nil } diff --git a/src/controller/config/controller.go b/src/controller/config/controller.go index c424b2659..5302804aa 100644 --- a/src/controller/config/controller.go +++ b/src/controller/config/controller.go @@ -182,11 +182,11 @@ func verifyValueLengthCfg(_ context.Context, cfgs map[string]interface{}) error // the cfgs is unmarshal from json string, the number type will be float64 if vf, ok := v.(float64); ok { if vf <= 0 { - return errors.BadRequestError(nil).WithMessage("the %s value must be positive", c) + return errors.BadRequestError(nil).WithMessagef("the %s value must be positive", c) } if int64(vf) > maxValue { - return errors.BadRequestError(nil).WithMessage(fmt.Sprintf("the %s value is over the limit value: %d", c, maxValue)) + return errors.BadRequestError(nil).WithMessagef("the %s value is over the limit value: %d", c, maxValue) } } } diff --git a/src/controller/gc/controller.go b/src/controller/gc/controller.go index 8ade07f3f..5de9be5e5 100644 --- a/src/controller/gc/controller.go +++ b/src/controller/gc/controller.go @@ -139,7 +139,7 @@ func (c *controller) GetExecution(ctx context.Context, id int64) (*Execution, er } if len(execs) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("garbage collection execution %d not found", id) + WithMessagef("garbage collection execution %d not found", id) } return convertExecution(execs[0]), nil } @@ -157,7 +157,7 @@ func (c *controller) GetTask(ctx context.Context, id int64) (*Task, error) { } if len(tasks) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("garbage collection task %d not found", id) + WithMessagef("garbage collection task %d not found", id) } return convertTask(tasks[0]), nil } diff --git a/src/controller/icon/controller.go b/src/controller/icon/controller.go index c2f950544..f9787ce90 100644 --- a/src/controller/icon/controller.go +++ b/src/controller/icon/controller.go @@ -143,7 +143,7 @@ func (c *controller) Get(ctx context.Context, digest string) (*Icon, error) { } if len(artifacts) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("the icon %s not found", digest) + WithMessagef("the icon %s not found", digest) } _, iconFile, err = c.regCli.PullBlob(artifacts[0].RepositoryName, digest) if err != nil { diff --git a/src/controller/member/controller.go b/src/controller/member/controller.go index c53d49232..0ad32164e 100644 --- a/src/controller/member/controller.go +++ b/src/controller/member/controller.go @@ -135,20 +135,20 @@ func (c *controller) Create(ctx context.Context, projectNameOrID interface{}, re if req.MemberUser.UserID > 0 { user, err := c.userManager.Get(ctx, req.MemberUser.UserID) if err != nil { - return 0, errors.BadRequestError(nil).WithMessage("Failed to get user %d: %v", req.MemberUser.UserID, err) + return 0, errors.BadRequestError(nil).WithMessagef("Failed to get user %d: %v", req.MemberUser.UserID, err) } if user == nil { - return 0, errors.BadRequestError(nil).WithMessage("User %d not found", req.MemberUser.UserID) + return 0, errors.BadRequestError(nil).WithMessagef("User %d not found", req.MemberUser.UserID) } member.EntityID = req.MemberUser.UserID member.EntityType = common.UserMember } else if req.MemberGroup.ID > 0 { g, err := c.groupManager.Get(ctx, req.MemberGroup.ID) if err != nil { - return 0, errors.BadRequestError(nil).WithMessage("Failed to get group %d: %v", req.MemberGroup.ID, err) + return 0, errors.BadRequestError(nil).WithMessagef("Failed to get group %d: %v", req.MemberGroup.ID, err) } if g == nil { - return 0, errors.BadRequestError(nil).WithMessage("Group %d not found", req.MemberGroup.ID) + return 0, errors.BadRequestError(nil).WithMessagef("Group %d not found", req.MemberGroup.ID) } member.EntityID = req.MemberGroup.ID } else if len(req.MemberUser.Username) > 0 { diff --git a/src/controller/p2p/preheat/controller.go b/src/controller/p2p/preheat/controller.go index e1e50e187..65f80ebf1 100644 --- a/src/controller/p2p/preheat/controller.go +++ b/src/controller/p2p/preheat/controller.go @@ -219,7 +219,7 @@ func (c *controller) DeleteInstance(ctx context.Context, id int64) error { if len(policies) > 0 { return errors.New(nil). WithCode(errors.PreconditionCode). - WithMessage("Provider [%s] cannot be deleted as some preheat policies are using it", ins.Name) + WithMessagef("Provider [%s] cannot be deleted as some preheat policies are using it", ins.Name) } return c.iManager.Delete(ctx, id) @@ -246,7 +246,7 @@ func (c *controller) UpdateInstance(ctx context.Context, instance *providerModel if len(policies) > 0 { return errors.New(nil). WithCode(errors.PreconditionCode). - WithMessage("Provider [%s] cannot be disabled as some preheat policies are using it", oldIns.Name) + WithMessagef("Provider [%s] cannot be disabled as some preheat policies are using it", oldIns.Name) } } diff --git a/src/controller/quota/controller.go b/src/controller/quota/controller.go index 570c6ab14..a04894c66 100644 --- a/src/controller/quota/controller.go +++ b/src/controller/quota/controller.go @@ -349,7 +349,7 @@ func (c *controller) updateUsageWithRetry(ctx context.Context, reference, refere options := []retry.Option{ retry.Timeout(defaultRetryTimeout), retry.Backoff(false), - retry.Callback(func(err error, sleep time.Duration) { + retry.Callback(func(err error, _ time.Duration) { log.G(ctx).Debugf("failed to update the quota usage for %s %s, error: %v", reference, referenceID, err) }), } @@ -488,7 +488,7 @@ func reserveResources(resources types.ResourceList) func(hardLimits, used types. newUsed := types.Add(used, resources) if err := quota.IsSafe(hardLimits, used, newUsed, false); err != nil { - return nil, errors.DeniedError(err).WithMessage("Quota exceeded when processing the request of %v", err) + return nil, errors.DeniedError(err).WithMessagef("Quota exceeded when processing the request of %v", err) } return newUsed, nil @@ -496,7 +496,7 @@ func reserveResources(resources types.ResourceList) func(hardLimits, used types. } func rollbackResources(resources types.ResourceList) func(hardLimits, used types.ResourceList) (types.ResourceList, error) { - return func(hardLimits, used types.ResourceList) (types.ResourceList, error) { + return func(_, used types.ResourceList) (types.ResourceList, error) { newUsed := types.Subtract(used, resources) // ensure that new used is never negative if negativeUsed := types.IsNegative(newUsed); len(negativeUsed) > 0 { diff --git a/src/controller/quota/driver/project/util.go b/src/controller/quota/driver/project/util.go index ffc85ec4a..9efaa68f0 100644 --- a/src/controller/quota/driver/project/util.go +++ b/src/controller/quota/driver/project/util.go @@ -75,7 +75,7 @@ func getProjectsBatchFn(ctx context.Context, keys dataloader.Keys) []*dataloader for _, projectID := range projectIDs { project, ok := projectsMap[projectID] if !ok { - err := errors.NotFoundError(nil).WithMessage("project %d not found", projectID) + err := errors.NotFoundError(nil).WithMessagef("project %d not found", projectID) return handleError(err) } diff --git a/src/controller/registry/controller.go b/src/controller/registry/controller.go index b6da77209..9b40e27e5 100644 --- a/src/controller/registry/controller.go +++ b/src/controller/registry/controller.go @@ -136,7 +136,7 @@ func (c *controller) Delete(ctx context.Context, id int64) error { return err } if count > 0 { - return errors.New(nil).WithCode(errors.PreconditionCode).WithMessage("the registry %d is referenced by replication policies, cannot delete it", id) + return errors.New(nil).WithCode(errors.PreconditionCode).WithMessagef("the registry %d is referenced by replication policies, cannot delete it", id) } // referenced by replication policy as destination registry count, err = c.repMgr.Count(ctx, &q.Query{ @@ -148,7 +148,7 @@ func (c *controller) Delete(ctx context.Context, id int64) error { return err } if count > 0 { - return errors.New(nil).WithCode(errors.PreconditionCode).WithMessage("the registry %d is referenced by replication policies, cannot delete it", id) + return errors.New(nil).WithCode(errors.PreconditionCode).WithMessagef("the registry %d is referenced by replication policies, cannot delete it", id) } // referenced by proxy cache project count, err = c.proMgr.Count(ctx, &q.Query{ @@ -160,7 +160,7 @@ func (c *controller) Delete(ctx context.Context, id int64) error { return err } if count > 0 { - return errors.New(nil).WithCode(errors.PreconditionCode).WithMessage("the registry %d is referenced by proxy cache project, cannot delete it", id) + return errors.New(nil).WithCode(errors.PreconditionCode).WithMessagef("the registry %d is referenced by proxy cache project, cannot delete it", id) } return c.regMgr.Delete(ctx, id) diff --git a/src/controller/replication/execution.go b/src/controller/replication/execution.go index 95136d9d8..3c9225094 100644 --- a/src/controller/replication/execution.go +++ b/src/controller/replication/execution.go @@ -102,7 +102,7 @@ func (c *controller) Start(ctx context.Context, policy *replicationmodel.Policy, logger := log.GetLogger(ctx) if !policy.Enabled { return 0, errors.New(nil).WithCode(errors.PreconditionCode). - WithMessage("the policy %d is disabled", policy.ID) + WithMessagef("the policy %d is disabled", policy.ID) } // create an execution record extra := make(map[string]interface{}) @@ -213,7 +213,7 @@ func (c *controller) GetExecution(ctx context.Context, id int64) (*Execution, er } if len(execs) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("replication execution %d not found", id) + WithMessagef("replication execution %d not found", id) } return convertExecution(execs[0]), nil } @@ -250,7 +250,7 @@ func (c *controller) GetTask(ctx context.Context, id int64) (*Task, error) { } if len(tasks) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("replication task %d not found", id) + WithMessagef("replication task %d not found", id) } return convertTask(tasks[0]), nil } diff --git a/src/controller/replication/flow/mock_adapter_factory_test.go b/src/controller/replication/flow/mock_adapter_factory_test.go index 05d63df3f..450c10b1a 100644 --- a/src/controller/replication/flow/mock_adapter_factory_test.go +++ b/src/controller/replication/flow/mock_adapter_factory_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package flow diff --git a/src/controller/replication/flow/mock_adapter_test.go b/src/controller/replication/flow/mock_adapter_test.go index 5f7f07bcb..78d8dad3a 100644 --- a/src/controller/replication/flow/mock_adapter_test.go +++ b/src/controller/replication/flow/mock_adapter_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package flow diff --git a/src/controller/replication/flow/stage.go b/src/controller/replication/flow/stage.go index c2ad07d72..3778767b4 100644 --- a/src/controller/replication/flow/stage.go +++ b/src/controller/replication/flow/stage.go @@ -203,7 +203,7 @@ func replaceNamespace(repository string, namespace string, replaceCount int8, ds dstRepoPrefix = namespace case int(replaceCount) > srcLength-1: // invalid replace count return "", errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("the source repository %q contains only %d path components %v excepting the last one, but the destination namespace flattening level is %d", + WithMessagef("the source repository %q contains only %d path components %v excepting the last one, but the destination namespace flattening level is %d", repository, srcLength-1, srcRepoPathComponents[:srcLength-1], replaceCount) default: dstRepoPrefix = namespace + "/" + strings.Join(srcRepoPathComponents[replaceCount:srcLength-1], "/") @@ -216,12 +216,12 @@ func replaceNamespace(repository string, namespace string, replaceCount int8, ds switch dstRepoComponentPathType { case model.RepositoryPathComponentTypeOnlyTwo: if dstLength != 2 { - return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("the destination repository %q contains %d path components %v, but the destination registry only supports 2", + return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("the destination repository %q contains %d path components %v, but the destination registry only supports 2", dstRepo, dstLength, dstRepoPathComponents) } case model.RepositoryPathComponentTypeAtLeastTwo: if dstLength < 2 { - return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("the destination repository %q contains only %d path components %v, but the destination registry requires at least 2", + return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("the destination repository %q contains only %d path components %v, but the destination registry requires at least 2", dstRepo, dstLength, dstRepoPathComponents) } } diff --git a/src/controller/replication/mock_flow_controller_test.go b/src/controller/replication/mock_flow_controller_test.go index 672aa710f..badcc57b2 100644 --- a/src/controller/replication/mock_flow_controller_test.go +++ b/src/controller/replication/mock_flow_controller_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package replication diff --git a/src/controller/replication/model/model.go b/src/controller/replication/model/model.go index a257687a7..63202d179 100644 --- a/src/controller/replication/model/model.go +++ b/src/controller/replication/model/model.go @@ -91,7 +91,7 @@ func (p *Policy) Validate() error { if len(p.DestNamespace) > 0 { if !lib.RepositoryNameRe.MatchString(p.DestNamespace) { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid destination namespace: %s", p.DestNamespace) + WithMessagef("invalid destination namespace: %s", p.DestNamespace) } } @@ -102,11 +102,11 @@ func (p *Policy) Validate() error { case model.TriggerTypeScheduled: if p.Trigger.Settings == nil || len(p.Trigger.Settings.Cron) == 0 { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("the cron string cannot be empty when the trigger type is %s", model.TriggerTypeScheduled) + WithMessagef("the cron string cannot be empty when the trigger type is %s", model.TriggerTypeScheduled) } if _, err := utils.CronParser().Parse(p.Trigger.Settings.Cron); err != nil { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid cron string for scheduled trigger: %s", p.Trigger.Settings.Cron) + WithMessagef("invalid cron string for scheduled trigger: %s", p.Trigger.Settings.Cron) } cronParts := strings.Split(p.Trigger.Settings.Cron, " ") if cronParts[0] != "0" { diff --git a/src/controller/retention/controller.go b/src/controller/retention/controller.go index 179d8c151..dae3bbeea 100644 --- a/src/controller/retention/controller.go +++ b/src/controller/retention/controller.go @@ -36,8 +36,6 @@ import ( "github.com/goharbor/harbor/src/pkg/task" ) -// go:generate mockery -name Controller -case snake - // Controller to handle the requests related with retention type Controller interface { GetRetention(ctx context.Context, id int64) (*policy.Metadata, error) diff --git a/src/controller/scan/base_controller.go b/src/controller/scan/base_controller.go index 04213eb4c..448e25e27 100644 --- a/src/controller/scan/base_controller.go +++ b/src/controller/scan/base_controller.go @@ -243,12 +243,12 @@ func (bc *basicController) Scan(ctx context.Context, artifact *ar.Artifact, opti // In case it does not exist if r == nil { - return errors.PreconditionFailedError(nil).WithMessage("no available scanner for project: %d", artifact.ProjectID) + return errors.PreconditionFailedError(nil).WithMessagef("no available scanner for project: %d", artifact.ProjectID) } // Check if it is disabled if r.Disabled { - return errors.PreconditionFailedError(nil).WithMessage("scanner %s is deactivated", r.Name) + return errors.PreconditionFailedError(nil).WithMessagef("scanner %s is deactivated", r.Name) } artifacts, scannable, err := bc.collectScanningArtifacts(ctx, r, artifact) @@ -266,7 +266,7 @@ func (bc *basicController) Scan(ctx context.Context, artifact *ar.Artifact, opti // skip to return err for event related scan return nil } - return errors.BadRequestError(nil).WithMessage("the configured scanner %s does not support scanning artifact with mime type %s", r.Name, artifact.ManifestMediaType) + return errors.BadRequestError(nil).WithMessagef("the configured scanner %s does not support scanning artifact with mime type %s", r.Name, artifact.ManifestMediaType) } var ( @@ -376,8 +376,7 @@ func (bc *basicController) Stop(ctx context.Context, artifact *ar.Artifact, capT } if len(executions) == 0 { - message := fmt.Sprintf("no scan job for artifact digest=%v", artifact.Digest) - return errors.BadRequestError(nil).WithMessage(message) + return errors.BadRequestError(nil).WithMessagef("no scan job for artifact digest=%v", artifact.Digest) } execution := executions[0] return bc.execMgr.Stop(ctx, execution.ID) @@ -590,7 +589,7 @@ func (bc *basicController) GetReport(ctx context.Context, artifact *ar.Artifact, } if r == nil { - return nil, errors.NotFoundError(nil).WithMessage("no scanner registration configured for project: %d", artifact.ProjectID) + return nil, errors.NotFoundError(nil).WithMessagef("no scanner registration configured for project: %d", artifact.ProjectID) } artifacts, scannable, err := bc.collectScanningArtifacts(ctx, r, artifact) @@ -599,7 +598,7 @@ func (bc *basicController) GetReport(ctx context.Context, artifact *ar.Artifact, } if !scannable { - return nil, errors.NotFoundError(nil).WithMessage("report not found for %s@%s", artifact.RepositoryName, artifact.Digest) + return nil, errors.NotFoundError(nil).WithMessagef("report not found for %s@%s", artifact.RepositoryName, artifact.Digest) } groupReports := make([][]*scan.Report, len(artifacts)) @@ -681,7 +680,7 @@ func (bc *basicController) GetScanLog(ctx context.Context, artifact *ar.Artifact reportUUIDToTasks := map[string]*task.Task{} for _, t := range tasks { if !scanTaskForArtifacts(t, artifactMap) { - return nil, errors.NotFoundError(nil).WithMessage("scan log with uuid: %s not found", uuid) + return nil, errors.NotFoundError(nil).WithMessagef("scan log with uuid: %s not found", uuid) } for _, reportUUID := range GetReportUUIDs(t.ExtraAttrs) { reportUUIDToTasks[reportUUID] = t @@ -1043,7 +1042,7 @@ func (bc *basicController) getScanTask(ctx context.Context, reportUUID string) ( } if len(tasks) == 0 { - return nil, errors.NotFoundError(nil).WithMessage("task for report %s not found", reportUUID) + return nil, errors.NotFoundError(nil).WithMessagef("task for report %s not found", reportUUID) } return tasks[0], nil diff --git a/src/controller/scanner/base_controller.go b/src/controller/scanner/base_controller.go index d05878288..25ae5820d 100644 --- a/src/controller/scanner/base_controller.go +++ b/src/controller/scanner/base_controller.go @@ -98,7 +98,7 @@ func (bc *basicController) GetTotalOfRegistrations(ctx context.Context, query *q // CreateRegistration ... func (bc *basicController) CreateRegistration(ctx context.Context, registration *scanner.Registration) (string, error) { if isReservedName(registration.Name) { - return "", errors.BadRequestError(nil).WithMessage(`name "%s" is reserved, please try a different name`, registration.Name) + return "", errors.BadRequestError(nil).WithMessagef(`name "%s" is reserved, please try a different name`, registration.Name) } // Check if the registration is available @@ -168,7 +168,7 @@ func (bc *basicController) UpdateRegistration(ctx context.Context, registration } if isReservedName(registration.Name) { - return errors.BadRequestError(nil).WithMessage(`name "%s" is reserved, please try a different name`, registration.Name) + return errors.BadRequestError(nil).WithMessagef(`name "%s" is reserved, please try a different name`, registration.Name) } return bc.manager.Update(ctx, registration) @@ -343,7 +343,7 @@ func (bc *basicController) GetMetadata(ctx context.Context, registrationUUID str } if r == nil { - return nil, errors.NotFoundError(nil).WithMessage("registration %s not found", registrationUUID) + return nil, errors.NotFoundError(nil).WithMessagef("registration %s not found", registrationUUID) } return bc.Ping(ctx, r) @@ -402,7 +402,7 @@ type MetadataResult struct { func (m *MetadataResult) Unpack() (*v1.ScannerAdapterMetadata, error) { var err error if m.Error != "" { - err = fmt.Errorf(m.Error) + err = errors.New(nil).WithMessage(m.Error) } return m.Metadata, err diff --git a/src/controller/securityhub/controller.go b/src/controller/securityhub/controller.go index 80babcb9a..fe28f3b22 100644 --- a/src/controller/securityhub/controller.go +++ b/src/controller/securityhub/controller.go @@ -147,11 +147,11 @@ func (c *controller) attachTags(ctx context.Context, vuls []*secHubModel.Vulnera } // get tags in the artifact list - var artifactIds []interface{} + var artifactIDs []interface{} for k := range artifactTagMap { - artifactIds = append(artifactIds, k) + artifactIDs = append(artifactIDs, k) } - query := q.New(q.KeyWords{"artifact_id": q.NewOrList(artifactIds)}) + query := q.New(q.KeyWords{"artifact_id": q.NewOrList(artifactIDs)}) tags, err := c.tagMgr.List(ctx, query) if err != nil { return vuls, err diff --git a/src/controller/tag/controller.go b/src/controller/tag/controller.go index 4fab9fb6b..5e20419df 100644 --- a/src/controller/tag/controller.go +++ b/src/controller/tag/controller.go @@ -97,7 +97,7 @@ func (c *controller) Ensure(ctx context.Context, repositoryID, artifactID int64, // existing tag must check the immutable status and signature if tag.Immutable { return 0, errors.New(nil).WithCode(errors.PreconditionCode). - WithMessage("the tag %s configured as immutable, cannot be updated", tag.Name) + WithMessagef("the tag %s configured as immutable, cannot be updated", tag.Name) } // the tag exists under the repository, but it is attached to other artifact // update it to point to the provided artifact @@ -189,7 +189,7 @@ func (c *controller) Delete(ctx context.Context, id int64) (err error) { } if tag.Immutable { return errors.New(nil).WithCode(errors.PreconditionCode). - WithMessage("the tag %s configured as immutable, cannot be deleted", tag.Name) + WithMessagef("the tag %s configured as immutable, cannot be deleted", tag.Name) } return c.tagMgr.Delete(ctx, id) } diff --git a/src/controller/user/controller.go b/src/controller/user/controller.go index 1d0901206..928d9fa89 100644 --- a/src/controller/user/controller.go +++ b/src/controller/user/controller.go @@ -178,17 +178,17 @@ func (c *controller) Count(ctx context.Context, query *q.Query) (int64, error) { func (c *controller) Delete(ctx context.Context, id int) error { // cleanup project member with the user if err := c.memberMgr.DeleteMemberByUserID(ctx, id); err != nil { - return errors.UnknownError(err).WithMessage("delete user failed, user id: %v, cannot delete project user member, error:%v", id, err) + return errors.UnknownError(err).WithMessagef("delete user failed, user id: %v, cannot delete project user member, error:%v", id, err) } // delete oidc metadata under the user if lib.GetAuthMode(ctx) == common.OIDCAuth { if err := c.oidcMetaMgr.DeleteByUserID(ctx, id); err != nil { - return errors.UnknownError(err).WithMessage("delete user failed, user id: %v, cannot delete oidc user, error:%v", id, err) + return errors.UnknownError(err).WithMessagef("delete user failed, user id: %v, cannot delete oidc user, error:%v", id, err) } } gdprSetting, err := config.GDPRSetting(ctx) if err != nil { - return errors.UnknownError(err).WithMessage("failed to load GDPR setting: %v", err) + return errors.UnknownError(err).WithMessagef("failed to load GDPR setting: %v", err) } if gdprSetting.AuditLogs { diff --git a/src/controller/usergroup/controller.go b/src/controller/usergroup/controller.go index 13bc31c82..8aae0871f 100644 --- a/src/controller/usergroup/controller.go +++ b/src/controller/usergroup/controller.go @@ -81,7 +81,7 @@ func (c *controller) Update(ctx context.Context, id int, groupName string) error return err } if len(ug) == 0 { - return errors.NotFoundError(nil).WithMessage("the user group with id %v is not found", id) + return errors.NotFoundError(nil).WithMessagef("the user group with id %v is not found", id) } return c.mgr.UpdateName(ctx, id, groupName) } @@ -90,10 +90,10 @@ func (c *controller) Create(ctx context.Context, group model.UserGroup) (int, er if group.GroupType == common.LDAPGroupType { ldapGroup, err := auth.SearchGroup(ctx, group.LdapGroupDN) if err == ldap.ErrNotFound || ldapGroup == nil { - return 0, errors.BadRequestError(nil).WithMessage("LDAP Group DN is not found: DN:%v", group.LdapGroupDN) + return 0, errors.BadRequestError(nil).WithMessagef("LDAP Group DN is not found: DN:%v", group.LdapGroupDN) } if err == ldap.ErrDNSyntax { - return 0, errors.BadRequestError(nil).WithMessage("invalid DN syntax. DN: %v", group.LdapGroupDN) + return 0, errors.BadRequestError(nil).WithMessagef("invalid DN syntax. DN: %v", group.LdapGroupDN) } if err != nil { return 0, err @@ -102,7 +102,7 @@ func (c *controller) Create(ctx context.Context, group model.UserGroup) (int, er id, err := c.mgr.Create(ctx, group) if err != nil && err == usergroup.ErrDupUserGroup { return 0, errors.ConflictError(nil). - WithMessage("duplicate user group, group name:%v, group type: %v, ldap group DN: %v", + WithMessagef("duplicate user group, group name:%v, group type: %v, ldap group DN: %v", group.GroupName, group.GroupType, group.LdapGroupDN) } diff --git a/src/controller/webhook/controller.go b/src/controller/webhook/controller.go index cae172a25..3e8f50f7f 100644 --- a/src/controller/webhook/controller.go +++ b/src/controller/webhook/controller.go @@ -146,7 +146,7 @@ func (c *controller) GetTask(ctx context.Context, taskID int64) (*task.Task, err if len(tasks) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("webhook task %d not found", taskID) + WithMessagef("webhook task %d not found", taskID) } return tasks[0], nil } diff --git a/src/core/auth/authenticator.go b/src/core/auth/authenticator.go index f36da85f2..6d00d4d3d 100644 --- a/src/core/auth/authenticator.go +++ b/src/core/auth/authenticator.go @@ -102,7 +102,7 @@ func (d *DefaultAuthenticateHelper) OnBoardUser(_ context.Context, _ *models.Use // SearchUser - Get user information from account repository 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) + return nil, libErrors.NotFoundError(ErrNotSupported).WithMessagef("%s not found", username) } // PostAuthenticate - Update user information after authenticate, such as OnBoard or sync info etc @@ -118,7 +118,7 @@ func (d *DefaultAuthenticateHelper) OnBoardGroup(_ context.Context, _ *model.Use // 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(_ 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) + return nil, libErrors.NotFoundError(ErrNotSupported).WithMessagef("%s not found", groupKey) } var registry = make(map[string]AuthenticateHelper) @@ -222,7 +222,7 @@ func SearchAndOnBoardUser(ctx context.Context, username string) (int, error) { return 0, err } if user == nil { - return 0, libErrors.NotFoundError(nil).WithMessage(fmt.Sprintf("user %s is not found", username)) + return 0, libErrors.NotFoundError(nil).WithMessagef("user %s is not found", username) } err = OnBoardUser(ctx, user) if err != nil { diff --git a/src/core/auth/ldap/ldap.go b/src/core/auth/ldap/ldap.go index 56533b287..62f85aa15 100644 --- a/src/core/auth/ldap/ldap.go +++ b/src/core/auth/ldap/ldap.go @@ -262,7 +262,7 @@ func (l *Auth) SearchUser(ctx context.Context, username string) (*models.User, e log.Debugf("Found ldap user %v", user) } else { - return nil, errors.NotFoundError(nil).WithMessage("no user found: %v", username) + return nil, errors.NotFoundError(nil).WithMessagef("no user found: %v", username) } return &user, nil @@ -292,7 +292,7 @@ func (l *Auth) SearchGroup(ctx context.Context, groupKey string) (*ugModel.UserG } if len(userGroupList) == 0 { - return nil, errors.NotFoundError(nil).WithMessage("failed to searh ldap group with groupDN:%v", groupKey) + return nil, errors.NotFoundError(nil).WithMessagef("failed to searh ldap group with groupDN:%v", groupKey) } userGroup := ugModel.UserGroup{ GroupName: userGroupList[0].Name, diff --git a/src/core/service/token/token.go b/src/core/service/token/token.go index 82b1dee62..5b6e29d9b 100644 --- a/src/core/service/token/token.go +++ b/src/core/service/token/token.go @@ -39,7 +39,7 @@ func (h *Handler) Get() { tokenCreator, ok := creatorMap[service] if !ok { errMsg := fmt.Sprintf("Unable to handle service: %s", service) - log.Errorf(errMsg) + log.Error(errMsg) h.CustomAbort(http.StatusBadRequest, template.HTMLEscapeString(errMsg)) } token, err := tokenCreator.Create(request) diff --git a/src/go.mod b/src/go.mod index 5aa9ae6fd..3a4bd4a67 100644 --- a/src/go.mod +++ b/src/go.mod @@ -1,6 +1,6 @@ module github.com/goharbor/harbor/src -go 1.22.3 +go 1.23.2 require ( github.com/FZambia/sentinel v1.1.0 diff --git a/src/jobservice/job/impl/gc/garbage_collection.go b/src/jobservice/job/impl/gc/garbage_collection.go index 7968a1020..eabe9e80e 100644 --- a/src/jobservice/job/impl/gc/garbage_collection.go +++ b/src/jobservice/job/impl/gc/garbage_collection.go @@ -713,7 +713,7 @@ func (gc *GarbageCollector) markDeleteFailed(ctx job.Context, blob *blobModels.B return errors.Wrapf(err, "failed to mark gc candidate delete failed: %s, %s", blob.Digest, blob.Status) } if count == 0 { - return errors.New(nil).WithMessage("no blob found to mark delete failed, ID:%d, digest:%s", blob.ID, blob.Digest).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("no blob found to mark delete failed, ID:%d, digest:%s", blob.ID, blob.Digest).WithCode(errors.NotFoundCode) } 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 3201d6b41..59f84d6c9 100644 --- a/src/jobservice/job/impl/scandataexport/scan_data_export.go +++ b/src/jobservice/job/impl/scandataexport/scan_data_export.go @@ -201,24 +201,24 @@ func (sde *ScanDataExport) writeCsvFile(ctx job.Context, params job.Parameters, return err } - projectIds := filterCriteria.Projects - if len(projectIds) == 0 { + projectIDs := filterCriteria.Projects + if len(projectIDs) == 0 { return nil } // extract the repository ids if any repositories have been specified - repoIds, err := sde.filterProcessor.ProcessRepositoryFilter(systemContext, filterCriteria.Repositories, projectIds) + repoIDs, err := sde.filterProcessor.ProcessRepositoryFilter(systemContext, filterCriteria.Repositories, projectIDs) if err != nil { return err } - if len(repoIds) == 0 { + if len(repoIDs) == 0 { logger.Infof("No repositories found with specified names: %v", filterCriteria.Repositories) return nil } // filter artifacts by tags - arts, err := sde.filterProcessor.ProcessTagFilter(systemContext, filterCriteria.Tags, repoIds) + arts, err := sde.filterProcessor.ProcessTagFilter(systemContext, filterCriteria.Tags, repoIDs) if err != nil { return err } diff --git a/src/jobservice/logger/entry.go b/src/jobservice/logger/entry.go index 3cdb5f5d9..c1f24ff31 100644 --- a/src/jobservice/logger/entry.go +++ b/src/jobservice/logger/entry.go @@ -14,7 +14,10 @@ package logger -import "fmt" +import ( + "errors" + "fmt" +) // Entry provides unique interfaces on top of multiple logger backends. // Entry also implements @Interface. @@ -115,7 +118,7 @@ func (e *Entry) Close() error { } } if errMsg != "" { - return fmt.Errorf(errMsg) + return errors.New(errMsg) } return nil } diff --git a/src/jobservice/mgt/mock_manager.go b/src/jobservice/mgt/mock_manager.go index 71e516cbf..57258d08e 100644 --- a/src/jobservice/mgt/mock_manager.go +++ b/src/jobservice/mgt/mock_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package mgt diff --git a/src/jobservice/migration/migrator_v180.go b/src/jobservice/migration/migrator_v180.go index ff9e497ca..2d9350017 100644 --- a/src/jobservice/migration/migrator_v180.go +++ b/src/jobservice/migration/migrator_v180.go @@ -390,7 +390,7 @@ func toInt(v interface{}) int64 { func hashKey(p *period.Policy) string { key := p.JobName - if p.JobParameters != nil && len(p.JobParameters) > 0 { + if len(p.JobParameters) > 0 { if bytes, err := json.Marshal(p.JobParameters); err == nil { key = fmt.Sprintf("%s:%s", key, string(bytes)) } diff --git a/src/jobservice/period/mock_scheduler.go b/src/jobservice/period/mock_scheduler.go index 556fe2a73..e323dbb59 100644 --- a/src/jobservice/period/mock_scheduler.go +++ b/src/jobservice/period/mock_scheduler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package period diff --git a/src/jobservice/worker/cworker/c_worker.go b/src/jobservice/worker/cworker/c_worker.go index 2063e74cd..130cd099e 100644 --- a/src/jobservice/worker/cworker/c_worker.go +++ b/src/jobservice/worker/cworker/c_worker.go @@ -154,7 +154,7 @@ func (w *basicWorker) Start() error { logger.Infof("Basic worker is started") // Start the reaper - w.knownJobs.Range(func(k interface{}, v interface{}) bool { + w.knownJobs.Range(func(k interface{}, _ interface{}) bool { w.reaper.jobTypes = append(w.reaper.jobTypes, k.(string)) return true diff --git a/src/jobservice/worker/cworker/reaper.go b/src/jobservice/worker/cworker/reaper.go index 8bf2b165d..601a9e6d0 100644 --- a/src/jobservice/worker/cworker/reaper.go +++ b/src/jobservice/worker/cworker/reaper.go @@ -136,7 +136,7 @@ func (r *reaper) syncOutdatedStats() error { // Loop all the in progress jobs to check if they're really in progress or // status is hung. - h := func(k string, v int64) (err error) { + h := func(k string, _ int64) (err error) { defer func() { if errs.IsObjectNotFoundError(err) { // As the job stats is lost and we don't have chance to restore it, then directly discard it. diff --git a/src/lib/cache/mock_cache_test.go b/src/lib/cache/mock_cache_test.go index b990522fa..de83992f0 100644 --- a/src/lib/cache/mock_cache_test.go +++ b/src/lib/cache/mock_cache_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package cache diff --git a/src/lib/endpoint.go b/src/lib/endpoint.go index 07945068a..95e6d6123 100644 --- a/src/lib/endpoint.go +++ b/src/lib/endpoint.go @@ -35,10 +35,10 @@ func ValidateHTTPURL(s string) (string, error) { } url, err := url.Parse(s) if err != nil { - return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid URL: %s", err.Error()) + return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid URL: %s", err.Error()) } if url.Scheme != "http" && url.Scheme != "https" { - return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid HTTP scheme: %s", url.Scheme) + return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid HTTP scheme: %s", url.Scheme) } // To avoid SSRF security issue, refer to #3755 for more detail return fmt.Sprintf("%s://%s%s", url.Scheme, url.Host, url.Path), nil diff --git a/src/lib/errors/errors.go b/src/lib/errors/errors.go index a44c7f2ac..71d1074b2 100644 --- a/src/lib/errors/errors.go +++ b/src/lib/errors/errors.go @@ -63,12 +63,18 @@ func (e *Error) MarshalJSON() ([]byte, error) { }) } -// WithMessage ... -func (e *Error) WithMessage(format string, v ...interface{}) *Error { +// WithMessagef ... +func (e *Error) WithMessagef(format string, v ...interface{}) *Error { e.Message = fmt.Sprintf(format, v...) return e } +// WithMessage ... +func (e *Error) WithMessage(message string) *Error { + e.Message = message + return e +} + // WithCode ... func (e *Error) WithCode(code string) *Error { e.Code = code diff --git a/src/lib/orm/error.go b/src/lib/orm/error.go index 0d8ea034d..315a41327 100644 --- a/src/lib/orm/error.go +++ b/src/lib/orm/error.go @@ -53,7 +53,7 @@ func AsNotFoundError(err error, messageFormat string, args ...interface{}) *erro if errors.Is(err, orm.ErrNoRows) { e := errors.NotFoundError(nil) if len(messageFormat) > 0 { - _ = e.WithMessage(messageFormat, args...) + _ = e.WithMessagef(messageFormat, args...) } return e } @@ -66,7 +66,7 @@ func AsConflictError(err error, messageFormat string, args ...interface{}) *erro if IsDuplicateKeyError(err) { e := errors.New(err). WithCode(errors.ConflictCode). - WithMessage(messageFormat, args...) + WithMessagef(messageFormat, args...) return e } return nil @@ -78,7 +78,7 @@ func AsForeignKeyError(err error, messageFormat string, args ...interface{}) *er if isViolatingForeignKeyConstraintError(err) { e := errors.New(err). WithCode(errors.ViolateForeignKeyConstraintCode). - WithMessage(messageFormat, args...) + WithMessagef(messageFormat, args...) return e } return nil diff --git a/src/lib/q/builder.go b/src/lib/q/builder.go index 3e4a50c4a..98a885ead 100644 --- a/src/lib/q/builder.go +++ b/src/lib/q/builder.go @@ -70,7 +70,7 @@ func parseKeywords(q string) (map[string]interface{}, error) { if err != nil { return nil, errors.New(err). WithCode(errors.BadRequestCode). - WithMessage("invalid query string value: %s", strs[1]) + WithMessagef("invalid query string value: %s", strs[1]) } keywords[strs[0]] = value } diff --git a/src/lib/redis/pool.go b/src/lib/redis/pool.go index 337375abe..3fe9c3351 100644 --- a/src/lib/redis/pool.go +++ b/src/lib/redis/pool.go @@ -84,7 +84,7 @@ func GetRedisPool(name string, rawurl string, param *PoolParam) (*redis.Pool, er Dial: func() (redis.Conn, error) { return redis.DialURL(rawurl) }, - TestOnBorrow: func(c redis.Conn, t time.Time) error { + TestOnBorrow: func(c redis.Conn, _ time.Time) error { _, err := c.Do("PING") return err }, @@ -172,7 +172,7 @@ func getSentinelPool(u *url.URL, param *PoolParam, name string) (*redis.Pool, er log.Debug(name, "dial redis master:", masterAddr, "db:", db) return redis.Dial("tcp", masterAddr, redisOptions...) }, - TestOnBorrow: func(c redis.Conn, t time.Time) error { + TestOnBorrow: func(c redis.Conn, _ time.Time) error { if !sentinel.TestRole(c, "master") { return fmt.Errorf("check role failed, %s", name) } diff --git a/src/lib/selector/selectors/index/index.go b/src/lib/selector/selectors/index/index.go index 8d308ae5a..5e7864624 100644 --- a/src/lib/selector/selectors/index/index.go +++ b/src/lib/selector/selectors/index/index.go @@ -94,7 +94,7 @@ func Get(kind, decoration, pattern, extras string) (selector.Selector, error) { func Index() []*IndexedMeta { all := make([]*IndexedMeta, 0) - index.Range(func(k, v interface{}) bool { + index.Range(func(_, v interface{}) bool { if item, ok := v.(*indexedItem); ok { all = append(all, item.Meta) return true diff --git a/src/pkg/accessory/dao/dao.go b/src/pkg/accessory/dao/dao.go index 96e63e05b..b51dc12b9 100644 --- a/src/pkg/accessory/dao/dao.go +++ b/src/pkg/accessory/dao/dao.go @@ -132,7 +132,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("accessory %d not found", id) + return errors.NotFoundError(nil).WithMessagef("accessory %d not found", id) } return nil } diff --git a/src/pkg/artifact/dao/dao.go b/src/pkg/artifact/dao/dao.go index c59baeb7f..e22e23091 100644 --- a/src/pkg/artifact/dao/dao.go +++ b/src/pkg/artifact/dao/dao.go @@ -146,7 +146,7 @@ func (d *dao) GetByDigest(ctx context.Context, repository, digest string) (*Arti } if len(artifacts) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("artifact %s@%s not found", repository, digest) + WithMessagef("artifact %s@%s not found", repository, digest) } return artifacts[0], nil } @@ -181,7 +181,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("artifact %d not found", id) + return errors.NotFoundError(nil).WithMessagef("artifact %d not found", id) } return nil @@ -197,7 +197,7 @@ func (d *dao) Update(ctx context.Context, artifact *Artifact, props ...string) e return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("artifact %d not found", artifact.ID) + return errors.NotFoundError(nil).WithMessagef("artifact %d not found", artifact.ID) } return nil } @@ -261,7 +261,7 @@ func (d *dao) DeleteReference(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("artifact reference %d not found", id) + return errors.NotFoundError(nil).WithMessagef("artifact reference %d not found", id) } return nil } diff --git a/src/pkg/artifactrash/dao/dao.go b/src/pkg/artifactrash/dao/dao.go index f10beba4f..1fad8ef99 100644 --- a/src/pkg/artifactrash/dao/dao.go +++ b/src/pkg/artifactrash/dao/dao.go @@ -73,7 +73,7 @@ func (d *dao) Delete(ctx context.Context, id int64) (err error) { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("artifact trash %d not found", id) + return errors.NotFoundError(nil).WithMessagef("artifact trash %d not found", id) } return nil } diff --git a/src/pkg/audit/dao/dao.go b/src/pkg/audit/dao/dao.go index 3a816b6c4..09e87c5ee 100644 --- a/src/pkg/audit/dao/dao.go +++ b/src/pkg/audit/dao/dao.go @@ -207,7 +207,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("access %d not found", id) + return errors.NotFoundError(nil).WithMessagef("access %d not found", id) } return nil } diff --git a/src/pkg/blob/dao/dao.go b/src/pkg/blob/dao/dao.go index 163616220..ba5aa67a1 100644 --- a/src/pkg/blob/dao/dao.go +++ b/src/pkg/blob/dao/dao.go @@ -385,7 +385,7 @@ func (d *dao) DeleteBlob(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("blob %d not found", id) + return errors.NotFoundError(nil).WithMessagef("blob %d not found", id) } return nil } diff --git a/src/pkg/blob/manager.go b/src/pkg/blob/manager.go index 54cc371df..07bd097c5 100644 --- a/src/pkg/blob/manager.go +++ b/src/pkg/blob/manager.go @@ -140,7 +140,7 @@ func (m *manager) Update(ctx context.Context, blob *Blob) error { func (m *manager) UpdateBlobStatus(ctx context.Context, blob *models.Blob) (int64, error) { _, exist := models.StatusMap[blob.Status] if !exist { - return -1, errors.New(nil).WithMessage("cannot update blob status, as the status is unknown. digest: %s, status: %s", blob.Digest, blob.Status) + return -1, errors.New(nil).WithMessagef("cannot update blob status, as the status is unknown. digest: %s, status: %s", blob.Digest, blob.Status) } return m.dao.UpdateBlobStatus(ctx, blob) } diff --git a/src/pkg/exporter/exporter.go b/src/pkg/exporter/exporter.go index 079071b31..2f5a5fe88 100644 --- a/src/pkg/exporter/exporter.go +++ b/src/pkg/exporter/exporter.go @@ -87,7 +87,7 @@ func (e *Exporter) RegisterCollector(collectors ...collector) error { func newServer(opt *Opt, _ *prometheus.Registry) *http.Server { exporterMux := http.NewServeMux() exporterMux.Handle(opt.MetricsPath, promhttp.Handler()) - exporterMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + exporterMux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(` Harbor Exporter diff --git a/src/pkg/immutable/dao/dao.go b/src/pkg/immutable/dao/dao.go index e957895c9..84e31237a 100644 --- a/src/pkg/immutable/dao/dao.go +++ b/src/pkg/immutable/dao/dao.go @@ -69,7 +69,7 @@ func (i *iDao) UpdateImmutableRule(ctx context.Context, projectID int64, ir *mod return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("immutable %d not found", ir.ID) + return errors.NotFoundError(nil).WithMessagef("immutable %d not found", ir.ID) } return nil } @@ -86,7 +86,7 @@ func (i *iDao) ToggleImmutableRule(ctx context.Context, id int64, status bool) e return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("immutable %d not found", ir.ID) + return errors.NotFoundError(nil).WithMessagef("immutable %d not found", ir.ID) } return nil } @@ -142,7 +142,7 @@ func (i *iDao) DeleteImmutableRule(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("immutable rule %d not found", id) + return errors.NotFoundError(nil).WithMessagef("immutable rule %d not found", id) } return nil } diff --git a/src/pkg/label/dao/dao.go b/src/pkg/label/dao/dao.go index b0fab3a00..8a00e2b25 100644 --- a/src/pkg/label/dao/dao.go +++ b/src/pkg/label/dao/dao.go @@ -123,7 +123,7 @@ func (d *defaultDAO) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("label %d not found", id) + return errors.NotFoundError(nil).WithMessagef("label %d not found", id) } return nil } @@ -184,7 +184,7 @@ func (d *defaultDAO) DeleteReference(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("label reference %d not found", id) + return errors.NotFoundError(nil).WithMessagef("label reference %d not found", id) } return nil } diff --git a/src/pkg/label/manager.go b/src/pkg/label/manager.go index 2886b3167..224a47e56 100644 --- a/src/pkg/label/manager.go +++ b/src/pkg/label/manager.go @@ -114,7 +114,7 @@ func (m *manager) RemoveFrom(ctx context.Context, labelID int64, artifactID int6 return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("reference with label %d and artifact %d not found", labelID, artifactID) + return errors.NotFoundError(nil).WithMessagef("reference with label %d and artifact %d not found", labelID, artifactID) } return nil } diff --git a/src/pkg/label/model/model.go b/src/pkg/label/model/model.go index e4444ee80..b6e731de6 100644 --- a/src/pkg/label/model/model.go +++ b/src/pkg/label/model/model.go @@ -52,9 +52,9 @@ func (l *Label) Valid() error { } if l.Scope != common.LabelScopeGlobal && l.Scope != common.LabelScopeProject { - return errors.New(nil).WithMessage("invalid: %s", l.Scope).WithCode(errors.BadRequestCode) + return errors.New(nil).WithMessagef("invalid: %s", l.Scope).WithCode(errors.BadRequestCode) } else if l.Scope == common.LabelScopeProject && l.ProjectID <= 0 { - return errors.New(nil).WithMessage("invalid: %d", l.ProjectID).WithCode(errors.BadRequestCode) + return errors.New(nil).WithMessagef("invalid: %d", l.ProjectID).WithCode(errors.BadRequestCode) } return nil } diff --git a/src/pkg/member/manager.go b/src/pkg/member/manager.go index d1a748fe6..6fe8ebb01 100644 --- a/src/pkg/member/manager.go +++ b/src/pkg/member/manager.go @@ -67,7 +67,7 @@ func (m *manager) Get(ctx context.Context, projectID int64, memberID int) (*mode } if len(pm) == 0 { return nil, errors.NotFoundError(nil). - WithMessage("the project member is not found, project id %v, member id %v", projectID, memberID) + WithMessagef("the project member is not found, project id %v, member id %v", projectID, memberID) } return pm[0], nil } diff --git a/src/pkg/notification/policy/dao/dao.go b/src/pkg/notification/policy/dao/dao.go index badd5b9d1..b744b0aa3 100644 --- a/src/pkg/notification/policy/dao/dao.go +++ b/src/pkg/notification/policy/dao/dao.go @@ -150,7 +150,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("notificationPolicy %d not found", id) + return errors.NotFoundError(nil).WithMessagef("notificationPolicy %d not found", id) } return nil } diff --git a/src/pkg/oidc/dao/meta.go b/src/pkg/oidc/dao/meta.go index 43efc3c44..37afec31e 100644 --- a/src/pkg/oidc/dao/meta.go +++ b/src/pkg/oidc/dao/meta.go @@ -80,7 +80,7 @@ func (md *metaDAO) Update(ctx context.Context, oidcUser *models.OIDCUser, props return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("oidc user data with id %d not found", oidcUser.ID) + return errors.NotFoundError(nil).WithMessagef("oidc user data with id %d not found", oidcUser.ID) } return nil } diff --git a/src/pkg/oidc/metamanager.go b/src/pkg/oidc/metamanager.go index c20b7806c..301d3503a 100644 --- a/src/pkg/oidc/metamanager.go +++ b/src/pkg/oidc/metamanager.go @@ -60,7 +60,7 @@ func (m *metaManager) GetBySubIss(ctx context.Context, sub, iss string) (*models return nil, err } if len(l) == 0 { - return nil, errors.NotFoundError(nil).WithMessage("oidc info for user with issuer %s, subject %s not found", iss, sub) + return nil, errors.NotFoundError(nil).WithMessagef("oidc info for user with issuer %s, subject %s not found", iss, sub) } if len(l) > 1 { logger.Warningf("Multiple oidc info records found for issuer %s, subject %s", iss, sub) @@ -79,7 +79,7 @@ func (m *metaManager) GetByUserID(ctx context.Context, uid int) (*models.OIDCUse return nil, err } if len(l) == 0 { - return nil, errors.NotFoundError(nil).WithMessage("oidc info for user %d not found", uid) + return nil, errors.NotFoundError(nil).WithMessagef("oidc info for user %d not found", uid) } if len(l) > 1 { logger.Warningf("%d records of oidc user Info found for user %d", len(l), uid) diff --git a/src/pkg/p2p/preheat/dao/policy/dao.go b/src/pkg/p2p/preheat/dao/policy/dao.go index 25b44b460..4de480bad 100644 --- a/src/pkg/p2p/preheat/dao/policy/dao.go +++ b/src/pkg/p2p/preheat/dao/policy/dao.go @@ -91,7 +91,7 @@ func (d *dao) Update(ctx context.Context, schema *policy.Schema, props ...string } if id == 0 { - return errors.NotFoundError(nil).WithMessage("policy %d not found", schema.ID) + return errors.NotFoundError(nil).WithMessagef("policy %d not found", schema.ID) } return nil @@ -148,7 +148,7 @@ func (d *dao) Delete(ctx context.Context, id int64) (err error) { } if n == 0 { - return errors.NotFoundError(nil).WithMessage("policy %d not found", id) + return errors.NotFoundError(nil).WithMessagef("policy %d not found", id) } return nil diff --git a/src/pkg/p2p/preheat/models/policy/policy.go b/src/pkg/p2p/preheat/models/policy/policy.go index b9e410b1c..2ac1b2a82 100644 --- a/src/pkg/p2p/preheat/models/policy/policy.go +++ b/src/pkg/p2p/preheat/models/policy/policy.go @@ -132,13 +132,13 @@ func (s *Schema) ValidatePreheatPolicy() error { if s.Trigger != nil && s.Trigger.Type == TriggerTypeScheduled && len(s.Trigger.Settings.Cron) > 0 { if err := utils.ValidateCronString(s.Trigger.Settings.Cron); err != nil { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid cron string for scheduled preheat: %s, error: %v", s.Trigger.Settings.Cron, err) + WithMessagef("invalid cron string for scheduled preheat: %s, error: %v", s.Trigger.Settings.Cron, err) } } // validate preheat scope if s.Scope != "" && s.Scope != ScopeTypeSinglePeer && s.Scope != ScopeTypeAllPeers { - return errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid scope for preheat policy: %s", s.Scope) + return errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid scope for preheat policy: %s", s.Scope) } return nil diff --git a/src/pkg/permission/evaluator/rbac/casbin_match.go b/src/pkg/permission/evaluator/rbac/casbin_match.go index afd0ddf25..543512b46 100644 --- a/src/pkg/permission/evaluator/rbac/casbin_match.go +++ b/src/pkg/permission/evaluator/rbac/casbin_match.go @@ -40,7 +40,7 @@ func (s *regexpStore) Get(key string, build func(string) *regexp.Regexp) *regexp func (s *regexpStore) Purge() { var keys []interface{} - s.entries.Range(func(key, value interface{}) bool { + s.entries.Range(func(key, _ interface{}) bool { keys = append(keys, key) return true }) diff --git a/src/pkg/project/manager.go b/src/pkg/project/manager.go index aa4d55bdb..b030061af 100644 --- a/src/pkg/project/manager.go +++ b/src/pkg/project/manager.go @@ -71,12 +71,12 @@ type manager struct { // Create creates project instance func (m *manager) Create(ctx context.Context, project *models.Project) (int64, error) { if project.OwnerID <= 0 { - return 0, errors.BadRequestError(nil).WithMessage("Owner is missing when creating project %s", project.Name) + return 0, errors.BadRequestError(nil).WithMessagef("Owner is missing when creating project %s", project.Name) } if utils.IsIllegalLength(project.Name, projectNameMinLen, projectNameMaxLen) { format := "Project name %s is illegal in length. (greater than %d or less than %d)" - return 0, errors.BadRequestError(nil).WithMessage(format, project.Name, projectNameMaxLen, projectNameMinLen) + return 0, errors.BadRequestError(nil).WithMessagef(format, project.Name, projectNameMaxLen, projectNameMinLen) } legal := validProjectName.MatchString(project.Name) @@ -107,7 +107,7 @@ func (m *manager) Get(ctx context.Context, idOrName interface{}) (*models.Projec if ok { // check white space in project name if strings.Contains(name, " ") { - return nil, errors.BadRequestError(nil).WithMessage("invalid project name: '%s'", name) + return nil, errors.BadRequestError(nil).WithMessagef("invalid project name: '%s'", name) } return m.dao.GetByName(ctx, name) } diff --git a/src/pkg/rbac/dao/dao.go b/src/pkg/rbac/dao/dao.go index 1678a522c..0c05b8388 100644 --- a/src/pkg/rbac/dao/dao.go +++ b/src/pkg/rbac/dao/dao.go @@ -74,7 +74,7 @@ func (d *dao) DeletePermission(ctx context.Context, id int64) (err error) { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("role permission %d not found", id) + return errors.NotFoundError(nil).WithMessagef("role permission %d not found", id) } return nil } @@ -106,7 +106,7 @@ func (d *dao) DeletePermissionsByRole(ctx context.Context, roleType string, role return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("role permission %s:%d not found", roleType, roleID) + return errors.NotFoundError(nil).WithMessagef("role permission %s:%d not found", roleType, roleID) } return err } @@ -132,7 +132,7 @@ func (d *dao) DeleteRbacPolicy(ctx context.Context, id int64) (err error) { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("rbac policy %d not found", id) + return errors.NotFoundError(nil).WithMessagef("rbac policy %d not found", id) } return nil } diff --git a/src/pkg/reg/adapter/googlegcr/adapter.go b/src/pkg/reg/adapter/googlegcr/adapter.go index 43d80722f..75a33665c 100644 --- a/src/pkg/reg/adapter/googlegcr/adapter.go +++ b/src/pkg/reg/adapter/googlegcr/adapter.go @@ -212,7 +212,7 @@ func (a adapter) DeleteManifest(repository, reference string) error { if d == "" { return errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("%s:%s not found", repository, reference) + WithMessagef("%s:%s not found", repository, reference) } for _, t := range append(tags, d) { req, err := http.NewRequest(http.MethodDelete, buildManifestURL(a.registry.URL, repository, t), nil) diff --git a/src/pkg/reg/dao/dao.go b/src/pkg/reg/dao/dao.go index afdd941ac..c1ab4acad 100644 --- a/src/pkg/reg/dao/dao.go +++ b/src/pkg/reg/dao/dao.go @@ -109,7 +109,7 @@ func (d *dao) Update(ctx context.Context, registry *Registry, props ...string) e return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("registry %d not found", registry.ID) + return errors.NotFoundError(nil).WithMessagef("registry %d not found", registry.ID) } return nil } @@ -126,7 +126,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("registry %d not found", id) + return errors.NotFoundError(nil).WithMessagef("registry %d not found", id) } return nil } diff --git a/src/pkg/reg/model/policy.go b/src/pkg/reg/model/policy.go index e7352c16f..3b7260b77 100644 --- a/src/pkg/reg/model/policy.go +++ b/src/pkg/reg/model/policy.go @@ -52,7 +52,7 @@ func (f *Filter) Validate() error { rt := value if !(rt == ResourceTypeArtifact || rt == ResourceTypeImage) { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid resource filter: %s", value) + WithMessagef("invalid resource filter: %s", value) } } if f.Type == FilterTypeName || f.Type == FilterTypeResource { @@ -81,7 +81,7 @@ func (f *Filter) Validate() error { if f.Decoration != "" && f.Decoration != Matches && f.Decoration != Excludes { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid filter decoration, :%s", f.Decoration) + WithMessagef("invalid filter decoration, :%s", f.Decoration) } return nil diff --git a/src/pkg/reg/util/util.go b/src/pkg/reg/util/util.go index 4c628871d..ca94ce641 100644 --- a/src/pkg/reg/util/util.go +++ b/src/pkg/reg/util/util.go @@ -49,7 +49,7 @@ func Ping(registry *model.Registry) (string, string, error) { return challenge.Parameters["realm"], challenge.Parameters["service"], nil } } - return "", "", errors.New(nil).WithCode(errors.ChallengesUnsupportedCode).WithMessage("bearer auth scheme isn't supported: %v", challenges) + return "", "", errors.New(nil).WithCode(errors.ChallengesUnsupportedCode).WithMessagef("bearer auth scheme isn't supported: %v", challenges) } // ParseRepository parses the "repository" provided into two parts: namespace and the rest diff --git a/src/pkg/registry/auth/bearer/authorizer.go b/src/pkg/registry/auth/bearer/authorizer.go index 114f495ef..402632b74 100644 --- a/src/pkg/registry/auth/bearer/authorizer.go +++ b/src/pkg/registry/auth/bearer/authorizer.go @@ -125,7 +125,6 @@ func (a *authorizer) fetchToken(scopes []*scope) (*token, error) { return nil, err } if resp.StatusCode != http.StatusOK { - message := fmt.Sprintf("http status code: %d, body: %s", resp.StatusCode, string(body)) code := errors.GeneralCode switch resp.StatusCode { case http.StatusUnauthorized: @@ -134,7 +133,7 @@ func (a *authorizer) fetchToken(scopes []*scope) (*token, error) { code = errors.ForbiddenCode } return nil, errors.New(nil).WithCode(code). - WithMessage(message) + WithMessagef("http status code: %d, body: %s", resp.StatusCode, string(body)) } token := &token{} if err = json.Unmarshal(body, token); err != nil { diff --git a/src/pkg/registry/client.go b/src/pkg/registry/client.go index af3d95186..23bb14827 100644 --- a/src/pkg/registry/client.go +++ b/src/pkg/registry/client.go @@ -340,7 +340,7 @@ func (c *client) DeleteManifest(repository, reference string) error { } if !exist { return errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("%s:%s not found", repository, reference) + WithMessagef("%s:%s not found", repository, reference) } reference = string(desc.Digest) } @@ -669,7 +669,6 @@ func (c *client) do(req *http.Request) (*http.Response, error) { if err != nil { return nil, err } - message := fmt.Sprintf("http status code: %d, body: %s", resp.StatusCode, string(body)) code := errors.GeneralCode switch resp.StatusCode { case http.StatusUnauthorized: @@ -682,7 +681,7 @@ func (c *client) do(req *http.Request) (*http.Response, error) { code = errors.RateLimitCode } return nil, errors.New(nil).WithCode(code). - WithMessage(message) + WithMessagef("http status code: %d, body: %s", resp.StatusCode, string(body)) } return resp, nil } diff --git a/src/pkg/replication/dao/dao.go b/src/pkg/replication/dao/dao.go index 6beb2ad56..f5c736c88 100644 --- a/src/pkg/replication/dao/dao.go +++ b/src/pkg/replication/dao/dao.go @@ -109,7 +109,7 @@ func (d *dao) Update(ctx context.Context, policy *model.Policy, props ...string) } if n == 0 { - return errors.NotFoundError(nil).WithMessage("replication policy %d not found", policy.ID) + return errors.NotFoundError(nil).WithMessagef("replication policy %d not found", policy.ID) } return nil } @@ -126,7 +126,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("replication policy %d not found", id) + return errors.NotFoundError(nil).WithMessagef("replication policy %d not found", id) } return nil } diff --git a/src/pkg/repository/dao/dao.go b/src/pkg/repository/dao/dao.go index 864761ef7..4c814730e 100644 --- a/src/pkg/repository/dao/dao.go +++ b/src/pkg/repository/dao/dao.go @@ -113,7 +113,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("repository %d not found", id) + return errors.NotFoundError(nil).WithMessagef("repository %d not found", id) } return nil } @@ -128,7 +128,7 @@ func (d *dao) Update(ctx context.Context, repository *model.RepoRecord, props .. return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("repository %d not found", repository.RepositoryID) + return errors.NotFoundError(nil).WithMessagef("repository %d not found", repository.RepositoryID) } return nil } @@ -147,7 +147,7 @@ func (d *dao) AddPullCount(ctx context.Context, id int64, count uint64) error { return err } if num == 0 { - return errors.New(nil).WithMessage("failed to increase repository pull count: %d", id) + return errors.New(nil).WithMessagef("failed to increase repository pull count: %d", id) } return nil } diff --git a/src/pkg/repository/manager.go b/src/pkg/repository/manager.go index a27260ea3..4e36821dc 100644 --- a/src/pkg/repository/manager.go +++ b/src/pkg/repository/manager.go @@ -83,7 +83,7 @@ func (m *manager) GetByName(ctx context.Context, name string) (repository *model } if len(repositories) == 0 { return nil, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("repository %s not found", name) + WithMessagef("repository %s not found", name) } return repositories[0], nil } diff --git a/src/pkg/retention/policy/models.go b/src/pkg/retention/policy/models.go index 14e7630f4..7e5e8d0b9 100644 --- a/src/pkg/retention/policy/models.go +++ b/src/pkg/retention/policy/models.go @@ -69,7 +69,7 @@ func (m *Metadata) ValidateRetentionPolicy() error { if ok && len(cronItem.(string)) > 0 { if err := utils.ValidateCronString(cronItem.(string)); err != nil { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid cron string for scheduled tag retention: %s, error: %v", cronItem.(string), err) + WithMessagef("invalid cron string for scheduled tag retention: %s, error: %v", cronItem.(string), err) } } } diff --git a/src/pkg/retention/policy/rule/index/index.go b/src/pkg/retention/policy/rule/index/index.go index 7fd148c9c..1555aedd6 100644 --- a/src/pkg/retention/policy/rule/index/index.go +++ b/src/pkg/retention/policy/rule/index/index.go @@ -253,7 +253,7 @@ func Get(templateID string, parameters rule.Parameters) (rule.Evaluator, error) func Index() []*Metadata { res := make([]*Metadata, 0) - index.Range(func(k, v interface{}) bool { + index.Range(func(_, v interface{}) bool { if item, ok := v.(*indexedItem); ok { res = append(res, item.Meta) return true diff --git a/src/pkg/robot/dao/dao.go b/src/pkg/robot/dao/dao.go index c8bb7abb1..b2f960826 100644 --- a/src/pkg/robot/dao/dao.go +++ b/src/pkg/robot/dao/dao.go @@ -78,7 +78,7 @@ func (d *dao) Update(ctx context.Context, r *model.Robot, props ...string) error return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("robot %d not found", r.ID) + return errors.NotFoundError(nil).WithMessagef("robot %d not found", r.ID) } return nil } @@ -117,7 +117,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("robot account %d not found", id) + return errors.NotFoundError(nil).WithMessagef("robot account %d not found", id) } return nil } diff --git a/src/pkg/scan/dao/scan/vulnerability.go b/src/pkg/scan/dao/scan/vulnerability.go index da59cabe0..d920de81d 100644 --- a/src/pkg/scan/dao/scan/vulnerability.go +++ b/src/pkg/scan/dao/scan/vulnerability.go @@ -50,8 +50,8 @@ type VulnerabilityRecordDao interface { DeleteForReport(ctx context.Context, reportUUID string) (int64, error) // DeleteForDigests deletes vulnerability records for a provided list of digests DeleteForDigests(ctx context.Context, digests ...string) (int64, error) - // GetRecordIdsForScanner gets record ids of vulnerability records for a scanner - GetRecordIdsForScanner(ctx context.Context, registrationUUID string) ([]int, error) + // GetRecordIDsForScanner gets record ids of vulnerability records for a scanner + GetRecordIDsForScanner(ctx context.Context, registrationUUID string) ([]int, error) } // NewVulnerabilityRecordDao returns a new dao to handle vulnerability data @@ -230,17 +230,17 @@ func (v *vulnerabilityRecordDao) DeleteForDigests(ctx context.Context, digests . return numRowsDeleted, nil } -// GetRecordIdsForScanner retrieves the internal Ids of the vulnerability records for a given scanner +// GetRecordIDsForScanner retrieves the internal Ids of the vulnerability records for a given scanner // identified by registrationUUID -func (v *vulnerabilityRecordDao) GetRecordIdsForScanner(ctx context.Context, registrationUUID string) ([]int, error) { - vulnRecordIds := make([]int, 0) +func (v *vulnerabilityRecordDao) GetRecordIDsForScanner(ctx context.Context, registrationUUID string) ([]int, error) { + vulnRecordIDs := make([]int, 0) o, err := orm.FromContext(ctx) if err != nil { return nil, err } - _, err = o.Raw("select id from vulnerability_record where registration_uuid = ?", registrationUUID).QueryRows(&vulnRecordIds) + _, err = o.Raw("select id from vulnerability_record where registration_uuid = ?", registrationUUID).QueryRows(&vulnRecordIDs) if err != nil { - return vulnRecordIds, err + return vulnRecordIDs, err } - return vulnRecordIds, err + return vulnRecordIDs, err } diff --git a/src/pkg/scan/dao/scan/vulnerability_test.go b/src/pkg/scan/dao/scan/vulnerability_test.go index c78cdef2c..9b56ffd67 100644 --- a/src/pkg/scan/dao/scan/vulnerability_test.go +++ b/src/pkg/scan/dao/scan/vulnerability_test.go @@ -180,7 +180,7 @@ func (suite *VulnerabilityTestSuite) TestGetVulnerabilityRecordsForScanner() { // TestGetVulnerabilityRecordIdsForScanner gets vulnerability records for scanner func (suite *VulnerabilityTestSuite) TestGetVulnerabilityRecordIdsForScanner() { - vulns, err := suite.vulnerabilityRecordDao.GetRecordIdsForScanner(suite.Context(), "scannerId1") + vulns, err := suite.vulnerabilityRecordDao.GetRecordIDsForScanner(suite.Context(), "scannerId1") suite.NoError(err, "Error when fetching vulnerability records for report") suite.True(len(vulns) > 0) } diff --git a/src/pkg/scan/dao/scanner/registration.go b/src/pkg/scan/dao/scanner/registration.go index 4b1190e0b..038b6af32 100644 --- a/src/pkg/scan/dao/scanner/registration.go +++ b/src/pkg/scan/dao/scanner/registration.go @@ -154,7 +154,7 @@ func SetDefaultRegistration(ctx context.Context, UUID string) error { return err } if count == 0 { - return errors.NotFoundError(nil).WithMessage("registration %s not found", UUID) + return errors.NotFoundError(nil).WithMessagef("registration %s not found", UUID) } qt2 := o.QueryTable(new(Registration)) diff --git a/src/pkg/scan/export/filter_processor.go b/src/pkg/scan/export/filter_processor.go index a58e2052b..4353e8479 100644 --- a/src/pkg/scan/export/filter_processor.go +++ b/src/pkg/scan/export/filter_processor.go @@ -30,8 +30,8 @@ import ( ) type FilterProcessor interface { - ProcessRepositoryFilter(ctx context.Context, filter string, projectIds []int64) ([]int64, error) - ProcessTagFilter(ctx context.Context, filter string, repositoryIds []int64) ([]*artifact.Artifact, error) + ProcessRepositoryFilter(ctx context.Context, filter string, projectIDs []int64) ([]int64, error) + ProcessTagFilter(ctx context.Context, filter string, repositoryIDs []int64) ([]*artifact.Artifact, error) ProcessLabelFilter(ctx context.Context, labelIDs []int64, arts []*artifact.Artifact) ([]*artifact.Artifact, error) } @@ -52,12 +52,12 @@ func NewFilterProcessor() FilterProcessor { } } -func (dfp *DefaultFilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter string, projectIds []int64) ([]int64, error) { +func (dfp *DefaultFilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter string, projectIDs []int64) ([]int64, error) { sel := doublestar.New(doublestar.RepoMatches, filter, "") candidates := make([]*selector.Candidate, 0) allRepoIDs := make([]int64, 0) - for _, projectID := range projectIds { + for _, projectID := range projectIDs { query := q.New(q.KeyWords{"ProjectID": projectID}) allRepos, err := dfp.repoMgr.List(ctx, query) if err != nil { @@ -87,7 +87,7 @@ func (dfp *DefaultFilterProcessor) ProcessRepositoryFilter(ctx context.Context, return repoIDs, nil } -func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter string, repositoryIds []int64) ([]*artifact.Artifact, error) { +func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter string, repositoryIDs []int64) ([]*artifact.Artifact, error) { arts := make([]*artifact.Artifact, 0) opts := &artifact.Option{ WithTag: true, @@ -96,7 +96,7 @@ func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter // WithAccessory: true } // list all artifacts by repository id - for _, repoID := range repositoryIds { + for _, repoID := range repositoryIDs { repoArts, err := dfp.artCtl.List(ctx, q.New(q.KeyWords{"RepositoryID": repoID}), opts) if err != nil { return nil, err diff --git a/src/pkg/scan/postprocessors/report_converters.go b/src/pkg/scan/postprocessors/report_converters.go index 0a91f41ad..c26032201 100644 --- a/src/pkg/scan/postprocessors/report_converters.go +++ b/src/pkg/scan/postprocessors/report_converters.go @@ -339,7 +339,7 @@ func (c *nativeToRelationalSchemaConverter) updateReport(ctx context.Context, vu return err } if len(reports) == 0 { - return errors.New(nil).WithMessage("report not found, uuid:%v", reportUUID) + return errors.New(nil).WithMessagef("report not found, uuid:%v", reportUUID) } r := reports[0] diff --git a/src/pkg/scan/vulnerability/vul.go b/src/pkg/scan/vulnerability/vul.go index 3a9cb5d0c..26fe7ab1a 100644 --- a/src/pkg/scan/vulnerability/vul.go +++ b/src/pkg/scan/vulnerability/vul.go @@ -73,7 +73,7 @@ func (h *scanHandler) MakePlaceHolder(ctx context.Context, art *artifact.Artifac if len(oldReports) > 0 { for _, oldReport := range oldReports { if !job.Status(oldReport.Status).Final() { - return nil, errors.ConflictError(nil).WithMessage("a previous scan process is %s", oldReport.Status) + return nil, errors.ConflictError(nil).WithMessagef("a previous scan process is %s", oldReport.Status) } } @@ -203,7 +203,7 @@ func (h *scanHandler) getScanTask(ctx context.Context, reportUUID string) (*task } if len(tasks) == 0 { - return nil, errors.NotFoundError(nil).WithMessage("task for report %s not found", reportUUID) + return nil, errors.NotFoundError(nil).WithMessagef("task for report %s not found", reportUUID) } return tasks[0], nil diff --git a/src/pkg/scheduler/dao.go b/src/pkg/scheduler/dao.go index e061d7ed7..1f56e7fdb 100644 --- a/src/pkg/scheduler/dao.go +++ b/src/pkg/scheduler/dao.go @@ -114,7 +114,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("schedule %d not found", id) + return errors.NotFoundError(nil).WithMessagef("schedule %d not found", id) } return nil @@ -132,7 +132,7 @@ func (d *dao) Update(ctx context.Context, schedule *schedule, props ...string) e return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("schedule %d not found", schedule.ID) + return errors.NotFoundError(nil).WithMessagef("schedule %d not found", schedule.ID) } return nil } diff --git a/src/pkg/scheduler/mock_dao_test.go b/src/pkg/scheduler/mock_dao_test.go index e875cb40d..84d68dcc8 100644 --- a/src/pkg/scheduler/mock_dao_test.go +++ b/src/pkg/scheduler/mock_dao_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package scheduler diff --git a/src/pkg/scheduler/scheduler.go b/src/pkg/scheduler/scheduler.go index 27227bb47..be065e6d6 100644 --- a/src/pkg/scheduler/scheduler.go +++ b/src/pkg/scheduler/scheduler.go @@ -99,7 +99,7 @@ func (s *scheduler) Schedule(ctx context.Context, vendorType string, vendorID in } if _, err := utils.CronParser().Parse(cron); err != nil { return 0, errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid cron %s: %v", cron, err) + WithMessagef("invalid cron %s: %v", cron, err) } if !callbackFuncExist(callbackFuncName) { return 0, fmt.Errorf("callback function %s not found", callbackFuncName) diff --git a/src/pkg/tag/dao/dao.go b/src/pkg/tag/dao/dao.go index 79acf00de..26103e21a 100644 --- a/src/pkg/tag/dao/dao.go +++ b/src/pkg/tag/dao/dao.go @@ -119,7 +119,7 @@ func (d *dao) Update(ctx context.Context, tag *tag.Tag, props ...string) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("tag %d not found", tag.ID) + return errors.NotFoundError(nil).WithMessagef("tag %d not found", tag.ID) } return nil } @@ -135,7 +135,7 @@ func (d *dao) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("tag %d not found", id) + return errors.NotFoundError(nil).WithMessagef("tag %d not found", id) } return nil } diff --git a/src/pkg/task/dao/execution.go b/src/pkg/task/dao/execution.go index 6775a7f3a..54128742d 100644 --- a/src/pkg/task/dao/execution.go +++ b/src/pkg/task/dao/execution.go @@ -161,7 +161,7 @@ func (e *executionDAO) Update(ctx context.Context, execution *Execution, props . return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("execution %d not found", execution.ID) + return errors.NotFoundError(nil).WithMessagef("execution %d not found", execution.ID) } return nil } @@ -182,7 +182,7 @@ func (e *executionDAO) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("execution %d not found", id) + return errors.NotFoundError(nil).WithMessagef("execution %d not found", id) } return nil } diff --git a/src/pkg/task/dao/task.go b/src/pkg/task/dao/task.go index 6bdcec199..6bead6283 100644 --- a/src/pkg/task/dao/task.go +++ b/src/pkg/task/dao/task.go @@ -166,7 +166,7 @@ func (t *taskDAO) Update(ctx context.Context, task *Task, props ...string) error return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("task %d not found", task.ID) + return errors.NotFoundError(nil).WithMessagef("task %d not found", task.ID) } return nil } @@ -217,7 +217,7 @@ func (t *taskDAO) Delete(ctx context.Context, id int64) error { return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("task %d not found", id) + return errors.NotFoundError(nil).WithMessagef("task %d not found", id) } return nil } diff --git a/src/pkg/task/execution.go b/src/pkg/task/execution.go index e2160cd89..31c993e36 100644 --- a/src/pkg/task/execution.go +++ b/src/pkg/task/execution.go @@ -275,7 +275,7 @@ func (e *executionManager) Delete(ctx context.Context, id int64) error { for _, task := range tasks { if !job.Status(task.Status).Final() { return errors.New(nil).WithCode(errors.PreconditionCode). - WithMessage("the execution %d has tasks that aren't in final status, stop the tasks first", id) + WithMessagef("the execution %d has tasks that aren't in final status, stop the tasks first", id) } log.Debugf("delete task %d as execution %d has been deleted", task.ID, task.ExecutionID) @@ -305,7 +305,7 @@ func (e *executionManager) DeleteByVendor(ctx context.Context, vendorType string for _, execution := range executions { if !job.Status(execution.Status).Final() { return errors.New(nil).WithCode(errors.PreconditionCode). - WithMessage("contains executions that aren't in final status, stop the execution first") + WithMessagef("contains executions that aren't in final status, stop the execution first") } } // delete the executions diff --git a/src/pkg/task/hook.go b/src/pkg/task/hook.go index 829a49156..46ca8e915 100644 --- a/src/pkg/task/hook.go +++ b/src/pkg/task/hook.go @@ -78,7 +78,7 @@ func (h *HookHandler) Handle(ctx context.Context, sc *job.StatusChange) error { } if len(tasks) == 0 { return errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("task with job ID %s not found", sc.JobID) + WithMessagef("task with job ID %s not found", sc.JobID) } task := tasks[0] execution, err := h.executionDAO.Get(ctx, task.ExecutionID) diff --git a/src/pkg/task/mock_execution_dao_test.go b/src/pkg/task/mock_execution_dao_test.go index 155b959ea..fa2a4b694 100644 --- a/src/pkg/task/mock_execution_dao_test.go +++ b/src/pkg/task/mock_execution_dao_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/pkg/task/mock_jobservice_client_test.go b/src/pkg/task/mock_jobservice_client_test.go index 06f58aff7..b0ff4aa76 100644 --- a/src/pkg/task/mock_jobservice_client_test.go +++ b/src/pkg/task/mock_jobservice_client_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/pkg/task/mock_sweep_manager_test.go b/src/pkg/task/mock_sweep_manager_test.go index 5bd1a6227..f4d7161bf 100644 --- a/src/pkg/task/mock_sweep_manager_test.go +++ b/src/pkg/task/mock_sweep_manager_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/pkg/task/mock_task_dao_test.go b/src/pkg/task/mock_task_dao_test.go index 00a810c63..f737fe44c 100644 --- a/src/pkg/task/mock_task_dao_test.go +++ b/src/pkg/task/mock_task_dao_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/pkg/task/mock_task_manager_test.go b/src/pkg/task/mock_task_manager_test.go index 9f9c35851..6e80df078 100644 --- a/src/pkg/task/mock_task_manager_test.go +++ b/src/pkg/task/mock_task_manager_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/pkg/token/options.go b/src/pkg/token/options.go index 7f639dfdc..1e1cb2872 100644 --- a/src/pkg/token/options.go +++ b/src/pkg/token/options.go @@ -69,7 +69,7 @@ func (o *Options) GetKey() (interface{}, error) { } return privateKey, nil default: - return nil, fmt.Errorf(fmt.Sprintf("unsupported sign method, %s", o.SignMethod)) + return nil, fmt.Errorf("unsupported sign method, %s", o.SignMethod) } } @@ -83,7 +83,7 @@ func DefaultTokenOptions() *Options { func NewOptions(sm, iss, keyPath string) (*Options, error) { pk, err := os.ReadFile(keyPath) if err != nil { - log.Errorf(fmt.Sprintf("failed to read private key %v", err)) + log.Errorf("failed to read private key %v", err) return nil, err } return &Options{ diff --git a/src/pkg/token/token.go b/src/pkg/token/token.go index 920b587af..61fc9885b 100644 --- a/src/pkg/token/token.go +++ b/src/pkg/token/token.go @@ -18,7 +18,6 @@ import ( "crypto/ecdsa" "crypto/rsa" "errors" - "fmt" "github.com/golang-jwt/jwt/v5" @@ -54,7 +53,7 @@ func (tk *Token) Raw() (string, error) { } raw, err := tk.Token.SignedString(key) if err != nil { - log.Debugf(fmt.Sprintf("failed to issue token %v", err)) + log.Debugf("failed to issue token %v", err) return "", err } return raw, err @@ -67,7 +66,7 @@ func Parse(opt *Options, rawToken string, claims jwt.Claims) (*Token, error) { return nil, err } var parser = jwt.NewParser(jwt.WithLeeway(common.JwtLeeway), jwt.WithValidMethods([]string{opt.SignMethod.Alg()})) - token, err := parser.ParseWithClaims(rawToken, claims, func(token *jwt.Token) (interface{}, error) { + token, err := parser.ParseWithClaims(rawToken, claims, func(_ *jwt.Token) (interface{}, error) { switch k := key.(type) { case *rsa.PrivateKey: return &k.PublicKey, nil @@ -78,12 +77,12 @@ func Parse(opt *Options, rawToken string, claims jwt.Claims) (*Token, error) { } }) if err != nil { - log.Errorf(fmt.Sprintf("parse token error, %v", err)) + log.Errorf("parse token error, %v", err) return nil, err } if !token.Valid { - log.Errorf(fmt.Sprintf("invalid jwt token, %v", token)) + log.Errorf("invalid jwt token, %v", token) return nil, errors.New("invalid jwt token") } return &Token{ diff --git a/src/pkg/user/dao/dao.go b/src/pkg/user/dao/dao.go index f93bdb212..13faf96be 100644 --- a/src/pkg/user/dao/dao.go +++ b/src/pkg/user/dao/dao.go @@ -71,7 +71,7 @@ func (d *dao) Count(ctx context.Context, query *q.Query) (int64, error) { func (d *dao) Create(ctx context.Context, user *commonmodels.User) (int, error) { if user.UserID > 0 { - return 0, errors.BadRequestError(nil).WithMessage("user ID is set when creating user: %d", user.UserID) + return 0, errors.BadRequestError(nil).WithMessagef("user ID is set when creating user: %d", user.UserID) } ormer, err := orm.FromContext(ctx) if err != nil { @@ -94,7 +94,7 @@ func (d *dao) Update(ctx context.Context, user *commonmodels.User, props ...stri return err } if n == 0 { - return errors.NotFoundError(nil).WithMessage("user with id %d not found", user.UserID) + return errors.NotFoundError(nil).WithMessagef("user with id %d not found", user.UserID) } return nil } diff --git a/src/pkg/user/manager.go b/src/pkg/user/manager.go index 5efb05578..85206b670 100644 --- a/src/pkg/user/manager.go +++ b/src/pkg/user/manager.go @@ -182,7 +182,7 @@ func (m *manager) Get(ctx context.Context, id int) (*commonmodels.User, error) { } if len(users) == 0 { - return nil, errors.NotFoundError(nil).WithMessage("user %d not found", id) + return nil, errors.NotFoundError(nil).WithMessagef("user %d not found", id) } return users[0], nil @@ -196,7 +196,7 @@ func (m *manager) GetByName(ctx context.Context, username string) (*commonmodels } if len(users) == 0 { - return nil, errors.NotFoundError(nil).WithMessage("user %s not found", username) + return nil, errors.NotFoundError(nil).WithMessagef("user %s not found", username) } return users[0], nil diff --git a/src/registryctl/client/client.go b/src/registryctl/client/client.go index f43e46f61..348d90012 100644 --- a/src/registryctl/client/client.go +++ b/src/registryctl/client/client.go @@ -124,7 +124,6 @@ func (c *client) do(req *http.Request) (*http.Response, error) { if err != nil { return nil, err } - message := fmt.Sprintf("http status code: %d, body: %s", resp.StatusCode, string(body)) code := errors.GeneralCode switch resp.StatusCode { case http.StatusUnauthorized: @@ -135,7 +134,7 @@ func (c *client) do(req *http.Request) (*http.Response, error) { code = errors.NotFoundCode } return nil, errors.New(nil).WithCode(code). - WithMessage(message) + WithMessagef("http status code: %d, body: %s", resp.StatusCode, string(body)) } return resp, nil } diff --git a/src/server/middleware/blob/copy_artifact.go b/src/server/middleware/blob/copy_artifact.go index 2a5de1c06..ea3884b6e 100644 --- a/src/server/middleware/blob/copy_artifact.go +++ b/src/server/middleware/blob/copy_artifact.go @@ -33,7 +33,7 @@ func isSuccess(statusCode int) bool { // CopyArtifactMiddleware middleware to sync the missing associations for the project func CopyArtifactMiddleware() func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if !isSuccess(statusCode) { return nil } @@ -49,7 +49,7 @@ func CopyArtifactMiddleware() func(http.Handler) http.Handler { art, err := artifactController.GetByReference(ctx, repository, reference, &artifact.Option{WithAccessory: true}) if errors.IsNotFoundErr(err) { // artifact not found, discontinue the API request - return errors.BadRequestError(nil).WithMessage("artifact %s not found", from) + return errors.BadRequestError(nil).WithMessagef("artifact %s not found", from) } else if err != nil { logger.Errorf("get artifact %s failed, error: %v", from, err) return err diff --git a/src/server/middleware/blob/head_blob.go b/src/server/middleware/blob/head_blob.go index 6f8e89914..f2ac625f4 100644 --- a/src/server/middleware/blob/head_blob.go +++ b/src/server/middleware/blob/head_blob.go @@ -15,7 +15,6 @@ package blob import ( - "fmt" "net/http" "time" @@ -59,7 +58,7 @@ func handleHead(req *http.Request) error { case blob_models.StatusNone, blob_models.StatusDelete: if err := blob.Ctl.Touch(req.Context(), bb); err != nil { log.Errorf("failed to update blob: %s status to StatusNone, error:%v", blobInfo.Digest, err) - return errors.Wrapf(err, fmt.Sprintf("the request id is: %s", req.Header.Get(requestid.HeaderXRequestID))) + return errors.Wrapf(err, "the request id is: %s", req.Header.Get(requestid.HeaderXRequestID)) } case blob_models.StatusDeleting: now := time.Now().UTC() @@ -67,14 +66,14 @@ func handleHead(req *http.Request) error { if now.Sub(bb.UpdateTime) > time.Duration(config.GetGCTimeWindow())*time.Hour { if err := blob.Ctl.Fail(req.Context(), bb); err != nil { log.Errorf("failed to update blob: %s status to StatusDeleteFailed, error:%v", blobInfo.Digest, err) - return errors.Wrapf(err, fmt.Sprintf("the request id is: %s", req.Header.Get(requestid.HeaderXRequestID))) + return errors.Wrapf(err, "the request id is: %s", req.Header.Get(requestid.HeaderXRequestID)) } } - return errors.New(nil).WithMessage(fmt.Sprintf("the asking blob is in GC, mark it as non existing, request id: %s", req.Header.Get(requestid.HeaderXRequestID))).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("the asking blob is in GC, mark it as non existing, request id: %s", req.Header.Get(requestid.HeaderXRequestID)).WithCode(errors.NotFoundCode) case blob_models.StatusDeleteFailed: - return errors.New(nil).WithMessage(fmt.Sprintf("the asking blob is delete failed, mark it as non existing, request id: %s", req.Header.Get(requestid.HeaderXRequestID))).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("the asking blob is delete failed, mark it as non existing, request id: %s", req.Header.Get(requestid.HeaderXRequestID)).WithCode(errors.NotFoundCode) default: - return errors.New(nil).WithMessage(fmt.Sprintf("wrong blob status, %s", bb.Status)) + return errors.New(nil).WithMessagef("wrong blob status, %s", bb.Status) } return nil } diff --git a/src/server/middleware/blob/post_initiate_blob_upload.go b/src/server/middleware/blob/post_initiate_blob_upload.go index 33eb42c11..07a984961 100644 --- a/src/server/middleware/blob/post_initiate_blob_upload.go +++ b/src/server/middleware/blob/post_initiate_blob_upload.go @@ -24,7 +24,7 @@ import ( // PostInitiateBlobUploadMiddleware middleware to add blob to project after mount blob success func PostInitiateBlobUploadMiddleware() func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if statusCode != http.StatusCreated { return nil } diff --git a/src/server/middleware/blob/put_manifest.go b/src/server/middleware/blob/put_manifest.go index e44aac57b..1bb3fbeb8 100644 --- a/src/server/middleware/blob/put_manifest.go +++ b/src/server/middleware/blob/put_manifest.go @@ -49,7 +49,7 @@ func PutManifestMiddleware() func(http.Handler) http.Handler { return probeBlob(r, descriptor.Digest.String()) }) - after := middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + after := middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if statusCode != http.StatusCreated { return nil } diff --git a/src/server/middleware/blob/util.go b/src/server/middleware/blob/util.go index 30f720fff..dc606d8cf 100644 --- a/src/server/middleware/blob/util.go +++ b/src/server/middleware/blob/util.go @@ -15,7 +15,6 @@ package blob import ( - "fmt" "net/http" "time" @@ -44,7 +43,7 @@ func probeBlob(r *http.Request, digest string) error { case models.StatusNone, models.StatusDelete, models.StatusDeleteFailed: if err := blobController.Touch(r.Context(), bb); err != nil { logger.Errorf("failed to update blob: %s status to StatusNone, error:%v", bb.Digest, err) - return errors.Wrapf(err, fmt.Sprintf("the request id is: %s", r.Header.Get(requestid.HeaderXRequestID))) + return errors.Wrapf(err, "the request id is: %s", r.Header.Get(requestid.HeaderXRequestID)) } case models.StatusDeleting: now := time.Now().UTC() @@ -52,12 +51,12 @@ func probeBlob(r *http.Request, digest string) error { if now.Sub(bb.UpdateTime) > time.Duration(config.GetGCTimeWindow())*time.Hour { if err := blob.Ctl.Fail(r.Context(), bb); err != nil { log.Errorf("failed to update blob: %s status to StatusDeleteFailed, error:%v", bb.Digest, err) - return errors.Wrapf(err, fmt.Sprintf("the request id is: %s", r.Header.Get(requestid.HeaderXRequestID))) + return errors.Wrapf(err, "the request id is: %s", r.Header.Get(requestid.HeaderXRequestID)) } // StatusDeleteFailed => StatusNone, and then let the proxy to handle manifest upload return probeBlob(r, digest) } - return errors.New(nil).WithMessage(fmt.Sprintf("the asking blob is in GC, mark it as non existing, request id: %s", r.Header.Get(requestid.HeaderXRequestID))).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("the asking blob is in GC, mark it as non existing, request id: %s", r.Header.Get(requestid.HeaderXRequestID)).WithCode(errors.NotFoundCode) default: return nil } diff --git a/src/server/middleware/cosign/cosign.go b/src/server/middleware/cosign/cosign.go index 53fcdc7ed..3dd4aa9a3 100644 --- a/src/server/middleware/cosign/cosign.go +++ b/src/server/middleware/cosign/cosign.go @@ -99,7 +99,7 @@ PUT /v2/library/goharbor/harbor-db/manifests/sha256:aabea2bdd5a6fb79c13837b88c7b */ func SignatureMiddleware() func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { if statusCode != http.StatusCreated { return nil } diff --git a/src/server/middleware/quota/copy_artifact.go b/src/server/middleware/quota/copy_artifact.go index b5630907d..a8e49432c 100644 --- a/src/server/middleware/quota/copy_artifact.go +++ b/src/server/middleware/quota/copy_artifact.go @@ -88,7 +88,7 @@ func copyArtifactResources(r *http.Request, _, referenceID string) (types.Resour }) if errors.IsNotFoundErr(err) { // artifact not found, discontinue the API request - return nil, errors.BadRequestError(nil).WithMessage("artifact %s not found", from) + return nil, errors.BadRequestError(nil).WithMessagef("artifact %s not found", from) } else if err != nil { logger.Errorf("get artifact %s failed, error: %v", from, err) return nil, err diff --git a/src/server/middleware/quota/put_blob_upload_test.go b/src/server/middleware/quota/put_blob_upload_test.go index d0d37eae3..25125689d 100644 --- a/src/server/middleware/quota/put_blob_upload_test.go +++ b/src/server/middleware/quota/put_blob_upload_test.go @@ -140,7 +140,7 @@ func (suite *PutBlobUploadMiddlewareTestSuite) TestResourcesExceeded() { var errs quota.Errors errs = errs.Add(quota.NewResourceOverflowError(types.ResourceStorage, 100, 100, 110)) - err := errors.DeniedError(errs).WithMessage("Quota exceeded when processing the request of %v", errs) + err := errors.DeniedError(errs).WithMessagef("Quota exceeded when processing the request of %v", errs) mock.OnAnything(suite.quotaController, "Request").Return(err).Once() req := suite.makeRequest(100) diff --git a/src/server/middleware/quota/put_manifest_test.go b/src/server/middleware/quota/put_manifest_test.go index 62c980603..f7539157f 100644 --- a/src/server/middleware/quota/put_manifest_test.go +++ b/src/server/middleware/quota/put_manifest_test.go @@ -213,7 +213,7 @@ func (suite *PutManifestMiddlewareTestSuite) TestResourcesExceeded() { var errs quota.Errors errs = errs.Add(quota.NewResourceOverflowError(types.ResourceStorage, 100, 100, 110)) - err := errors.DeniedError(errs).WithMessage("Quota exceeded when processing the request of %v", errs) + err := errors.DeniedError(errs).WithMessagef("Quota exceeded when processing the request of %v", errs) mock.OnAnything(suite.quotaController, "Request").Return(err).Once() req := httptest.NewRequest(http.MethodPut, "/v2/library/photon/manifests/2.0", nil) diff --git a/src/server/middleware/quota/quota.go b/src/server/middleware/quota/quota.go index 1213ea21f..f4d9b3c40 100644 --- a/src/server/middleware/quota/quota.go +++ b/src/server/middleware/quota/quota.go @@ -191,7 +191,7 @@ type RefreshConfig struct { // RefreshMiddleware middleware which refresh the quota usage after the response success func RefreshMiddleware(config RefreshConfig, skipers ...middleware.Skipper) func(http.Handler) http.Handler { - return middleware.AfterResponse(func(w http.ResponseWriter, r *http.Request, statusCode int) error { + return middleware.AfterResponse(func(_ http.ResponseWriter, r *http.Request, statusCode int) error { // skip to refresh quota usage when response is not success if !isSuccess(statusCode) { return nil diff --git a/src/server/middleware/quota/util.go b/src/server/middleware/quota/util.go index 9479a8067..3c6e3df0e 100644 --- a/src/server/middleware/quota/util.go +++ b/src/server/middleware/quota/util.go @@ -61,7 +61,7 @@ var ( ) func projectResourcesEvent(level int) func(*http.Request, string, string, string) event.Metadata { - return func(r *http.Request, reference, referenceID string, message string) event.Metadata { + return func(r *http.Request, _, referenceID string, message string) event.Metadata { ctx := r.Context() logger := log.G(ctx).WithFields(log.Fields{"middleware": "quota", "action": "request", "url": r.URL.Path}) diff --git a/src/server/registry/catalog.go b/src/server/registry/catalog.go index 71971a584..3326af698 100644 --- a/src/server/registry/catalog.go +++ b/src/server/registry/catalog.go @@ -16,7 +16,6 @@ package registry import ( "encoding/json" - "fmt" "net/http" "sort" "strconv" @@ -82,7 +81,7 @@ func (r *repositoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) if lastEntry != "" { lastEntryIndex := util.IndexString(repoNames, lastEntry) if lastEntryIndex == -1 { - err := errors.New(nil).WithCode(errors.BadRequestCode).WithMessage(fmt.Sprintf("the last: %s should be a valid repository name.", lastEntry)) + err := errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("the last: %s should be a valid repository name.", lastEntry) lib_http.SendError(w, err) return } diff --git a/src/server/v2.0/handler/artifact.go b/src/server/v2.0/handler/artifact.go index 79cf31622..c5ee83114 100644 --- a/src/server/v2.0/handler/artifact.go +++ b/src/server/v2.0/handler/artifact.go @@ -212,7 +212,7 @@ func parse(s string) (string, string, error) { matches := reference.ReferenceRegexp.FindStringSubmatch(s) if matches == nil { return "", "", errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid input: %s", s) + WithMessagef("invalid input: %s", s) } repository := matches[1] reference := matches[2] @@ -220,7 +220,7 @@ func parse(s string) (string, string, error) { _, err := digest.Parse(matches[3]) if err != nil { return "", "", errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid input: %s", s) + WithMessagef("invalid input: %s", s) } reference = matches[3] } @@ -270,7 +270,7 @@ func (a *artifactAPI) requireNonProxyCacheProject(ctx context.Context, name stri } if pro.IsProxy() { return errors.New(nil).WithCode(errors.MethodNotAllowedCode). - WithMessage("the operation isn't supported for a proxy cache project") + WithMessagef("the operation isn't supported for a proxy cache project") } return nil } @@ -295,7 +295,7 @@ func (a *artifactAPI) DeleteTag(ctx context.Context, params operation.DeleteTagP } // the tag not found if id == 0 { - err = errors.New(nil).WithCode(errors.NotFoundCode).WithMessage( + err = errors.New(nil).WithCode(errors.NotFoundCode).WithMessagef( "tag %s attached to artifact %d not found", params.TagName, artifact.ID) return a.SendError(ctx, err) } @@ -428,7 +428,7 @@ func (a *artifactAPI) GetVulnerabilitiesAddition(ctx context.Context, params ope content, _ := json.Marshal(vulnerabilities) - return middleware.ResponderFunc(func(w http.ResponseWriter, p runtime.Producer) { + return middleware.ResponderFunc(func(w http.ResponseWriter, _ runtime.Producer) { w.Header().Set("Content-Type", "application/json") _, _ = w.Write(content) }) @@ -449,7 +449,7 @@ func (a *artifactAPI) GetAddition(ctx context.Context, params operation.GetAddit return a.SendError(ctx, err) } - return middleware.ResponderFunc(func(w http.ResponseWriter, p runtime.Producer) { + return middleware.ResponderFunc(func(w http.ResponseWriter, _ runtime.Producer) { w.Header().Set("Content-Type", addition.ContentType) _, _ = w.Write(addition.Content) }) @@ -496,7 +496,7 @@ func (a *artifactAPI) RequireLabelInProject(ctx context.Context, projectID, labe return err } if l.Scope == common.LabelScopeProject && l.ProjectID != projectID { - return errors.NotFoundError(nil).WithMessage("project id %d, label %d not found", projectID, labelID) + return errors.NotFoundError(nil).WithMessagef("project id %d, label %d not found", projectID, labelID) } return nil } diff --git a/src/server/v2.0/handler/gc.go b/src/server/v2.0/handler/gc.go index 5e5c36697..41d53734c 100644 --- a/src/server/v2.0/handler/gc.go +++ b/src/server/v2.0/handler/gc.go @@ -106,7 +106,7 @@ func (g *gcAPI) kick(ctx context.Context, scheType string, cron string, paramete return 0, errors.BadRequestError(fmt.Errorf("workers should be integer format")) } if !validateWorkers(int(wInt)) { - return 0, errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("Error: Invalid number of workers:%s. Workers must be greater than 0 and less than or equal to 5.", workers) + return 0, errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("Error: Invalid number of workers:%s. Workers must be greater than 0 and less than or equal to 5.", workers) } policy.Workers = int(wInt) } @@ -130,7 +130,7 @@ func (g *gcAPI) kick(ctx context.Context, scheType string, cron string, paramete return 0, errors.BadRequestError(fmt.Errorf("workers should be integer format")) } if !validateWorkers(int(wInt)) { - return 0, errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("Error: Invalid number of workers:%s. Workers must be greater than 0 and less than or equal to 5.", workers) + return 0, errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("Error: Invalid number of workers:%s. Workers must be greater than 0 and less than or equal to 5.", workers) } policy.Workers = int(wInt) } @@ -150,7 +150,7 @@ func (g *gcAPI) createSchedule(ctx context.Context, cronType, cron string, polic func (g *gcAPI) updateSchedule(ctx context.Context, cronType, cron string, policy gc.Policy) error { if err := utils.ValidateCronString(cron); err != nil { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid cron string for scheduled gc: %s, error: %v", cron, err) + WithMessagef("invalid cron string for scheduled gc: %s, error: %v", cron, err) } if err := g.gcCtr.DeleteSchedule(ctx); err != nil { return err @@ -262,7 +262,7 @@ func (g *gcAPI) GetGCLog(ctx context.Context, params operation.GetGCLogParams) m return g.SendError(ctx, err) } if len(tasks) == 0 { - return g.SendError(ctx, errors.New(nil).WithCode(errors.NotFoundCode).WithMessage("garbage collection %d log is not found", params.GCID)) + return g.SendError(ctx, errors.New(nil).WithCode(errors.NotFoundCode).WithMessagef("garbage collection %d log is not found", params.GCID)) } log, err := g.gcCtr.GetTaskLog(ctx, tasks[0].ID) if err != nil { diff --git a/src/server/v2.0/handler/label.go b/src/server/v2.0/handler/label.go index 2c9299cbf..80bc1b1ec 100644 --- a/src/server/v2.0/handler/label.go +++ b/src/server/v2.0/handler/label.go @@ -78,7 +78,7 @@ func (lAPI *labelAPI) GetLabelByID(ctx context.Context, params operation.GetLabe return lAPI.SendError(ctx, err) } if label == nil || label.Deleted { - return lAPI.SendError(ctx, errors.New(nil).WithMessage("label %d not found", params.LabelID).WithCode(errors.NotFoundCode)) + return lAPI.SendError(ctx, errors.New(nil).WithMessagef("label %d not found", params.LabelID).WithCode(errors.NotFoundCode)) } if err := lAPI.requireAccess(ctx, label, rbac.ActionRead); err != nil { @@ -96,7 +96,7 @@ func (lAPI *labelAPI) ListLabels(ctx context.Context, params operation.ListLabel scope := lib.StringValue(params.Scope) if scope != common.LabelScopeGlobal && scope != common.LabelScopeProject { - return lAPI.SendError(ctx, errors.New(nil).WithMessage("invalid scope: %s", scope).WithCode(errors.BadRequestCode)) + return lAPI.SendError(ctx, errors.New(nil).WithMessagef("invalid scope: %s", scope).WithCode(errors.BadRequestCode)) } query.Keywords["Level"] = common.LabelLevelUser query.Keywords["Scope"] = scope @@ -148,7 +148,7 @@ func (lAPI *labelAPI) UpdateLabel(ctx context.Context, params operation.UpdateLa return lAPI.SendError(ctx, err) } if label == nil || label.Deleted { - return lAPI.SendError(ctx, errors.New(nil).WithMessage("label %d not found", params.LabelID).WithCode(errors.NotFoundCode)) + return lAPI.SendError(ctx, errors.New(nil).WithMessagef("label %d not found", params.LabelID).WithCode(errors.NotFoundCode)) } if err := lAPI.requireAccess(ctx, label, rbac.ActionUpdate); err != nil { diff --git a/src/server/v2.0/handler/member.go b/src/server/v2.0/handler/member.go index 06caa50e1..2243cca82 100644 --- a/src/server/v2.0/handler/member.go +++ b/src/server/v2.0/handler/member.go @@ -159,10 +159,10 @@ func (m *memberAPI) UpdateProjectMember(ctx context.Context, params operation.Up return m.SendError(ctx, err) } if params.Role == nil { - return m.SendError(ctx, errors.BadRequestError(nil).WithMessage("role can not be empty!")) + return m.SendError(ctx, errors.BadRequestError(nil).WithMessage("role can not be empty")) } if params.Mid == 0 { - return m.SendError(ctx, errors.BadRequestError(nil).WithMessage("member id can not be empty!")) + return m.SendError(ctx, errors.BadRequestError(nil).WithMessage("member id can not be empty")) } err := m.ctl.UpdateRole(ctx, projectNameOrID, int(params.Mid), int(params.Role.RoleID)) diff --git a/src/server/v2.0/handler/model/project.go b/src/server/v2.0/handler/model/project.go index 1321f2fc0..d821e8c90 100644 --- a/src/server/v2.0/handler/model/project.go +++ b/src/server/v2.0/handler/model/project.go @@ -33,9 +33,9 @@ type Project struct { // ToSwagger converts the project to the swagger model func (p *Project) ToSwagger() *models.Project { - var currentUserRoleIds []int32 + var currentUserRoleIDs []int32 for _, role := range p.RoleList { - currentUserRoleIds = append(currentUserRoleIds, int32(role)) + currentUserRoleIDs = append(currentUserRoleIDs, int32(role)) } var md *models.ProjectMetadata @@ -63,7 +63,7 @@ func (p *Project) ToSwagger() *models.Project { return &models.Project{ CreationTime: strfmt.DateTime(p.CreationTime), CurrentUserRoleID: int64(p.Role), - CurrentUserRoleIds: currentUserRoleIds, + CurrentUserRoleIds: currentUserRoleIDs, CVEAllowlist: &allowlist, Metadata: md, Name: p.Name, diff --git a/src/server/v2.0/handler/project.go b/src/server/v2.0/handler/project.go index 047992954..57e1dfb7f 100644 --- a/src/server/v2.0/handler/project.go +++ b/src/server/v2.0/handler/project.go @@ -155,7 +155,7 @@ func (a *projectAPI) CreateProject(ctx context.Context, params operation.CreateP // validate metadata.public value, should only be "true" or "false" if p := req.Metadata.Public; p != "" { if p != "true" && p != "false" { - return a.SendError(ctx, errors.BadRequestError(nil).WithMessage(fmt.Sprintf("metadata.public should only be 'true' or 'false', but got: '%s'", p))) + return a.SendError(ctx, errors.BadRequestError(nil).WithMessagef("metadata.public should only be 'true' or 'false', but got: '%s'", p)) } } @@ -548,11 +548,11 @@ func (a *projectAPI) UpdateProject(ctx context.Context, params operation.UpdateP params.Project.CVEAllowlist.ProjectID = p.ProjectID } else if params.Project.CVEAllowlist.ProjectID != p.ProjectID { return a.SendError(ctx, errors.BadRequestError(nil). - WithMessage("project_id in cve_allowlist must be %d but it's %d", p.ProjectID, params.Project.CVEAllowlist.ProjectID)) + WithMessagef("project_id in cve_allowlist must be %d but it's %d", p.ProjectID, params.Project.CVEAllowlist.ProjectID)) } if err := lib.JSONCopy(&p.CVEAllowlist, params.Project.CVEAllowlist); err != nil { - return a.SendError(ctx, errors.UnknownError(nil).WithMessage("failed to process cve_allowlist, error: %v", err)) + return a.SendError(ctx, errors.UnknownError(nil).WithMessagef("failed to process cve_allowlist, error: %v", err)) } } @@ -578,7 +578,7 @@ func (a *projectAPI) UpdateProject(ctx context.Context, params operation.UpdateP } if rid, ok := md["retention_id"]; !ok || rid != ridParam { errMsg := "the retention_id in the request's payload when updating a project should be omitted, alternatively passing the one that has already been associated to this project" - return a.SendError(ctx, errors.BadRequestError(fmt.Errorf(errMsg))) + return a.SendError(ctx, errors.New(nil).WithMessage(errMsg).WithCode(errors.BadRequestCode)) } } @@ -806,7 +806,7 @@ func (a *projectAPI) validateProjectReq(ctx context.Context, req *models.Project // validate metadata.proxy_speed_kb. It should be an int32 if ps := req.Metadata.ProxySpeedKb; ps != nil { if _, err := strconv.ParseInt(*ps, 10, 32); err != nil { - return errors.BadRequestError(nil).WithMessage(fmt.Sprintf("metadata.proxy_speed_kb should by an int32, but got: '%s', err: %s", *ps, err)) + return errors.BadRequestError(nil).WithMessagef("metadata.proxy_speed_kb should by an int32, but got: '%s', err: %s", *ps, err) } } } diff --git a/src/server/v2.0/handler/project_metadata.go b/src/server/v2.0/handler/project_metadata.go index 7fa297b72..b58c59ffa 100644 --- a/src/server/v2.0/handler/project_metadata.go +++ b/src/server/v2.0/handler/project_metadata.go @@ -146,23 +146,23 @@ func (p *projectMetadataAPI) validate(metas map[string]string) (map[string]strin proModels.ProMetaAutoSBOMGen, proModels.ProMetaPreventVul, proModels.ProMetaAutoScan, proModels.ProMetaReuseSysCVEAllowlist: v, err := strconv.ParseBool(value) if err != nil { - return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid value: %s", value) + return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid value: %s", value) } metas[key] = strconv.FormatBool(v) case proModels.ProMetaSeverity: severity := vuln.ParseSeverityVersion3(strings.ToLower(value)) if severity == vuln.Unknown { - return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid value: %s", value) + return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid value: %s", value) } metas[proModels.ProMetaSeverity] = strings.ToLower(severity.String()) case proModels.ProMetaProxySpeed: v, err := strconv.ParseInt(value, 10, 32) if err != nil { - return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid value: %s", value) + return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid value: %s", value) } metas[proModels.ProMetaProxySpeed] = strconv.FormatInt(v, 10) default: - return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("invalid key: %s", key) + return nil, errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid key: %s", key) } return metas, nil } diff --git a/src/server/v2.0/handler/purge.go b/src/server/v2.0/handler/purge.go index 64d117aed..209418a9e 100644 --- a/src/server/v2.0/handler/purge.go +++ b/src/server/v2.0/handler/purge.go @@ -143,7 +143,7 @@ func (p *purgeAPI) kick(ctx context.Context, vendorType string, scheType string, func (p *purgeAPI) updateSchedule(ctx context.Context, vendorType, cronType, cron string, policy pg.JobPolicy, extraParams map[string]interface{}) error { if err := utils.ValidateCronString(cron); err != nil { return errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid cron string for scheduled log rotation purge: %s, error: %v", cron, err) + WithMessagef("invalid cron string for scheduled log rotation purge: %s, error: %v", cron, err) } if err := p.schedulerCtl.Delete(ctx, vendorType); err != nil { return err @@ -247,7 +247,7 @@ func (p *purgeAPI) GetPurgeJobLog(ctx context.Context, params purge.GetPurgeJobL if len(tasks) == 0 { return p.SendError(ctx, errors.New(nil).WithCode(errors.NotFoundCode). - WithMessage("purge job with execution ID: %d taskLog is not found", params.PurgeID)) + WithMessagef("purge job with execution ID: %d taskLog is not found", params.PurgeID)) } taskLog, err := p.taskCtl.GetLog(ctx, tasks[0].ID) if err != nil { diff --git a/src/server/v2.0/handler/replication.go b/src/server/v2.0/handler/replication.go index e9c64c439..c5c700f67 100644 --- a/src/server/v2.0/handler/replication.go +++ b/src/server/v2.0/handler/replication.go @@ -421,7 +421,7 @@ func (r *replicationAPI) GetReplicationLog(ctx context.Context, params operation if execution.ID != task.ExecutionID { return r.SendError(ctx, errors.New(nil). WithCode(errors.NotFoundCode). - WithMessage("execution %d contains no task with ID %d", params.ID, params.TaskID)) + WithMessagef("execution %d contains no task with ID %d", params.ID, params.TaskID)) } log, err := r.ctl.GetTaskLog(ctx, params.TaskID) if err != nil { diff --git a/src/server/v2.0/handler/retention.go b/src/server/v2.0/handler/retention.go index afe207abe..033e085ab 100644 --- a/src/server/v2.0/handler/retention.go +++ b/src/server/v2.0/handler/retention.go @@ -438,13 +438,13 @@ func (r *retentionAPI) requireExecutionInProject(ctx context.Context, p *policy. return err } if exec == nil { - return errors.New(nil).WithMessage("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) } if exec.PolicyID != p.ID { - return errors.New(nil).WithMessage("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) } if exec.Type != job.RetentionVendorType { - return errors.New(nil).WithMessage("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) } return nil } @@ -458,10 +458,10 @@ func (r *retentionAPI) requireTaskInProject(ctx context.Context, p *policy.Metad return err } if task == nil { - return errors.New(nil).WithMessage("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) } if task.ExecutionID != executionID { - return errors.New(nil).WithMessage("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessagef("project: %d, execution id %d not found", p.Scope.Reference, executionID).WithCode(errors.NotFoundCode) } return nil } diff --git a/src/server/v2.0/handler/robot.go b/src/server/v2.0/handler/robot.go index 119c29fce..5b9cac637 100644 --- a/src/server/v2.0/handler/robot.go +++ b/src/server/v2.0/handler/robot.go @@ -117,7 +117,7 @@ func (rAPI *robotAPI) CreateRobot(ctx context.Context, params operation.CreateRo } if !isValidPermissionScope(params.Robot.Permissions, creatorRobots[0].Permissions) { - return rAPI.SendError(ctx, errors.New(nil).WithMessage("permission scope is invalid. It must be equal to or more restrictive than the creator robot's permissions: %s", creatorRobots[0].Name).WithCode(errors.DENIED)) + return rAPI.SendError(ctx, errors.New(nil).WithMessagef("permission scope is invalid. It must be equal to or more restrictive than the creator robot's permissions: %s", creatorRobots[0].Name).WithCode(errors.DENIED)) } } @@ -333,11 +333,11 @@ func (rAPI *robotAPI) requireAccess(ctx context.Context, r *robot.Robot, action // more validation func (rAPI *robotAPI) validate(d int64, level string, permissions []*models.RobotPermission) error { if !isValidDuration(d) { - return errors.New(nil).WithMessage("bad request error duration input: %d, duration must be either -1(Never) or a positive integer", d).WithCode(errors.BadRequestCode) + return errors.New(nil).WithMessagef("bad request error duration input: %d, duration must be either -1(Never) or a positive integer", d).WithCode(errors.BadRequestCode) } if !isValidLevel(level) { - return errors.New(nil).WithMessage("bad request error level input: %s", level).WithCode(errors.BadRequestCode) + return errors.New(nil).WithMessagef("bad request error level input: %s", level).WithCode(errors.BadRequestCode) } if len(permissions) == 0 { @@ -362,18 +362,18 @@ func (rAPI *robotAPI) validate(d int64, level string, permissions []*models.Robo polices := provider.GetPermissions(rbac.ScopeSystem) for _, acc := range perm.Access { if !containsAccess(polices, acc) { - return errors.New(nil).WithMessage("bad request permission: %s:%s", acc.Resource, acc.Action).WithCode(errors.BadRequestCode) + return errors.New(nil).WithMessagef("bad request permission: %s:%s", acc.Resource, acc.Action).WithCode(errors.BadRequestCode) } } } else if perm.Kind == robot.LEVELPROJECT { polices := provider.GetPermissions(rbac.ScopeProject) for _, acc := range perm.Access { if !containsAccess(polices, acc) { - return errors.New(nil).WithMessage("bad request permission: %s:%s", acc.Resource, acc.Action).WithCode(errors.BadRequestCode) + return errors.New(nil).WithMessagef("bad request permission: %s:%s", acc.Resource, acc.Action).WithCode(errors.BadRequestCode) } } } else { - return errors.New(nil).WithMessage("bad request permission level: %s", perm.Kind).WithCode(errors.BadRequestCode) + return errors.New(nil).WithMessagef("bad request permission level: %s", perm.Kind).WithCode(errors.BadRequestCode) } } @@ -453,7 +453,7 @@ func (rAPI *robotAPI) updateV2Robot(ctx context.Context, params operation.Update } if !isValidPermissionScope(params.Robot.Permissions, creatorRobot.Permissions) { - return errors.New(nil).WithMessage("permission scope is invalid. It must be equal to or more restrictive than the creator robot's permissions: %s", creatorRobot.Name).WithCode(errors.DENIED) + return errors.New(nil).WithMessagef("permission scope is invalid. It must be equal to or more restrictive than the creator robot's permissions: %s", creatorRobot.Name).WithCode(errors.DENIED) } } diff --git a/src/server/v2.0/handler/robotV1.go b/src/server/v2.0/handler/robotV1.go index f8ce74b10..885e96e32 100644 --- a/src/server/v2.0/handler/robotV1.go +++ b/src/server/v2.0/handler/robotV1.go @@ -274,7 +274,7 @@ func (rAPI *robotV1API) validate(ctx context.Context, params operation.CreateRob log.Warningf("failed to call JSONCopy on robot access policy when validate, error: %v", err) } if !mp[p.String()] { - return errors.New(nil).WithMessage("%s action of %s resource not exist in project %s", policy.Action, policy.Resource, projectNameOrID).WithCode(errors.BadRequestCode) + return errors.New(nil).WithMessagef("%s action of %s resource not exist in project %s", policy.Action, policy.Resource, projectNameOrID).WithCode(errors.BadRequestCode) } } @@ -286,7 +286,7 @@ func getRawResource(resource string) (string, error) { resourceReg := regexp.MustCompile("^/project/[0-9]+/(?P[a-z-]+)$") matches := resourceReg.FindStringSubmatch(resource) if len(matches) <= 1 { - return "", errors.New(nil).WithMessage("bad resource %s", resource).WithCode(errors.BadRequestCode) + return "", errors.New(nil).WithMessagef("bad resource %s", resource).WithCode(errors.BadRequestCode) } return matches[1], nil } diff --git a/src/server/v2.0/handler/scan.go b/src/server/v2.0/handler/scan.go index a22eaaaed..e3c74d6c2 100644 --- a/src/server/v2.0/handler/scan.go +++ b/src/server/v2.0/handler/scan.go @@ -123,7 +123,7 @@ func (s *scanAPI) GetReportLog(ctx context.Context, params operation.GetReportLo if bytes == nil { // Not found - return s.SendError(ctx, errors.NotFoundError(nil).WithMessage("report with uuid %s does not exist", params.ReportID)) + return s.SendError(ctx, errors.NotFoundError(nil).WithMessagef("report with uuid %s does not exist", params.ReportID)) } return operation.NewGetReportLogOK().WithPayload(string(bytes)) diff --git a/src/server/v2.0/handler/scan_all.go b/src/server/v2.0/handler/scan_all.go index 3e9ed1bf0..469e3520b 100644 --- a/src/server/v2.0/handler/scan_all.go +++ b/src/server/v2.0/handler/scan_all.go @@ -134,8 +134,7 @@ func (s *scanAllAPI) UpdateScanAllSchedule(ctx context.Context, params operation req := params.Schedule if req.Schedule.Type == ScheduleManual { - message := fmt.Sprintf("fail to update scan all schedule as wrong schedule type: %s", req.Schedule.Type) - return s.SendError(ctx, errors.BadRequestError(nil).WithMessage(message)) + return s.SendError(ctx, errors.BadRequestError(nil).WithMessagef("fail to update scan all schedule as wrong schedule type: %s", req.Schedule.Type)) } schedule, err := s.getScanAllSchedule(ctx) @@ -197,7 +196,7 @@ func (s *scanAllAPI) GetLatestScheduledScanAllMetrics(ctx context.Context, _ ope func (s *scanAllAPI) createOrUpdateScanAllSchedule(ctx context.Context, cronType, cron string, previous *scheduler.Schedule) (int64, error) { if err := utils.ValidateCronString(cron); err != nil { return 0, errors.New(nil).WithCode(errors.BadRequestCode). - WithMessage("invalid cron string for scheduled scan all: %s, error: %v", cron, err) + WithMessagef("invalid cron string for scheduled scan all: %s, error: %v", cron, err) } if previous != nil { if cronType == previous.CRONType && cron == previous.CRON { diff --git a/src/server/v2.0/handler/scanexport.go b/src/server/v2.0/handler/scanexport.go index 520c66f81..09c5e0580 100644 --- a/src/server/v2.0/handler/scanexport.go +++ b/src/server/v2.0/handler/scanexport.go @@ -164,7 +164,7 @@ func (se *scanDataExportAPI) DownloadScanData(ctx context.Context, params operat execution, err := se.scanDataExportCtl.GetExecution(ctx, params.ExecutionID) if err != nil { if notFound := orm.AsNotFoundError(err, "execution with id: %d not found", params.ExecutionID); notFound != nil { - return middleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) { + return middleware.ResponderFunc(func(writer http.ResponseWriter, _ runtime.Producer) { writer.WriteHeader(http.StatusNotFound) }) } @@ -183,14 +183,14 @@ func (se *scanDataExportAPI) DownloadScanData(ctx context.Context, params operat } if secContext.GetUsername() != execution.UserName { - return middleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) { + return middleware.ResponderFunc(func(writer http.ResponseWriter, _ runtime.Producer) { writer.WriteHeader(http.StatusForbidden) }) } // check if the CSV artifact for the execution exists if !execution.FilePresent { - return middleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) { + return middleware.ResponderFunc(func(writer http.ResponseWriter, _ runtime.Producer) { writer.WriteHeader(http.StatusNotFound) }) } @@ -202,7 +202,7 @@ func (se *scanDataExportAPI) DownloadScanData(ctx context.Context, params operat } log.Infof("reading data from file : %s", repositoryName) - return middleware.ResponderFunc(func(writer http.ResponseWriter, producer runtime.Producer) { + return middleware.ResponderFunc(func(writer http.ResponseWriter, _ runtime.Producer) { defer se.cleanUpArtifact(ctx, repositoryName, execution.ExportDataDigest, params.ExecutionID, file) writer.Header().Set("Content-Type", "text/csv") diff --git a/src/server/v2.0/handler/scanner.go b/src/server/v2.0/handler/scanner.go index 3b5be4f45..89f674974 100644 --- a/src/server/v2.0/handler/scanner.go +++ b/src/server/v2.0/handler/scanner.go @@ -74,13 +74,13 @@ func (s *scannerAPI) DeleteScanner(ctx context.Context, params operation.DeleteS } if r == nil { - return s.SendError(ctx, errors.NotFoundError(nil).WithMessage("scanner %s not found", params.RegistrationID)) + return s.SendError(ctx, errors.NotFoundError(nil).WithMessagef("scanner %s not found", params.RegistrationID)) } // Immutable registration is not allowed if r.Immutable { format := "registration %s is not allowed to delete as it is immutable: scanner API: delete" - return s.SendError(ctx, errors.ForbiddenError(nil).WithMessage(format, r.Name)) + return s.SendError(ctx, errors.ForbiddenError(nil).WithMessagef(format, r.Name)) } deleted, err := s.scannerCtl.DeleteRegistration(ctx, r.UUID) @@ -102,7 +102,7 @@ func (s *scannerAPI) GetScanner(ctx context.Context, params operation.GetScanner } if r == nil { - return s.SendError(ctx, errors.NotFoundError(nil).WithMessage("scanner %s not found", params.RegistrationID)) + return s.SendError(ctx, errors.NotFoundError(nil).WithMessagef("scanner %s not found", params.RegistrationID)) } return operation.NewGetScannerOK().WithPayload(model.NewScannerRegistration(r).ToSwagger(ctx)) @@ -214,13 +214,13 @@ func (s *scannerAPI) UpdateScanner(ctx context.Context, params operation.UpdateS } if r == nil { - return s.SendError(ctx, errors.NotFoundError(nil).WithMessage("scanner %s not found", params.RegistrationID)) + return s.SendError(ctx, errors.NotFoundError(nil).WithMessagef("scanner %s not found", params.RegistrationID)) } // Immutable registration is not allowed if r.Immutable { format := "registration %s is not allowed to update as it is immutable: scanner API: update" - return s.SendError(ctx, errors.ForbiddenError(nil).WithMessage(format, r.Name)) + return s.SendError(ctx, errors.ForbiddenError(nil).WithMessagef(format, r.Name)) } copyToScannerRegistration(r, params.Registration) diff --git a/src/server/v2.0/handler/user.go b/src/server/v2.0/handler/user.go index 1bbe3b7ad..05b1e51db 100644 --- a/src/server/v2.0/handler/user.go +++ b/src/server/v2.0/handler/user.go @@ -200,7 +200,7 @@ func (u *usersAPI) GetCurrentUserInfo(ctx context.Context, _ operation.GetCurren sctx, _ := security.FromContext(ctx) lsc, ok := sctx.(*local.SecurityContext) if !ok { - return u.SendError(ctx, errors.PreconditionFailedError(nil).WithMessage("get current user not available for security context: %s", sctx.Name())) + return u.SendError(ctx, errors.PreconditionFailedError(nil).WithMessagef("get current user not available for security context: %s", sctx.Name())) } resp, err := u.getUserByID(ctx, lsc.User().UserID) if err != nil { @@ -356,14 +356,14 @@ func (u *usersAPI) requireForCLISecret(ctx context.Context, id int) error { return err } if a != common.OIDCAuth { - return errors.PreconditionFailedError(nil).WithMessage("unable to update CLI secret under authmode: %s", a) + return errors.PreconditionFailedError(nil).WithMessagef("unable to update CLI secret under authmode: %s", a) } sctx, ok := security.FromContext(ctx) if !ok || !sctx.IsAuthenticated() { return errors.UnauthorizedError(nil) } if !matchUserID(sctx, id) && !sctx.Can(ctx, rbac.ActionUpdate, rbac.ResourceUser) { - return errors.ForbiddenError(nil).WithMessage("Not authorized to update the CLI secret for user: %d", id) + return errors.ForbiddenError(nil).WithMessagef("Not authorized to update the CLI secret for user: %d", id) } return nil } @@ -375,7 +375,7 @@ func (u *usersAPI) requireCreatable(ctx context.Context) error { return err } if a != common.DBAuth { - return errors.ForbiddenError(nil).WithMessage("creating local user is not allowed under auth mode: %s", a) + return errors.ForbiddenError(nil).WithMessagef("creating local user is not allowed under auth mode: %s", a) } sr, err := config.SelfRegistration(ctx) if err != nil { @@ -398,7 +398,7 @@ func (u *usersAPI) requireReadable(ctx context.Context, id int) error { return errors.UnauthorizedError(nil) } if !matchUserID(sctx, id) && !sctx.Can(ctx, rbac.ActionRead, rbac.ResourceUser) { - return errors.ForbiddenError(nil).WithMessage("Not authorized to read user: %d", id) + return errors.ForbiddenError(nil).WithMessagef("Not authorized to read user: %d", id) } return nil } @@ -412,7 +412,7 @@ func (u *usersAPI) requireDeletable(ctx context.Context, id int) error { return errors.ForbiddenError(nil).WithMessage("Not authorized to delete users") } if matchUserID(sctx, id) || id == 1 { - return errors.ForbiddenError(nil).WithMessage("User with ID %d cannot be deleted", id) + return errors.ForbiddenError(nil).WithMessagef("User with ID %d cannot be deleted", id) } return nil } @@ -427,7 +427,7 @@ func (u *usersAPI) requireModifiable(ctx context.Context, id int) error { return errors.UnauthorizedError(nil) } if !modifiable(ctx, a, id) { - return errors.ForbiddenError(nil).WithMessage("User with ID %d can't be updated", id) + return errors.ForbiddenError(nil).WithMessagef("User with ID %d can't be updated", id) } return nil } diff --git a/src/server/v2.0/handler/usergroup.go b/src/server/v2.0/handler/usergroup.go index 187bc0b59..f2a5f26ea 100644 --- a/src/server/v2.0/handler/usergroup.go +++ b/src/server/v2.0/handler/usergroup.go @@ -92,7 +92,7 @@ func (u *userGroupAPI) GetUserGroup(ctx context.Context, params operation.GetUse return u.SendError(ctx, err) } if ug == nil { - return u.SendError(ctx, errors.NotFoundError(nil).WithMessage("the user group with id %v is not found", params.GroupID)) + return u.SendError(ctx, errors.NotFoundError(nil).WithMessagef("the user group with id %v is not found", params.GroupID)) } userGroup := &models.UserGroup{ GroupName: ug.GroupName, diff --git a/src/server/v2.0/handler/webhook.go b/src/server/v2.0/handler/webhook.go index 773864b9f..a77a30a01 100644 --- a/src/server/v2.0/handler/webhook.go +++ b/src/server/v2.0/handler/webhook.go @@ -404,7 +404,7 @@ func (n *webhookAPI) GetSupportedEventTypes(ctx context.Context, params webhook. func (n *webhookAPI) validateTargets(policy *policy_model.Policy) (bool, error) { if len(policy.Targets) == 0 { - return false, errors.New(nil).WithMessage("empty notification target with policy %s", policy.Name).WithCode(errors.BadRequestCode) + return false, errors.New(nil).WithMessagef("empty notification target with policy %s", policy.Name).WithCode(errors.BadRequestCode) } for i, target := range policy.Targets { url, err := utils.ParseEndpoint(target.Address) @@ -415,7 +415,7 @@ func (n *webhookAPI) validateTargets(policy *policy_model.Policy) (bool, error) target.Address = url.Scheme + "://" + url.Host + url.Path if !isNotifyTypeSupported(target.Type) { - return false, errors.New(nil).WithMessage("unsupported target type %s with policy %s", target.Type, policy.Name).WithCode(errors.BadRequestCode) + return false, errors.New(nil).WithMessagef("unsupported target type %s with policy %s", target.Type, policy.Name).WithCode(errors.BadRequestCode) } // don't allow set the payload format for slack type // slack should be migrated as a kind of payload in the future @@ -424,7 +424,7 @@ func (n *webhookAPI) validateTargets(policy *policy_model.Policy) (bool, error) } if len(target.PayloadFormat) > 0 && !isPayloadFormatSupported(target.PayloadFormat) { - return false, errors.New(nil).WithMessage("unsupported payload format type: %s", target.PayloadFormat).WithCode(errors.BadRequestCode) + return false, errors.New(nil).WithMessagef("unsupported payload format type: %s", target.PayloadFormat).WithCode(errors.BadRequestCode) } // set payload format to Default is not specified when the type is http if len(target.PayloadFormat) == 0 && target.Type == "http" { @@ -440,7 +440,7 @@ func (n *webhookAPI) validateEventTypes(policy *policy_model.Policy) (bool, erro } for _, eventType := range policy.EventTypes { if !isEventTypeSupported(eventType) { - return false, errors.New(nil).WithMessage("unsupported event type %s", eventType).WithCode(errors.BadRequestCode) + return false, errors.New(nil).WithMessagef("unsupported event type %s", eventType).WithCode(errors.BadRequestCode) } } return true, nil diff --git a/src/testing/common/security/context.go b/src/testing/common/security/context.go index f277d19d7..29fbf99a7 100644 --- a/src/testing/common/security/context.go +++ b/src/testing/common/security/context.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package security diff --git a/src/testing/controller/artifact/controller.go b/src/testing/controller/artifact/controller.go index 3ec563103..85c37c310 100644 --- a/src/testing/controller/artifact/controller.go +++ b/src/testing/controller/artifact/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package artifact diff --git a/src/testing/controller/blob/controller.go b/src/testing/controller/blob/controller.go index ba8fcc706..de097f96e 100644 --- a/src/testing/controller/blob/controller.go +++ b/src/testing/controller/blob/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package blob @@ -11,7 +11,7 @@ import ( mock "github.com/stretchr/testify/mock" - models "github.com/goharbor/harbor/src/pkg/blob/models" + pkgblob "github.com/goharbor/harbor/src/pkg/blob" q "github.com/goharbor/harbor/src/lib/q" ) @@ -213,7 +213,7 @@ func (_m *Controller) Exist(ctx context.Context, digest string, options ...blob. } // Fail provides a mock function with given fields: ctx, _a1 -func (_m *Controller) Fail(ctx context.Context, _a1 *models.Blob) error { +func (_m *Controller) Fail(ctx context.Context, _a1 *pkgblob.Blob) error { ret := _m.Called(ctx, _a1) if len(ret) == 0 { @@ -221,7 +221,7 @@ func (_m *Controller) Fail(ctx context.Context, _a1 *models.Blob) error { } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *models.Blob) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *pkgblob.Blob) error); ok { r0 = rf(ctx, _a1) } else { r0 = ret.Error(0) @@ -231,27 +231,27 @@ func (_m *Controller) Fail(ctx context.Context, _a1 *models.Blob) error { } // FindMissingAssociationsForProject provides a mock function with given fields: ctx, projectID, blobs -func (_m *Controller) FindMissingAssociationsForProject(ctx context.Context, projectID int64, blobs []*models.Blob) ([]*models.Blob, error) { +func (_m *Controller) FindMissingAssociationsForProject(ctx context.Context, projectID int64, blobs []*pkgblob.Blob) ([]*pkgblob.Blob, error) { ret := _m.Called(ctx, projectID, blobs) if len(ret) == 0 { panic("no return value specified for FindMissingAssociationsForProject") } - var r0 []*models.Blob + var r0 []*pkgblob.Blob var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int64, []*models.Blob) ([]*models.Blob, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, []*pkgblob.Blob) ([]*pkgblob.Blob, error)); ok { return rf(ctx, projectID, blobs) } - if rf, ok := ret.Get(0).(func(context.Context, int64, []*models.Blob) []*models.Blob); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, []*pkgblob.Blob) []*pkgblob.Blob); ok { r0 = rf(ctx, projectID, blobs) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*models.Blob) + r0 = ret.Get(0).([]*pkgblob.Blob) } } - if rf, ok := ret.Get(1).(func(context.Context, int64, []*models.Blob) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, int64, []*pkgblob.Blob) error); ok { r1 = rf(ctx, projectID, blobs) } else { r1 = ret.Error(1) @@ -261,7 +261,7 @@ func (_m *Controller) FindMissingAssociationsForProject(ctx context.Context, pro } // Get provides a mock function with given fields: ctx, digest, options -func (_m *Controller) Get(ctx context.Context, digest string, options ...blob.Option) (*models.Blob, error) { +func (_m *Controller) Get(ctx context.Context, digest string, options ...blob.Option) (*pkgblob.Blob, error) { _va := make([]interface{}, len(options)) for _i := range options { _va[_i] = options[_i] @@ -275,16 +275,16 @@ func (_m *Controller) Get(ctx context.Context, digest string, options ...blob.Op panic("no return value specified for Get") } - var r0 *models.Blob + var r0 *pkgblob.Blob var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, ...blob.Option) (*models.Blob, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...blob.Option) (*pkgblob.Blob, error)); ok { return rf(ctx, digest, options...) } - if rf, ok := ret.Get(0).(func(context.Context, string, ...blob.Option) *models.Blob); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, ...blob.Option) *pkgblob.Blob); ok { r0 = rf(ctx, digest, options...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*models.Blob) + r0 = ret.Get(0).(*pkgblob.Blob) } } @@ -326,23 +326,23 @@ func (_m *Controller) GetAcceptedBlobSize(ctx context.Context, sessionID string) } // List provides a mock function with given fields: ctx, query -func (_m *Controller) List(ctx context.Context, query *q.Query) ([]*models.Blob, error) { +func (_m *Controller) List(ctx context.Context, query *q.Query) ([]*pkgblob.Blob, error) { ret := _m.Called(ctx, query) if len(ret) == 0 { panic("no return value specified for List") } - var r0 []*models.Blob + var r0 []*pkgblob.Blob var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*models.Blob, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*pkgblob.Blob, error)); ok { return rf(ctx, query) } - if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*models.Blob); ok { + if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*pkgblob.Blob); ok { r0 = rf(ctx, query) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*models.Blob) + r0 = ret.Get(0).([]*pkgblob.Blob) } } @@ -392,7 +392,7 @@ func (_m *Controller) Sync(ctx context.Context, references []distribution.Descri } // Touch provides a mock function with given fields: ctx, _a1 -func (_m *Controller) Touch(ctx context.Context, _a1 *models.Blob) error { +func (_m *Controller) Touch(ctx context.Context, _a1 *pkgblob.Blob) error { ret := _m.Called(ctx, _a1) if len(ret) == 0 { @@ -400,7 +400,7 @@ func (_m *Controller) Touch(ctx context.Context, _a1 *models.Blob) error { } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *models.Blob) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *pkgblob.Blob) error); ok { r0 = rf(ctx, _a1) } else { r0 = ret.Error(0) @@ -410,7 +410,7 @@ func (_m *Controller) Touch(ctx context.Context, _a1 *models.Blob) error { } // Update provides a mock function with given fields: ctx, _a1 -func (_m *Controller) Update(ctx context.Context, _a1 *models.Blob) error { +func (_m *Controller) Update(ctx context.Context, _a1 *pkgblob.Blob) error { ret := _m.Called(ctx, _a1) if len(ret) == 0 { @@ -418,7 +418,7 @@ func (_m *Controller) Update(ctx context.Context, _a1 *models.Blob) error { } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *models.Blob) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *pkgblob.Blob) error); ok { r0 = rf(ctx, _a1) } else { r0 = ret.Error(0) diff --git a/src/testing/controller/config/controller.go b/src/testing/controller/config/controller.go index 0b6205200..e564efcbf 100644 --- a/src/testing/controller/config/controller.go +++ b/src/testing/controller/config/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package config diff --git a/src/testing/controller/jobservice/scheduler_controller.go b/src/testing/controller/jobservice/scheduler_controller.go index 1d9eea5c9..58e464726 100644 --- a/src/testing/controller/jobservice/scheduler_controller.go +++ b/src/testing/controller/jobservice/scheduler_controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package jobservice diff --git a/src/testing/controller/project/controller.go b/src/testing/controller/project/controller.go index c95d06791..eefa8a94b 100644 --- a/src/testing/controller/project/controller.go +++ b/src/testing/controller/project/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package project diff --git a/src/testing/controller/proxy/remote_interface.go b/src/testing/controller/proxy/remote_interface.go index dbe085f70..b25fcd6b4 100644 --- a/src/testing/controller/proxy/remote_interface.go +++ b/src/testing/controller/proxy/remote_interface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package proxy diff --git a/src/testing/controller/purge/controller.go b/src/testing/controller/purge/controller.go index 08416914b..935b8e0d5 100644 --- a/src/testing/controller/purge/controller.go +++ b/src/testing/controller/purge/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package purge diff --git a/src/testing/controller/quota/controller.go b/src/testing/controller/quota/controller.go index 14dbd1412..911d34fcb 100644 --- a/src/testing/controller/quota/controller.go +++ b/src/testing/controller/quota/controller.go @@ -1,11 +1,11 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package quota import ( context "context" - models "github.com/goharbor/harbor/src/pkg/quota/models" + pkgquota "github.com/goharbor/harbor/src/pkg/quota" mock "github.com/stretchr/testify/mock" q "github.com/goharbor/harbor/src/lib/q" @@ -102,7 +102,7 @@ func (_m *Controller) Delete(ctx context.Context, id int64) error { } // Get provides a mock function with given fields: ctx, id, options -func (_m *Controller) Get(ctx context.Context, id int64, options ...quota.Option) (*models.Quota, error) { +func (_m *Controller) Get(ctx context.Context, id int64, options ...quota.Option) (*pkgquota.Quota, error) { _va := make([]interface{}, len(options)) for _i := range options { _va[_i] = options[_i] @@ -116,16 +116,16 @@ func (_m *Controller) Get(ctx context.Context, id int64, options ...quota.Option panic("no return value specified for Get") } - var r0 *models.Quota + var r0 *pkgquota.Quota var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int64, ...quota.Option) (*models.Quota, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, ...quota.Option) (*pkgquota.Quota, error)); ok { return rf(ctx, id, options...) } - if rf, ok := ret.Get(0).(func(context.Context, int64, ...quota.Option) *models.Quota); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, ...quota.Option) *pkgquota.Quota); ok { r0 = rf(ctx, id, options...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*models.Quota) + r0 = ret.Get(0).(*pkgquota.Quota) } } @@ -139,7 +139,7 @@ func (_m *Controller) Get(ctx context.Context, id int64, options ...quota.Option } // GetByRef provides a mock function with given fields: ctx, reference, referenceID, options -func (_m *Controller) GetByRef(ctx context.Context, reference string, referenceID string, options ...quota.Option) (*models.Quota, error) { +func (_m *Controller) GetByRef(ctx context.Context, reference string, referenceID string, options ...quota.Option) (*pkgquota.Quota, error) { _va := make([]interface{}, len(options)) for _i := range options { _va[_i] = options[_i] @@ -153,16 +153,16 @@ func (_m *Controller) GetByRef(ctx context.Context, reference string, referenceI panic("no return value specified for GetByRef") } - var r0 *models.Quota + var r0 *pkgquota.Quota var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, ...quota.Option) (*models.Quota, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...quota.Option) (*pkgquota.Quota, error)); ok { return rf(ctx, reference, referenceID, options...) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, ...quota.Option) *models.Quota); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string, ...quota.Option) *pkgquota.Quota); ok { r0 = rf(ctx, reference, referenceID, options...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*models.Quota) + r0 = ret.Get(0).(*pkgquota.Quota) } } @@ -204,7 +204,7 @@ func (_m *Controller) IsEnabled(ctx context.Context, reference string, reference } // List provides a mock function with given fields: ctx, query, options -func (_m *Controller) List(ctx context.Context, query *q.Query, options ...quota.Option) ([]*models.Quota, error) { +func (_m *Controller) List(ctx context.Context, query *q.Query, options ...quota.Option) ([]*pkgquota.Quota, error) { _va := make([]interface{}, len(options)) for _i := range options { _va[_i] = options[_i] @@ -218,16 +218,16 @@ func (_m *Controller) List(ctx context.Context, query *q.Query, options ...quota panic("no return value specified for List") } - var r0 []*models.Quota + var r0 []*pkgquota.Quota var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *q.Query, ...quota.Option) ([]*models.Quota, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *q.Query, ...quota.Option) ([]*pkgquota.Quota, error)); ok { return rf(ctx, query, options...) } - if rf, ok := ret.Get(0).(func(context.Context, *q.Query, ...quota.Option) []*models.Quota); ok { + if rf, ok := ret.Get(0).(func(context.Context, *q.Query, ...quota.Option) []*pkgquota.Quota); ok { r0 = rf(ctx, query, options...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*models.Quota) + r0 = ret.Get(0).([]*pkgquota.Quota) } } @@ -284,7 +284,7 @@ func (_m *Controller) Request(ctx context.Context, reference string, referenceID } // Update provides a mock function with given fields: ctx, _a1 -func (_m *Controller) Update(ctx context.Context, _a1 *models.Quota) error { +func (_m *Controller) Update(ctx context.Context, _a1 *pkgquota.Quota) error { ret := _m.Called(ctx, _a1) if len(ret) == 0 { @@ -292,7 +292,7 @@ func (_m *Controller) Update(ctx context.Context, _a1 *models.Quota) error { } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *models.Quota) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *pkgquota.Quota) error); ok { r0 = rf(ctx, _a1) } else { r0 = ret.Error(0) diff --git a/src/testing/controller/replication/controller.go b/src/testing/controller/replication/controller.go index 8d4dc5ab2..4654cbf66 100644 --- a/src/testing/controller/replication/controller.go +++ b/src/testing/controller/replication/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package replication diff --git a/src/testing/controller/repository/controller.go b/src/testing/controller/repository/controller.go index 445bc5872..bfd0561c5 100644 --- a/src/testing/controller/repository/controller.go +++ b/src/testing/controller/repository/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package repository diff --git a/src/testing/controller/retention/controller.go b/src/testing/controller/retention/controller.go index 907b90196..29dfdbb8a 100644 --- a/src/testing/controller/retention/controller.go +++ b/src/testing/controller/retention/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package retention diff --git a/src/testing/controller/robot/controller.go b/src/testing/controller/robot/controller.go index 735f5df09..442c7fb91 100644 --- a/src/testing/controller/robot/controller.go +++ b/src/testing/controller/robot/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package robot diff --git a/src/testing/controller/scan/checker.go b/src/testing/controller/scan/checker.go index 7af46b09b..66d2a8ece 100644 --- a/src/testing/controller/scan/checker.go +++ b/src/testing/controller/scan/checker.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package scan diff --git a/src/testing/controller/scan/controller.go b/src/testing/controller/scan/controller.go index dad2b5dbf..70af6fd87 100644 --- a/src/testing/controller/scan/controller.go +++ b/src/testing/controller/scan/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package scan diff --git a/src/testing/controller/scandataexport/controller.go b/src/testing/controller/scandataexport/controller.go index 4fdf81b26..b63e8f13d 100644 --- a/src/testing/controller/scandataexport/controller.go +++ b/src/testing/controller/scandataexport/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package scandataexport diff --git a/src/testing/controller/scanner/controller.go b/src/testing/controller/scanner/controller.go index 403f4d807..64eaf4c3d 100644 --- a/src/testing/controller/scanner/controller.go +++ b/src/testing/controller/scanner/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package scanner diff --git a/src/testing/controller/securityhub/controller.go b/src/testing/controller/securityhub/controller.go index 7df099827..714df1427 100644 --- a/src/testing/controller/securityhub/controller.go +++ b/src/testing/controller/securityhub/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package securityhub diff --git a/src/testing/controller/systemartifact/controller.go b/src/testing/controller/systemartifact/controller.go index d533c629c..9d72db40c 100644 --- a/src/testing/controller/systemartifact/controller.go +++ b/src/testing/controller/systemartifact/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package systemartifact diff --git a/src/testing/controller/task/controller.go b/src/testing/controller/task/controller.go index 7a6072832..f296b68ed 100644 --- a/src/testing/controller/task/controller.go +++ b/src/testing/controller/task/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/testing/controller/task/execution_controller.go b/src/testing/controller/task/execution_controller.go index 9488a76f0..1b634b60a 100644 --- a/src/testing/controller/task/execution_controller.go +++ b/src/testing/controller/task/execution_controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/testing/controller/user/controller.go b/src/testing/controller/user/controller.go index a0325fa2b..5177d9d7b 100644 --- a/src/testing/controller/user/controller.go +++ b/src/testing/controller/user/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package user diff --git a/src/testing/controller/webhook/controller.go b/src/testing/controller/webhook/controller.go index e265fb033..aeb7a105c 100644 --- a/src/testing/controller/webhook/controller.go +++ b/src/testing/controller/webhook/controller.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package webhook diff --git a/src/testing/lib/cache/cache.go b/src/testing/lib/cache/cache.go index 2faca2d6c..3193798f5 100644 --- a/src/testing/lib/cache/cache.go +++ b/src/testing/lib/cache/cache.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package cache diff --git a/src/testing/lib/cache/iterator.go b/src/testing/lib/cache/iterator.go index 65daab833..d57732cc2 100644 --- a/src/testing/lib/cache/iterator.go +++ b/src/testing/lib/cache/iterator.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package cache diff --git a/src/testing/lib/config/manager.go b/src/testing/lib/config/manager.go index c692e3a3f..c81aafd85 100644 --- a/src/testing/lib/config/manager.go +++ b/src/testing/lib/config/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package config diff --git a/src/testing/lib/orm/creator.go b/src/testing/lib/orm/creator.go index c05dbf761..818eb25b4 100644 --- a/src/testing/lib/orm/creator.go +++ b/src/testing/lib/orm/creator.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package orm diff --git a/src/testing/pkg/accessory/dao/dao.go b/src/testing/pkg/accessory/dao/dao.go index d7a109b68..3a7d99448 100644 --- a/src/testing/pkg/accessory/dao/dao.go +++ b/src/testing/pkg/accessory/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/accessory/manager.go b/src/testing/pkg/accessory/manager.go index f3688f784..777d4aebb 100644 --- a/src/testing/pkg/accessory/manager.go +++ b/src/testing/pkg/accessory/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package accessory diff --git a/src/testing/pkg/accessory/model/accessory.go b/src/testing/pkg/accessory/model/accessory.go index c0ee08fa9..22169f1fc 100644 --- a/src/testing/pkg/accessory/model/accessory.go +++ b/src/testing/pkg/accessory/model/accessory.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package model diff --git a/src/testing/pkg/allowlist/dao/dao.go b/src/testing/pkg/allowlist/dao/dao.go index 850201b8f..9da59fae7 100644 --- a/src/testing/pkg/allowlist/dao/dao.go +++ b/src/testing/pkg/allowlist/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/allowlist/manager.go b/src/testing/pkg/allowlist/manager.go index 00cfcae31..69aef79dd 100644 --- a/src/testing/pkg/allowlist/manager.go +++ b/src/testing/pkg/allowlist/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package allowlist diff --git a/src/testing/pkg/artifact/manager.go b/src/testing/pkg/artifact/manager.go index a189685cc..502e2ed7f 100644 --- a/src/testing/pkg/artifact/manager.go +++ b/src/testing/pkg/artifact/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package artifact diff --git a/src/testing/pkg/artifactrash/manager.go b/src/testing/pkg/artifactrash/manager.go index de70e91a2..5d96bbea7 100644 --- a/src/testing/pkg/artifactrash/manager.go +++ b/src/testing/pkg/artifactrash/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package artifactrash diff --git a/src/testing/pkg/audit/dao/dao.go b/src/testing/pkg/audit/dao/dao.go index b90655034..f95e34b5b 100644 --- a/src/testing/pkg/audit/dao/dao.go +++ b/src/testing/pkg/audit/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/audit/manager.go b/src/testing/pkg/audit/manager.go index cf3524c02..3002c9d76 100644 --- a/src/testing/pkg/audit/manager.go +++ b/src/testing/pkg/audit/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package audit diff --git a/src/testing/pkg/blob/manager.go b/src/testing/pkg/blob/manager.go index 01bc65742..78de29dac 100644 --- a/src/testing/pkg/blob/manager.go +++ b/src/testing/pkg/blob/manager.go @@ -1,13 +1,16 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package blob import ( context "context" - models "github.com/goharbor/harbor/src/pkg/blob/models" + blob "github.com/goharbor/harbor/src/pkg/blob" + mock "github.com/stretchr/testify/mock" + models "github.com/goharbor/harbor/src/pkg/blob/models" + q "github.com/goharbor/harbor/src/lib/q" ) @@ -147,7 +150,7 @@ func (_m *Manager) CleanupAssociationsForArtifact(ctx context.Context, artifactD } // CleanupAssociationsForProject provides a mock function with given fields: ctx, projectID, blobs -func (_m *Manager) CleanupAssociationsForProject(ctx context.Context, projectID int64, blobs []*models.Blob) error { +func (_m *Manager) CleanupAssociationsForProject(ctx context.Context, projectID int64, blobs []*blob.Blob) error { ret := _m.Called(ctx, projectID, blobs) if len(ret) == 0 { @@ -155,7 +158,7 @@ func (_m *Manager) CleanupAssociationsForProject(ctx context.Context, projectID } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, int64, []*models.Blob) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64, []*blob.Blob) error); ok { r0 = rf(ctx, projectID, blobs) } else { r0 = ret.Error(0) @@ -241,23 +244,23 @@ func (_m *Manager) FindBlobsShouldUnassociatedWithProject(ctx context.Context, p } // Get provides a mock function with given fields: ctx, digest -func (_m *Manager) Get(ctx context.Context, digest string) (*models.Blob, error) { +func (_m *Manager) Get(ctx context.Context, digest string) (*blob.Blob, error) { ret := _m.Called(ctx, digest) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *models.Blob + var r0 *blob.Blob var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*models.Blob, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) (*blob.Blob, error)); ok { return rf(ctx, digest) } - if rf, ok := ret.Get(0).(func(context.Context, string) *models.Blob); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) *blob.Blob); ok { r0 = rf(ctx, digest) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*models.Blob) + r0 = ret.Get(0).(*blob.Blob) } } @@ -301,23 +304,23 @@ func (_m *Manager) GetByArt(ctx context.Context, digest string) ([]*models.Blob, } // List provides a mock function with given fields: ctx, query -func (_m *Manager) List(ctx context.Context, query *q.Query) ([]*models.Blob, error) { +func (_m *Manager) List(ctx context.Context, query *q.Query) ([]*blob.Blob, error) { ret := _m.Called(ctx, query) if len(ret) == 0 { panic("no return value specified for List") } - var r0 []*models.Blob + var r0 []*blob.Blob var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*models.Blob, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*blob.Blob, error)); ok { return rf(ctx, query) } - if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*models.Blob); ok { + if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*blob.Blob); ok { r0 = rf(ctx, query) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*models.Blob) + r0 = ret.Get(0).([]*blob.Blob) } } @@ -331,7 +334,7 @@ func (_m *Manager) List(ctx context.Context, query *q.Query) ([]*models.Blob, er } // Update provides a mock function with given fields: ctx, _a1 -func (_m *Manager) Update(ctx context.Context, _a1 *models.Blob) error { +func (_m *Manager) Update(ctx context.Context, _a1 *blob.Blob) error { ret := _m.Called(ctx, _a1) if len(ret) == 0 { @@ -339,7 +342,7 @@ func (_m *Manager) Update(ctx context.Context, _a1 *models.Blob) error { } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *models.Blob) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *blob.Blob) error); ok { r0 = rf(ctx, _a1) } else { r0 = ret.Error(0) diff --git a/src/testing/pkg/cached/manifest/redis/cached_manager.go b/src/testing/pkg/cached/manifest/redis/cached_manager.go index 86f17e749..ae81c2ba8 100644 --- a/src/testing/pkg/cached/manifest/redis/cached_manager.go +++ b/src/testing/pkg/cached/manifest/redis/cached_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package redis diff --git a/src/testing/pkg/chart/operator.go b/src/testing/pkg/chart/operator.go index 4ed9e2816..132a83380 100644 --- a/src/testing/pkg/chart/operator.go +++ b/src/testing/pkg/chart/operator.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package chart diff --git a/src/testing/pkg/distribution/manifest.go b/src/testing/pkg/distribution/manifest.go index 7d96ca80e..2379f920d 100644 --- a/src/testing/pkg/distribution/manifest.go +++ b/src/testing/pkg/distribution/manifest.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package distribution diff --git a/src/testing/pkg/immutable/dao/dao.go b/src/testing/pkg/immutable/dao/dao.go index 07776e600..ba91b1446 100644 --- a/src/testing/pkg/immutable/dao/dao.go +++ b/src/testing/pkg/immutable/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/immutable/matcher.go b/src/testing/pkg/immutable/matcher.go index f14c04e2f..43681a69d 100644 --- a/src/testing/pkg/immutable/matcher.go +++ b/src/testing/pkg/immutable/matcher.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package immutable diff --git a/src/testing/pkg/joblog/dao/dao.go b/src/testing/pkg/joblog/dao/dao.go index e010d2309..d9887e7b4 100644 --- a/src/testing/pkg/joblog/dao/dao.go +++ b/src/testing/pkg/joblog/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/joblog/manager.go b/src/testing/pkg/joblog/manager.go index 0e4204da6..9bb4581df 100644 --- a/src/testing/pkg/joblog/manager.go +++ b/src/testing/pkg/joblog/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package joblog diff --git a/src/testing/pkg/jobmonitor/job_service_monitor_client.go b/src/testing/pkg/jobmonitor/job_service_monitor_client.go index 567942c61..d3f3c636f 100644 --- a/src/testing/pkg/jobmonitor/job_service_monitor_client.go +++ b/src/testing/pkg/jobmonitor/job_service_monitor_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package jobmonitor diff --git a/src/testing/pkg/jobmonitor/pool_manager.go b/src/testing/pkg/jobmonitor/pool_manager.go index b2a8eb3af..ca08ec63e 100644 --- a/src/testing/pkg/jobmonitor/pool_manager.go +++ b/src/testing/pkg/jobmonitor/pool_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package jobmonitor diff --git a/src/testing/pkg/jobmonitor/queue_manager.go b/src/testing/pkg/jobmonitor/queue_manager.go index 2bf71c5f8..cc960ce49 100644 --- a/src/testing/pkg/jobmonitor/queue_manager.go +++ b/src/testing/pkg/jobmonitor/queue_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package jobmonitor diff --git a/src/testing/pkg/jobmonitor/redis_client.go b/src/testing/pkg/jobmonitor/redis_client.go index 099b41db7..5d270c48a 100644 --- a/src/testing/pkg/jobmonitor/redis_client.go +++ b/src/testing/pkg/jobmonitor/redis_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package jobmonitor diff --git a/src/testing/pkg/jobmonitor/worker_manager.go b/src/testing/pkg/jobmonitor/worker_manager.go index 5fef25392..ede27cbbe 100644 --- a/src/testing/pkg/jobmonitor/worker_manager.go +++ b/src/testing/pkg/jobmonitor/worker_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package jobmonitor diff --git a/src/testing/pkg/label/dao/dao.go b/src/testing/pkg/label/dao/dao.go index c552f751b..b63c90278 100644 --- a/src/testing/pkg/label/dao/dao.go +++ b/src/testing/pkg/label/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/label/manager.go b/src/testing/pkg/label/manager.go index dff40d983..aa2fcb8b1 100644 --- a/src/testing/pkg/label/manager.go +++ b/src/testing/pkg/label/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package label diff --git a/src/testing/pkg/ldap/manager.go b/src/testing/pkg/ldap/manager.go index aeb7ff7d5..966128b30 100644 --- a/src/testing/pkg/ldap/manager.go +++ b/src/testing/pkg/ldap/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package ldap diff --git a/src/testing/pkg/member/fake_member_manager.go b/src/testing/pkg/member/fake_member_manager.go index 6fe7aac32..c959a2670 100644 --- a/src/testing/pkg/member/fake_member_manager.go +++ b/src/testing/pkg/member/fake_member_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package member diff --git a/src/testing/pkg/notification/policy/dao/dao.go b/src/testing/pkg/notification/policy/dao/dao.go index 6c3061e25..3fe86a8d4 100644 --- a/src/testing/pkg/notification/policy/dao/dao.go +++ b/src/testing/pkg/notification/policy/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/notification/policy/manager.go b/src/testing/pkg/notification/policy/manager.go index 4b41766e5..35a731495 100644 --- a/src/testing/pkg/notification/policy/manager.go +++ b/src/testing/pkg/notification/policy/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package policy diff --git a/src/testing/pkg/oidc/dao/meta_dao.go b/src/testing/pkg/oidc/dao/meta_dao.go index 1a2e1fbbe..f6181268b 100644 --- a/src/testing/pkg/oidc/dao/meta_dao.go +++ b/src/testing/pkg/oidc/dao/meta_dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/oidc/meta_manager.go b/src/testing/pkg/oidc/meta_manager.go index 350fdef1c..c88c14f6c 100644 --- a/src/testing/pkg/oidc/meta_manager.go +++ b/src/testing/pkg/oidc/meta_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package oidc diff --git a/src/testing/pkg/p2p/preheat/instance/manager.go b/src/testing/pkg/p2p/preheat/instance/manager.go index 6e0e5233b..b08bd3f80 100644 --- a/src/testing/pkg/p2p/preheat/instance/manager.go +++ b/src/testing/pkg/p2p/preheat/instance/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package instance diff --git a/src/testing/pkg/p2p/preheat/policy/manager.go b/src/testing/pkg/p2p/preheat/policy/manager.go index 7c79fcfb3..c7df12e17 100644 --- a/src/testing/pkg/p2p/preheat/policy/manager.go +++ b/src/testing/pkg/p2p/preheat/policy/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package policy diff --git a/src/testing/pkg/parser/parser.go b/src/testing/pkg/parser/parser.go index f533da44e..065d4441c 100644 --- a/src/testing/pkg/parser/parser.go +++ b/src/testing/pkg/parser/parser.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package parser diff --git a/src/testing/pkg/processor/processor.go b/src/testing/pkg/processor/processor.go index 9f7896a70..67a186ec3 100644 --- a/src/testing/pkg/processor/processor.go +++ b/src/testing/pkg/processor/processor.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package processor diff --git a/src/testing/pkg/project/manager.go b/src/testing/pkg/project/manager.go index b9ec7051b..98ac8e668 100644 --- a/src/testing/pkg/project/manager.go +++ b/src/testing/pkg/project/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package project diff --git a/src/testing/pkg/project/metadata/manager.go b/src/testing/pkg/project/metadata/manager.go index 774f4d78b..1f77f170e 100644 --- a/src/testing/pkg/project/metadata/manager.go +++ b/src/testing/pkg/project/metadata/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package metadata diff --git a/src/testing/pkg/queuestatus/manager.go b/src/testing/pkg/queuestatus/manager.go index d2942cabe..f8f52dea9 100644 --- a/src/testing/pkg/queuestatus/manager.go +++ b/src/testing/pkg/queuestatus/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package queuestatus diff --git a/src/testing/pkg/quota/driver/driver.go b/src/testing/pkg/quota/driver/driver.go index 9bfb32728..564ed3a47 100644 --- a/src/testing/pkg/quota/driver/driver.go +++ b/src/testing/pkg/quota/driver/driver.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package driver diff --git a/src/testing/pkg/quota/manager.go b/src/testing/pkg/quota/manager.go index 71df09fce..eef3b3737 100644 --- a/src/testing/pkg/quota/manager.go +++ b/src/testing/pkg/quota/manager.go @@ -1,14 +1,14 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package quota import ( context "context" - models "github.com/goharbor/harbor/src/pkg/quota/models" + q "github.com/goharbor/harbor/src/lib/q" mock "github.com/stretchr/testify/mock" - q "github.com/goharbor/harbor/src/lib/q" + quota "github.com/goharbor/harbor/src/pkg/quota" types "github.com/goharbor/harbor/src/pkg/quota/types" ) @@ -100,23 +100,23 @@ func (_m *Manager) Delete(ctx context.Context, id int64) error { } // Get provides a mock function with given fields: ctx, id -func (_m *Manager) Get(ctx context.Context, id int64) (*models.Quota, error) { +func (_m *Manager) Get(ctx context.Context, id int64) (*quota.Quota, error) { ret := _m.Called(ctx, id) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *models.Quota + var r0 *quota.Quota var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int64) (*models.Quota, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64) (*quota.Quota, error)); ok { return rf(ctx, id) } - if rf, ok := ret.Get(0).(func(context.Context, int64) *models.Quota); ok { + if rf, ok := ret.Get(0).(func(context.Context, int64) *quota.Quota); ok { r0 = rf(ctx, id) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*models.Quota) + r0 = ret.Get(0).(*quota.Quota) } } @@ -130,23 +130,23 @@ func (_m *Manager) Get(ctx context.Context, id int64) (*models.Quota, error) { } // GetByRef provides a mock function with given fields: ctx, reference, referenceID -func (_m *Manager) GetByRef(ctx context.Context, reference string, referenceID string) (*models.Quota, error) { +func (_m *Manager) GetByRef(ctx context.Context, reference string, referenceID string) (*quota.Quota, error) { ret := _m.Called(ctx, reference, referenceID) if len(ret) == 0 { panic("no return value specified for GetByRef") } - var r0 *models.Quota + var r0 *quota.Quota var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*models.Quota, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*quota.Quota, error)); ok { return rf(ctx, reference, referenceID) } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *models.Quota); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, string) *quota.Quota); ok { r0 = rf(ctx, reference, referenceID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*models.Quota) + r0 = ret.Get(0).(*quota.Quota) } } @@ -160,23 +160,23 @@ func (_m *Manager) GetByRef(ctx context.Context, reference string, referenceID s } // List provides a mock function with given fields: ctx, query -func (_m *Manager) List(ctx context.Context, query *q.Query) ([]*models.Quota, error) { +func (_m *Manager) List(ctx context.Context, query *q.Query) ([]*quota.Quota, error) { ret := _m.Called(ctx, query) if len(ret) == 0 { panic("no return value specified for List") } - var r0 []*models.Quota + var r0 []*quota.Quota var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*models.Quota, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *q.Query) ([]*quota.Quota, error)); ok { return rf(ctx, query) } - if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*models.Quota); ok { + if rf, ok := ret.Get(0).(func(context.Context, *q.Query) []*quota.Quota); ok { r0 = rf(ctx, query) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*models.Quota) + r0 = ret.Get(0).([]*quota.Quota) } } @@ -190,7 +190,7 @@ func (_m *Manager) List(ctx context.Context, query *q.Query) ([]*models.Quota, e } // Update provides a mock function with given fields: ctx, _a1 -func (_m *Manager) Update(ctx context.Context, _a1 *models.Quota) error { +func (_m *Manager) Update(ctx context.Context, _a1 *quota.Quota) error { ret := _m.Called(ctx, _a1) if len(ret) == 0 { @@ -198,7 +198,7 @@ func (_m *Manager) Update(ctx context.Context, _a1 *models.Quota) error { } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *models.Quota) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *quota.Quota) error); ok { r0 = rf(ctx, _a1) } else { r0 = ret.Error(0) diff --git a/src/testing/pkg/rbac/dao/dao.go b/src/testing/pkg/rbac/dao/dao.go index 379e5c0bc..f18b5cbfb 100644 --- a/src/testing/pkg/rbac/dao/dao.go +++ b/src/testing/pkg/rbac/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/rbac/manager.go b/src/testing/pkg/rbac/manager.go index 98ea99806..ead3d4717 100644 --- a/src/testing/pkg/rbac/manager.go +++ b/src/testing/pkg/rbac/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package rbac diff --git a/src/testing/pkg/reg/adapter/adapter.go b/src/testing/pkg/reg/adapter/adapter.go index 4b18309df..965417810 100644 --- a/src/testing/pkg/reg/adapter/adapter.go +++ b/src/testing/pkg/reg/adapter/adapter.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package adapter diff --git a/src/testing/pkg/reg/dao/dao.go b/src/testing/pkg/reg/dao/dao.go index e70de513f..61432f9c8 100644 --- a/src/testing/pkg/reg/dao/dao.go +++ b/src/testing/pkg/reg/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/reg/manager.go b/src/testing/pkg/reg/manager.go index 1ead2cc16..4476d09e4 100644 --- a/src/testing/pkg/reg/manager.go +++ b/src/testing/pkg/reg/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package reg diff --git a/src/testing/pkg/registry/fake_registry_client.go b/src/testing/pkg/registry/fake_registry_client.go index e0b99787a..53e84de4a 100644 --- a/src/testing/pkg/registry/fake_registry_client.go +++ b/src/testing/pkg/registry/fake_registry_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package registry diff --git a/src/testing/pkg/replication/dao/dao.go b/src/testing/pkg/replication/dao/dao.go index bcfe17c17..f44d94edb 100644 --- a/src/testing/pkg/replication/dao/dao.go +++ b/src/testing/pkg/replication/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/replication/manager.go b/src/testing/pkg/replication/manager.go index a22c831fb..ae39aa6ed 100644 --- a/src/testing/pkg/replication/manager.go +++ b/src/testing/pkg/replication/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package replication diff --git a/src/testing/pkg/repository/dao/dao.go b/src/testing/pkg/repository/dao/dao.go index 865fed0ee..6e59fe870 100644 --- a/src/testing/pkg/repository/dao/dao.go +++ b/src/testing/pkg/repository/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/repository/manager.go b/src/testing/pkg/repository/manager.go index 8f25fc36f..667d26f2a 100644 --- a/src/testing/pkg/repository/manager.go +++ b/src/testing/pkg/repository/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package repository diff --git a/src/testing/pkg/robot/dao/dao.go b/src/testing/pkg/robot/dao/dao.go index 7b9c86106..b14222569 100644 --- a/src/testing/pkg/robot/dao/dao.go +++ b/src/testing/pkg/robot/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/robot/manager.go b/src/testing/pkg/robot/manager.go index b49aa8a38..ca2c88122 100644 --- a/src/testing/pkg/robot/manager.go +++ b/src/testing/pkg/robot/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package robot diff --git a/src/testing/pkg/scan/export/artifact_digest_calculator.go b/src/testing/pkg/scan/export/artifact_digest_calculator.go index 0b007f1eb..2be3e00ec 100644 --- a/src/testing/pkg/scan/export/artifact_digest_calculator.go +++ b/src/testing/pkg/scan/export/artifact_digest_calculator.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package export diff --git a/src/testing/pkg/scan/export/filter_processor.go b/src/testing/pkg/scan/export/filter_processor.go index 6f35bb4b1..e73648c39 100644 --- a/src/testing/pkg/scan/export/filter_processor.go +++ b/src/testing/pkg/scan/export/filter_processor.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package export @@ -45,9 +45,9 @@ func (_m *FilterProcessor) ProcessLabelFilter(ctx context.Context, labelIDs []in return r0, r1 } -// ProcessRepositoryFilter provides a mock function with given fields: ctx, filter, projectIds -func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter string, projectIds []int64) ([]int64, error) { - ret := _m.Called(ctx, filter, projectIds) +// ProcessRepositoryFilter provides a mock function with given fields: ctx, filter, projectIDs +func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter string, projectIDs []int64) ([]int64, error) { + ret := _m.Called(ctx, filter, projectIDs) if len(ret) == 0 { panic("no return value specified for ProcessRepositoryFilter") @@ -56,10 +56,10 @@ func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter s var r0 []int64 var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, []int64) ([]int64, error)); ok { - return rf(ctx, filter, projectIds) + return rf(ctx, filter, projectIDs) } if rf, ok := ret.Get(0).(func(context.Context, string, []int64) []int64); ok { - r0 = rf(ctx, filter, projectIds) + r0 = rf(ctx, filter, projectIDs) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]int64) @@ -67,7 +67,7 @@ func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter s } if rf, ok := ret.Get(1).(func(context.Context, string, []int64) error); ok { - r1 = rf(ctx, filter, projectIds) + r1 = rf(ctx, filter, projectIDs) } else { r1 = ret.Error(1) } @@ -75,9 +75,9 @@ func (_m *FilterProcessor) ProcessRepositoryFilter(ctx context.Context, filter s return r0, r1 } -// ProcessTagFilter provides a mock function with given fields: ctx, filter, repositoryIds -func (_m *FilterProcessor) ProcessTagFilter(ctx context.Context, filter string, repositoryIds []int64) ([]*artifact.Artifact, error) { - ret := _m.Called(ctx, filter, repositoryIds) +// ProcessTagFilter provides a mock function with given fields: ctx, filter, repositoryIDs +func (_m *FilterProcessor) ProcessTagFilter(ctx context.Context, filter string, repositoryIDs []int64) ([]*artifact.Artifact, error) { + ret := _m.Called(ctx, filter, repositoryIDs) if len(ret) == 0 { panic("no return value specified for ProcessTagFilter") @@ -86,10 +86,10 @@ func (_m *FilterProcessor) ProcessTagFilter(ctx context.Context, filter string, var r0 []*artifact.Artifact var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, []int64) ([]*artifact.Artifact, error)); ok { - return rf(ctx, filter, repositoryIds) + return rf(ctx, filter, repositoryIDs) } if rf, ok := ret.Get(0).(func(context.Context, string, []int64) []*artifact.Artifact); ok { - r0 = rf(ctx, filter, repositoryIds) + r0 = rf(ctx, filter, repositoryIDs) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]*artifact.Artifact) @@ -97,7 +97,7 @@ func (_m *FilterProcessor) ProcessTagFilter(ctx context.Context, filter string, } if rf, ok := ret.Get(1).(func(context.Context, string, []int64) error); ok { - r1 = rf(ctx, filter, repositoryIds) + r1 = rf(ctx, filter, repositoryIDs) } else { r1 = ret.Error(1) } diff --git a/src/testing/pkg/scan/export/manager.go b/src/testing/pkg/scan/export/manager.go index c39505276..7200b6595 100644 --- a/src/testing/pkg/scan/export/manager.go +++ b/src/testing/pkg/scan/export/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package export diff --git a/src/testing/pkg/scan/handler.go b/src/testing/pkg/scan/handler.go index 8e0a953bd..5d9ba6b8b 100644 --- a/src/testing/pkg/scan/handler.go +++ b/src/testing/pkg/scan/handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package scan diff --git a/src/testing/pkg/scan/postprocessors/native_scan_report_converter.go b/src/testing/pkg/scan/postprocessors/native_scan_report_converter.go index 377f6f29e..8137b0224 100644 --- a/src/testing/pkg/scan/postprocessors/native_scan_report_converter.go +++ b/src/testing/pkg/scan/postprocessors/native_scan_report_converter.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package postprocessors diff --git a/src/testing/pkg/scan/report/manager.go b/src/testing/pkg/scan/report/manager.go index a3f18870a..bbdbe68b3 100644 --- a/src/testing/pkg/scan/report/manager.go +++ b/src/testing/pkg/scan/report/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package report diff --git a/src/testing/pkg/scan/rest/v1/client.go b/src/testing/pkg/scan/rest/v1/client.go index 1b718adf8..e65845293 100644 --- a/src/testing/pkg/scan/rest/v1/client.go +++ b/src/testing/pkg/scan/rest/v1/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package v1 diff --git a/src/testing/pkg/scan/rest/v1/client_pool.go b/src/testing/pkg/scan/rest/v1/client_pool.go index 9a6eb3f61..319d1b2c6 100644 --- a/src/testing/pkg/scan/rest/v1/client_pool.go +++ b/src/testing/pkg/scan/rest/v1/client_pool.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package v1 diff --git a/src/testing/pkg/scan/rest/v1/request_resolver.go b/src/testing/pkg/scan/rest/v1/request_resolver.go index 75fb726a1..3fd73505f 100644 --- a/src/testing/pkg/scan/rest/v1/request_resolver.go +++ b/src/testing/pkg/scan/rest/v1/request_resolver.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package v1 diff --git a/src/testing/pkg/scan/rest/v1/response_handler.go b/src/testing/pkg/scan/rest/v1/response_handler.go index 3bd7c77c1..1e18c27e0 100644 --- a/src/testing/pkg/scan/rest/v1/response_handler.go +++ b/src/testing/pkg/scan/rest/v1/response_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package v1 diff --git a/src/testing/pkg/scan/sbom/manager.go b/src/testing/pkg/scan/sbom/manager.go index e3be4bf42..11c195ae5 100644 --- a/src/testing/pkg/scan/sbom/manager.go +++ b/src/testing/pkg/scan/sbom/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package sbom diff --git a/src/testing/pkg/scan/scanner/manager.go b/src/testing/pkg/scan/scanner/manager.go index 561f38110..b406661c6 100644 --- a/src/testing/pkg/scan/scanner/manager.go +++ b/src/testing/pkg/scan/scanner/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package scanner diff --git a/src/testing/pkg/scheduler/scheduler.go b/src/testing/pkg/scheduler/scheduler.go index 4f64e3dfa..6b0451308 100644 --- a/src/testing/pkg/scheduler/scheduler.go +++ b/src/testing/pkg/scheduler/scheduler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package scheduler diff --git a/src/testing/pkg/securityhub/manager.go b/src/testing/pkg/securityhub/manager.go index 27d4f5818..777333422 100644 --- a/src/testing/pkg/securityhub/manager.go +++ b/src/testing/pkg/securityhub/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package securityhub diff --git a/src/testing/pkg/systemartifact/cleanup/selector.go b/src/testing/pkg/systemartifact/cleanup/selector.go index f7ebecd2b..b2fbb9602 100644 --- a/src/testing/pkg/systemartifact/cleanup/selector.go +++ b/src/testing/pkg/systemartifact/cleanup/selector.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package cleanup diff --git a/src/testing/pkg/systemartifact/dao/dao.go b/src/testing/pkg/systemartifact/dao/dao.go index aa6a01a2a..e897f4428 100644 --- a/src/testing/pkg/systemartifact/dao/dao.go +++ b/src/testing/pkg/systemartifact/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/systemartifact/manager.go b/src/testing/pkg/systemartifact/manager.go index c2ccccdb1..b3ea0e1f6 100644 --- a/src/testing/pkg/systemartifact/manager.go +++ b/src/testing/pkg/systemartifact/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package systemartifact diff --git a/src/testing/pkg/tag/manager.go b/src/testing/pkg/tag/manager.go index 23af9f07c..42f82dc5d 100644 --- a/src/testing/pkg/tag/manager.go +++ b/src/testing/pkg/tag/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package tag diff --git a/src/testing/pkg/task/execution_manager.go b/src/testing/pkg/task/execution_manager.go index 92a6ff4f0..bd2b79888 100644 --- a/src/testing/pkg/task/execution_manager.go +++ b/src/testing/pkg/task/execution_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/testing/pkg/task/manager.go b/src/testing/pkg/task/manager.go index acc815898..a9cfbdb95 100644 --- a/src/testing/pkg/task/manager.go +++ b/src/testing/pkg/task/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package task diff --git a/src/testing/pkg/user/dao/dao.go b/src/testing/pkg/user/dao/dao.go index b9ee65ab5..d7d6e6514 100644 --- a/src/testing/pkg/user/dao/dao.go +++ b/src/testing/pkg/user/dao/dao.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package dao diff --git a/src/testing/pkg/user/manager.go b/src/testing/pkg/user/manager.go index 18a642ad3..6abbb3530 100644 --- a/src/testing/pkg/user/manager.go +++ b/src/testing/pkg/user/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package user diff --git a/src/testing/pkg/usergroup/fake_usergroup_manager.go b/src/testing/pkg/usergroup/fake_usergroup_manager.go index b6b9007ea..a3e5691bb 100644 --- a/src/testing/pkg/usergroup/fake_usergroup_manager.go +++ b/src/testing/pkg/usergroup/fake_usergroup_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package usergroup diff --git a/src/testing/registryctl/client.go b/src/testing/registryctl/client.go index eca5728f1..2f5dc04f6 100644 --- a/src/testing/registryctl/client.go +++ b/src/testing/registryctl/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package registryctl diff --git a/tests/ci/distro_installer.sh b/tests/ci/distro_installer.sh index cab510c9d..015e23f06 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.22.3 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.22.3 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.23.2 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.23.2 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 6702bb3aa..0d05ecef3 100755 --- a/tests/ci/ut_install.sh +++ b/tests/ci/ut_install.sh @@ -18,7 +18,7 @@ set -e # cd ../ # binary will be $(go env GOPATH)/bin/golangci-lint # 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.55.2 +curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0 sudo service postgresql stop || echo no postgresql need to be stopped sleep 2