bump golang 1.21.5 & fix golangci-lint error (#19722)

bump golang 1.21.5

update golangci-lint && fix revive error

fix white space lint

Signed-off-by: yminer <yminer@vmware.com>
This commit is contained in:
MinerYang 2023-12-19 09:41:26 +08:00 committed by GitHub
parent 5f828ea72f
commit b38de22054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
142 changed files with 269 additions and 267 deletions

View File

@ -44,7 +44,7 @@ jobs:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21.4
go-version: 1.21.5
id: go
- uses: actions/checkout@v3
with:
@ -105,7 +105,7 @@ jobs:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21.4
go-version: 1.21.5
id: go
- uses: actions/checkout@v3
with:
@ -160,7 +160,7 @@ jobs:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21.4
go-version: 1.21.5
id: go
- uses: actions/checkout@v3
with:
@ -215,7 +215,7 @@ jobs:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21.4
go-version: 1.21.5
id: go
- uses: actions/checkout@v3
with:
@ -268,7 +268,7 @@ jobs:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21.4
go-version: 1.21.5
id: go
- uses: actions/checkout@v3
with:

View File

@ -26,7 +26,7 @@ jobs:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21.4
go-version: 1.21.5
id: go
- name: Setup Docker
uses: docker-practice/actions-setup-docker@master

View File

@ -28,7 +28,7 @@ jobs:
- name: Set up Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21.4
go-version: 1.21.5
id: go
- uses: actions/checkout@v3
with:

View File

@ -164,7 +164,7 @@ Harbor backend is written in [Go](http://golang.org/). If you don't have a Harbo
| 2.7 | 1.19.4 |
| 2.8 | 1.20.6 |
| 2.9 | 1.21.3 |
| 2.10 | 1.21.4 |
| 2.10 | 1.21.5 |
Ensure your GOPATH and PATH have been configured in accordance with the Go environment instructions.

View File

@ -140,7 +140,7 @@ GOINSTALL=$(GOCMD) install
GOTEST=$(GOCMD) test
GODEP=$(GOTEST) -i
GOFMT=gofmt -w
GOBUILDIMAGE=golang:1.21.4
GOBUILDIMAGE=golang:1.21.5
GOBUILDPATHINCONTAINER=/harbor
# go build
@ -479,7 +479,7 @@ misspell:
@find . -type d \( -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error
# golangci-lint binary installation or refer to https://golangci-lint.run/usage/install/#local-installation
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint
lint:
@echo checking lint

View File

@ -1,4 +1,4 @@
FROM golang:1.21.4
FROM golang:1.21.5
ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution
ENV BUILDTAGS include_oss include_gcs

View File

@ -1,4 +1,4 @@
FROM golang:1.21.4
FROM golang:1.21.5
ADD . /go/src/github.com/aquasecurity/harbor-scanner-trivy/
WORKDIR /go/src/github.com/aquasecurity/harbor-scanner-trivy/

View File

@ -19,7 +19,7 @@ TEMP=$(mktemp -d ${TMPDIR-/tmp}/trivy-adapter.XXXXXX)
git clone https://github.com/aquasecurity/harbor-scanner-trivy.git $TEMP
cd $TEMP; git checkout $VERSION; cd -
echo "Building Trivy adapter binary based on golang:1.21.4..."
echo "Building Trivy adapter binary based on golang:1.21.5..."
cp Dockerfile.binary $TEMP
docker build -f $TEMP/Dockerfile.binary -t trivy-adapter-golang $TEMP

View File

@ -77,7 +77,7 @@ func (s *SecurityContext) IsSolutionUser() bool {
// Can returns whether the user can do action on resource
// returns true if the corresponding user of the secret
// is jobservice or core service, otherwise returns false
func (s *SecurityContext) Can(ctx context.Context, action types.Action, resource types.Resource) bool {
func (s *SecurityContext) Can(_ context.Context, _ types.Action, _ types.Resource) bool {
if s.store == nil {
return false
}

View File

@ -63,7 +63,7 @@ func (t *tokenSecurityCtx) GetMyProjects() ([]*models.Project, error) {
return []*models.Project{}, nil
}
func (t *tokenSecurityCtx) GetProjectRoles(projectIDOrName interface{}) []int {
func (t *tokenSecurityCtx) GetProjectRoles(_ interface{}) []int {
return []int{}
}

View File

@ -30,7 +30,7 @@ type GCResult struct {
}
// NewRegistryCtl returns a mock registry server
func NewRegistryCtl(config map[string]interface{}) (*httptest.Server, error) {
func NewRegistryCtl(_ map[string]interface{}) (*httptest.Server, error) {
m := []*RequestHandlerMapping{}
gcr := GCResult{true, "hello-world", time.Now(), time.Now()}

View File

@ -49,7 +49,7 @@ func (fc *FakeClient) GetUserInfo(token string) (*UserInfo, error) {
}
// UpdateConfig ...
func (fc *FakeClient) UpdateConfig(cfg *ClientConfig) error {
func (fc *FakeClient) UpdateConfig(_ *ClientConfig) error {
return nil
}

View File

@ -39,7 +39,7 @@ type v1alpha1Parser struct {
regCli reg.Client
}
func (p *v1alpha1Parser) Parse(ctx context.Context, artifact *artifact.Artifact, manifest []byte) error {
func (p *v1alpha1Parser) Parse(_ context.Context, artifact *artifact.Artifact, manifest []byte) error {
if artifact.ManifestMediaType != v1.MediaTypeImageManifest && artifact.ManifestMediaType != schema2.MediaTypeManifest {
return nil
}

View File

@ -37,22 +37,22 @@ type IndexProcessor struct {
}
// AbstractMetadata abstracts metadata of artifact
func (m *IndexProcessor) AbstractMetadata(ctx context.Context, artifact *artifact.Artifact, content []byte) error {
func (m *IndexProcessor) AbstractMetadata(_ context.Context, _ *artifact.Artifact, _ []byte) error {
return nil
}
// AbstractAddition abstracts the addition of artifact
func (m *IndexProcessor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*processor.Addition, error) {
func (m *IndexProcessor) AbstractAddition(_ context.Context, _ *artifact.Artifact, addition string) (*processor.Addition, error) {
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
WithMessage("addition %s isn't supported", addition)
}
// GetArtifactType returns the artifact type
func (m *IndexProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (m *IndexProcessor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
return ""
}
// ListAdditionTypes returns the supported addition types
func (m *IndexProcessor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
func (m *IndexProcessor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
return nil
}

View File

@ -64,23 +64,23 @@ func (m *ManifestProcessor) AbstractMetadata(ctx context.Context, artifact *arti
}
// AbstractAddition abstracts the addition of artifact
func (m *ManifestProcessor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*processor.Addition, error) {
func (m *ManifestProcessor) AbstractAddition(_ context.Context, _ *artifact.Artifact, addition string) (*processor.Addition, error) {
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
WithMessage("addition %s isn't supported", addition)
}
// GetArtifactType returns the artifact type
func (m *ManifestProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (m *ManifestProcessor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
return ""
}
// ListAdditionTypes returns the supported addition types
func (m *ManifestProcessor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
func (m *ManifestProcessor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
return nil
}
// UnmarshalConfig unmarshal the config blob of the artifact into the specified object "v"
func (m *ManifestProcessor) UnmarshalConfig(ctx context.Context, repository string, manifest []byte, v interface{}) error {
func (m *ManifestProcessor) UnmarshalConfig(_ context.Context, repository string, manifest []byte, v interface{}) error {
// unmarshal manifest
mani := &v1.Manifest{}
if err := json.Unmarshal(manifest, mani); err != nil {

View File

@ -58,7 +58,7 @@ type processor struct {
chartOperator chart.Operator
}
func (p *processor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*ps.Addition, error) {
func (p *processor) AbstractAddition(_ context.Context, artifact *artifact.Artifact, addition string) (*ps.Addition, error) {
if addition != AdditionTypeValues && addition != AdditionTypeReadme && addition != AdditionTypeDependencies {
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
WithMessage("addition %s isn't supported for %s", addition, ArtifactTypeChart)
@ -122,10 +122,10 @@ func (p *processor) AbstractAddition(ctx context.Context, artifact *artifact.Art
return nil, nil
}
func (p *processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (p *processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
return ArtifactTypeChart
}
func (p *processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
func (p *processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
return []string{AdditionTypeValues, AdditionTypeReadme, AdditionTypeDependencies}
}

View File

@ -45,7 +45,7 @@ type processor struct {
manifestProcessor *base.ManifestProcessor
}
func (p *processor) AbstractMetadata(ctx context.Context, art *artifact.Artifact, manifest []byte) error {
func (p *processor) AbstractMetadata(ctx context.Context, art *artifact.Artifact, _ []byte) error {
cfgManiDgt := ""
// try to get the digest of the manifest that the config layer is referenced by
for _, reference := range art.References {
@ -72,6 +72,6 @@ func (p *processor) AbstractMetadata(ctx context.Context, art *artifact.Artifact
return p.manifestProcessor.AbstractMetadata(ctx, art, payload)
}
func (p *processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (p *processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
return ArtifactTypeCNAB
}

View File

@ -48,7 +48,7 @@ type defaultProcessor struct {
regCli registry.Client
}
func (d *defaultProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (d *defaultProcessor) GetArtifactType(_ context.Context, artifact *artifact.Artifact) string {
// try to parse the type from the media type
strs := artifactTypeRegExp.FindStringSubmatch(artifact.MediaType)
if len(strs) == 2 {
@ -57,7 +57,7 @@ func (d *defaultProcessor) GetArtifactType(ctx context.Context, artifact *artifa
// can not get the artifact type from the media type, return unknown
return ArtifactTypeUnknown
}
func (d *defaultProcessor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
func (d *defaultProcessor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
return nil
}
@ -127,7 +127,7 @@ func (d *defaultProcessor) AbstractMetadata(ctx context.Context, artifact *artif
return nil
}
func (d *defaultProcessor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*Addition, error) {
func (d *defaultProcessor) AbstractAddition(_ context.Context, artifact *artifact.Artifact, _ string) (*Addition, error) {
// Addition not support for user-defined artifact yet.
// It will be support in the future.
// return error directly

View File

@ -44,6 +44,6 @@ type indexProcessor struct {
*base.IndexProcessor
}
func (i *indexProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (i *indexProcessor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
return ArtifactTypeImage
}

View File

@ -38,7 +38,7 @@ func init() {
type manifestV1Processor struct {
}
func (m *manifestV1Processor) AbstractMetadata(ctx context.Context, artifact *artifact.Artifact, manifest []byte) error {
func (m *manifestV1Processor) AbstractMetadata(_ context.Context, artifact *artifact.Artifact, manifest []byte) error {
mani := &schema1.Manifest{}
if err := json.Unmarshal(manifest, mani); err != nil {
return err
@ -50,15 +50,15 @@ func (m *manifestV1Processor) AbstractMetadata(ctx context.Context, artifact *ar
return nil
}
func (m *manifestV1Processor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*processor.Addition, error) {
func (m *manifestV1Processor) AbstractAddition(_ context.Context, _ *artifact.Artifact, addition string) (*processor.Addition, error) {
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
WithMessage("addition %s isn't supported for %s(manifest version 1)", addition, ArtifactTypeImage)
}
func (m *manifestV1Processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (m *manifestV1Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
return ArtifactTypeImage
}
func (m *manifestV1Processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
func (m *manifestV1Processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
return nil
}

View File

@ -112,10 +112,10 @@ func (m *manifestV2Processor) AbstractAddition(ctx context.Context, artifact *ar
}, nil
}
func (m *manifestV2Processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (m *manifestV2Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
return ArtifactTypeImage
}
func (m *manifestV2Processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
func (m *manifestV2Processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
return []string{AdditionTypeBuildHistory}
}

View File

@ -128,10 +128,10 @@ func (m *Processor) AbstractAddition(ctx context.Context, artifact *artifact.Art
}, nil
}
func (m *Processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
func (m *Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
return ArtifactTypeWASM
}
func (m *Processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
func (m *Processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
return []string{AdditionTypeBuildHistory}
}

View File

@ -169,7 +169,7 @@ func verifySkipAuditLogCfg(ctx context.Context, cfgs map[string]interface{}, mgr
}
// verifyValueLengthCfg verifies the cfgs which need to check the value max length to align with frontend.
func verifyValueLengthCfg(ctx context.Context, cfgs map[string]interface{}) error {
func verifyValueLengthCfg(_ context.Context, cfgs map[string]interface{}) error {
maxValue := maxValueLimitedByLength(common.UIMaxLengthLimitedOfNumber)
validateCfgs := []string{
common.TokenExpiration,

View File

@ -159,7 +159,7 @@ func (a *ArtifactEventHandler) onPull(ctx context.Context, event *event.Artifact
return nil
}
func (a *ArtifactEventHandler) updatePullTimeInCache(ctx context.Context, event *event.ArtifactEvent) {
func (a *ArtifactEventHandler) updatePullTimeInCache(_ context.Context, event *event.ArtifactEvent) {
var tagName string
if len(event.Tags) != 0 {
tagName = event.Tags[0]
@ -173,7 +173,7 @@ func (a *ArtifactEventHandler) updatePullTimeInCache(ctx context.Context, event
a.pullTimeStore[key] = time.Now()
}
func (a *ArtifactEventHandler) addPullCountInCache(ctx context.Context, event *event.ArtifactEvent) {
func (a *ArtifactEventHandler) addPullCountInCache(_ context.Context, event *event.ArtifactEvent) {
a.pullCountLock.Lock()
defer a.pullCountLock.Unlock()

View File

@ -52,7 +52,7 @@ func gcCallback(ctx context.Context, p string) error {
return err
}
func gcTaskStatusChange(ctx context.Context, taskID int64, status string) error {
func gcTaskStatusChange(ctx context.Context, _ int64, status string) error {
if status == job.SuccessStatus.String() && config.QuotaPerProjectEnable(ctx) {
go func() {
err := quota.RefreshForProjects(orm.Context())

View File

@ -41,7 +41,7 @@ type Controller interface {
type controller struct{}
func (c *controller) GetHealth(ctx context.Context) *OverallHealthStatus {
func (c *controller) GetHealth(_ context.Context) *OverallHealthStatus {
var isHealthy healthy = true
components := []*ComponentHealthStatus{}
ch := make(chan *ComponentHealthStatus, len(registry))

View File

@ -495,7 +495,7 @@ func (c *controller) ListPoliciesByProject(ctx context.Context, project int64, q
}
// CheckHealth checks the instance health, for test connection
func (c *controller) CheckHealth(ctx context.Context, instance *providerModels.Instance) error {
func (c *controller) CheckHealth(_ context.Context, instance *providerModels.Instance) error {
if instance == nil {
return errors.New("instance can not be nil")
}

View File

@ -150,9 +150,9 @@ func (c *controller) Exists(ctx context.Context, projectIDOrName interface{}) (b
return true, nil
} else if errors.IsNotFoundErr(err) {
return false, nil
} else {
return false, err
}
// else
return false, err
}
func (c *controller) Get(ctx context.Context, projectIDOrName interface{}, options ...Option) (*models.Project, error) {

View File

@ -101,7 +101,7 @@ func (c *controller) EnsureTag(ctx context.Context, art lib.ArtifactInfo, tagNam
// search the digest in cache and query with trimmed digest
var trimmedDigest string
err := c.cache.Fetch(ctx, TrimmedManifestlist+art.Digest, &trimmedDigest)
if errors.Is(err, cache.ErrNotFound) {
if errors.Is(err, cache.ErrNotFound) { // nolint:revive
// skip to update digest, continue
} else if err != nil {
// for other error, return
@ -260,7 +260,7 @@ func (c *controller) ProxyManifest(ctx context.Context, art lib.ArtifactInfo, re
return man, nil
}
func (c *controller) HeadManifest(ctx context.Context, art lib.ArtifactInfo, remote RemoteInterface) (bool, *distribution.Descriptor, error) {
func (c *controller) HeadManifest(_ context.Context, art lib.ArtifactInfo, remote RemoteInterface) (bool, *distribution.Descriptor, error) {
remoteRepo := getRemoteRepo(art)
ref := getReference(art)
return remote.ManifestExist(remoteRepo, ref)

View File

@ -81,7 +81,7 @@ func newLocalHelper() localInterface {
return l
}
func (l *localHelper) BlobExist(ctx context.Context, art lib.ArtifactInfo) (bool, error) {
func (l *localHelper) BlobExist(_ context.Context, art lib.ArtifactInfo) (bool, error) {
return l.registry.BlobExist(art.Repository, art.Digest)
}

View File

@ -63,7 +63,7 @@ type ManifestListCache struct {
}
// CacheContent ...
func (m *ManifestListCache) CacheContent(ctx context.Context, remoteRepo string, man distribution.Manifest, art lib.ArtifactInfo, r RemoteInterface, contentType string) {
func (m *ManifestListCache) CacheContent(ctx context.Context, _ string, man distribution.Manifest, art lib.ArtifactInfo, _ RemoteInterface, contentType string) {
_, payload, err := man.Payload()
if err != nil {
log.Errorf("failed to get payload, error %v", err)
@ -171,7 +171,7 @@ type ManifestCache struct {
}
// CacheContent ...
func (m *ManifestCache) CacheContent(ctx context.Context, remoteRepo string, man distribution.Manifest, art lib.ArtifactInfo, r RemoteInterface, contentType string) {
func (m *ManifestCache) CacheContent(ctx context.Context, remoteRepo string, man distribution.Manifest, art lib.ArtifactInfo, r RemoteInterface, _ string) {
var waitBlobs []distribution.Descriptor
for n := 0; n < maxManifestWait; n++ {
time.Sleep(sleepIntervalSec * time.Second)

View File

@ -464,7 +464,7 @@ func (c *controller) Update(ctx context.Context, u *quota.Quota) error {
}
// Driver returns quota driver for the reference
func Driver(ctx context.Context, reference string) (driver.Driver, error) {
func Driver(_ context.Context, reference string) (driver.Driver, error) {
d, ok := driver.Get(reference)
if !ok {
return nil, fmt.Errorf("quota not support for %s", reference)

View File

@ -43,7 +43,7 @@ type driver struct {
blobCtl blob.Controller
}
func (d *driver) Enabled(ctx context.Context, key string) (bool, error) {
func (d *driver) Enabled(ctx context.Context, _ string) (bool, error) {
// NOTE: every time load the new configurations from the db to get the latest configurations may have performance problem.
if err := d.cfg.Load(ctx); err != nil {
return false, err

View File

@ -326,7 +326,7 @@ func (t *transfer) copyChunkWithRetry(srcRepo, dstRepo, digest string, sizeFromD
}
// tryMountBlob try to check existence and mount, return true if mounted.
func (t *transfer) tryMountBlob(srcRepo, dstRepo, digest string) (bool, error) {
func (t *transfer) tryMountBlob(_, dstRepo, digest string) (bool, error) {
if t.shouldStop() {
return false, errStopped
}

View File

@ -37,7 +37,7 @@ func init() {
}
}
func cleanupCallBack(ctx context.Context, param string) error {
func cleanupCallBack(ctx context.Context, _ string) error {
err := cleanupController.Start(ctx, true, task.ExecutionTriggerSchedule)
if err != nil {
logger.Errorf("System artifact cleanup job encountered errors: %v", err)

View File

@ -147,7 +147,7 @@ func OIDCProviderName(cfg map[string]interface{}) string {
return utils.SafeCastString(cfg[common.OIDCName])
}
func (c *controller) GetCapacity(ctx context.Context) (*imagestorage.Capacity, error) {
func (c *controller) GetCapacity(_ context.Context) (*imagestorage.Capacity, error) {
systeminfo.Init()
return imagestorage.GlobalDriver.Cap()
}
@ -158,14 +158,15 @@ func (c *controller) GetCA(ctx context.Context) (io.ReadCloser, error) {
if len(testRootCertPath) > 0 {
path = testRootCertPath
}
if _, err := os.Stat(path); err == nil {
_, err := os.Stat(path)
if err == nil {
return os.Open(path)
} else if os.IsNotExist(err) {
return nil, errors.NotFoundError(fmt.Errorf("cert not found in path: %s", path))
} else {
logger.Errorf("Failed to stat the cert, path: %s, error: %v", path, err)
return nil, err
}
// else
logger.Errorf("Failed to stat the cert, path: %s, error: %v", path, err)
return nil, err
}
// NewController return an instance of controller

View File

@ -52,7 +52,7 @@ func init() {
}
}
func sweepCallback(ctx context.Context, p string) error {
func sweepCallback(ctx context.Context, _ string) error {
params := &SweepParams{ExecRetainCounts: job.GetExecutionSweeperCount()}
return SweepCtl.Start(ctx, params, task.ExecutionTriggerSchedule)
}

View File

@ -88,35 +88,35 @@ type DefaultAuthenticateHelper struct {
}
// Authenticate ...
func (d *DefaultAuthenticateHelper) Authenticate(ctx context.Context, m models.AuthModel) (*models.User, error) {
func (d *DefaultAuthenticateHelper) Authenticate(_ context.Context, _ models.AuthModel) (*models.User, error) {
return nil, ErrNotSupported
}
// OnBoardUser will check if a user exists in user table, if not insert the user and
// put the id in the pointer of user model, if it does exist, fill in the user model based
// on the data record of the user
func (d *DefaultAuthenticateHelper) OnBoardUser(ctx context.Context, u *models.User) error {
func (d *DefaultAuthenticateHelper) OnBoardUser(_ context.Context, _ *models.User) error {
return ErrNotSupported
}
// SearchUser - Get user information from account repository
func (d *DefaultAuthenticateHelper) SearchUser(ctx context.Context, username string) (*models.User, error) {
func (d *DefaultAuthenticateHelper) SearchUser(_ context.Context, username string) (*models.User, error) {
log.Errorf("Not support searching user, username: %s", username)
return nil, libErrors.NotFoundError(ErrNotSupported).WithMessage("%s not found", username)
}
// PostAuthenticate - Update user information after authenticate, such as OnBoard or sync info etc
func (d *DefaultAuthenticateHelper) PostAuthenticate(ctx context.Context, u *models.User) error {
func (d *DefaultAuthenticateHelper) PostAuthenticate(_ context.Context, _ *models.User) error {
return nil
}
// OnBoardGroup - OnBoardGroup, it will set the ID of the user group, if altGroupName is not empty, take the altGroupName as groupName in harbor DB.
func (d *DefaultAuthenticateHelper) OnBoardGroup(ctx context.Context, u *model.UserGroup, altGroupName string) error {
func (d *DefaultAuthenticateHelper) OnBoardGroup(_ context.Context, _ *model.UserGroup, _ string) error {
return ErrNotSupported
}
// SearchGroup - Search ldap group by group key, groupKey is the unique attribute of group in authenticator, for LDAP, the key is group DN
func (d *DefaultAuthenticateHelper) SearchGroup(ctx context.Context, groupKey string) (*model.UserGroup, error) {
func (d *DefaultAuthenticateHelper) SearchGroup(_ context.Context, groupKey string) (*model.UserGroup, error) {
log.Errorf("Not support searching group, group key: %s", groupKey)
return nil, libErrors.NotFoundError(ErrNotSupported).WithMessage("%s not found", groupKey)
}

View File

@ -102,13 +102,13 @@ func (a *Auth) Authenticate(ctx context.Context, m models.AuthModel) (*models.Us
return user, nil
} else if resp.StatusCode == http.StatusUnauthorized {
return nil, auth.NewErrAuth(string(data))
} else {
data, err := io.ReadAll(resp.Body)
if err != nil {
log.Warningf("Failed to read response body, error: %v", err)
}
return nil, fmt.Errorf("failed to authenticate, status code: %d, text: %s", resp.StatusCode, string(data))
}
// else
data, err = io.ReadAll(resp.Body)
if err != nil {
log.Warningf("Failed to read response body, error: %v", err)
}
return nil, fmt.Errorf("failed to authenticate, status code: %d, text: %s", resp.StatusCode, string(data))
}
func (a *Auth) tokenReview(ctx context.Context, sessionID string) (*models.User, error) {
@ -191,7 +191,7 @@ func (a *Auth) SearchGroup(ctx context.Context, groupKey string) (*model.UserGro
}
// OnBoardGroup create user group entity in Harbor DB, altGroupName is not used.
func (a *Auth) OnBoardGroup(ctx context.Context, u *model.UserGroup, altGroupName string) error {
func (a *Auth) OnBoardGroup(ctx context.Context, u *model.UserGroup, _ string) error {
// if group name provided, on board the user group
if len(u.GroupName) == 0 {
return errors.New("should provide a group name")

View File

@ -58,9 +58,9 @@ func (ah *authHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
_, err := rw.Write([]byte(fmt.Sprintf(`{"session_id": "%s"}`, e.sessionID)))
if err != nil {
panic(err)
} else {
return
}
// else
return
}
}
http.Error(rw, fmt.Sprintf("Do not find entry in entrylist, username: %s", html.EscapeString(u)), http.StatusUnauthorized)
@ -89,9 +89,9 @@ func (rth *reviewTokenHandler) ServeHTTP(rw http.ResponseWriter, req *http.Reque
_, err := rw.Write([]byte(fmt.Sprintf(reviewStatusTpl, e.username)))
if err != nil {
panic(err)
} else {
return
}
// else return
return
}
}
http.Error(rw, html.EscapeString(fmt.Sprintf("failed to match token: %s, entrylist: %+v", reviewData.Spec.Token, rth.entries)), http.StatusUnauthorized)

View File

@ -54,7 +54,7 @@ func (d *Auth) SearchUser(ctx context.Context, username string) (*models.User, e
}
// OnBoardUser -
func (d *Auth) OnBoardUser(ctx context.Context, u *models.User) error {
func (d *Auth) OnBoardUser(_ context.Context, _ *models.User) error {
return nil
}

View File

@ -30,7 +30,7 @@ type Auth struct {
}
// SearchGroup is skipped in OIDC mode, so it makes sure any group will be onboarded.
func (a *Auth) SearchGroup(ctx context.Context, groupKey string) (*model.UserGroup, error) {
func (a *Auth) SearchGroup(_ context.Context, groupKey string) (*model.UserGroup, error) {
return &model.UserGroup{
GroupName: groupKey,
GroupType: common.OIDCGroupType,
@ -38,7 +38,7 @@ func (a *Auth) SearchGroup(ctx context.Context, groupKey string) (*model.UserGro
}
// OnBoardGroup create user group entity in Harbor DB, altGroupName is not used.
func (a *Auth) OnBoardGroup(ctx context.Context, u *model.UserGroup, altGroupName string) error {
func (a *Auth) OnBoardGroup(ctx context.Context, u *model.UserGroup, _ string) error {
// if group name provided, on board the user group
if len(u.GroupName) == 0 || u.GroupType != common.OIDCGroupType {
return fmt.Errorf("invalid input group for OIDC mode: %v", *u)

View File

@ -124,7 +124,7 @@ type accessFilter interface {
type registryFilter struct {
}
func (reg registryFilter) filter(ctx context.Context, ctl project.Controller,
func (reg registryFilter) filter(ctx context.Context, _ project.Controller,
a *token.ResourceActions) error {
// Do not filter if the request is to access registry catalog
if a.Name != "catalog" {

View File

@ -46,7 +46,7 @@ type Store struct {
}
// Set value in redis session
func (rs *Store) Set(ctx context.Context, key, value interface{}) error {
func (rs *Store) Set(_ context.Context, key, value interface{}) error {
rs.lock.Lock()
defer rs.lock.Unlock()
rs.values[key] = value
@ -54,7 +54,7 @@ func (rs *Store) Set(ctx context.Context, key, value interface{}) error {
}
// Get value in redis session
func (rs *Store) Get(ctx context.Context, key interface{}) interface{} {
func (rs *Store) Get(_ context.Context, key interface{}) interface{} {
rs.lock.RLock()
defer rs.lock.RUnlock()
if v, ok := rs.values[key]; ok {
@ -64,7 +64,7 @@ func (rs *Store) Get(ctx context.Context, key interface{}) interface{} {
}
// Delete value in redis session
func (rs *Store) Delete(ctx context.Context, key interface{}) error {
func (rs *Store) Delete(_ context.Context, key interface{}) error {
rs.lock.Lock()
defer rs.lock.Unlock()
delete(rs.values, key)
@ -72,7 +72,7 @@ func (rs *Store) Delete(ctx context.Context, key interface{}) error {
}
// Flush clear all values in redis session
func (rs *Store) Flush(ctx context.Context) error {
func (rs *Store) Flush(_ context.Context) error {
rs.lock.Lock()
defer rs.lock.Unlock()
rs.values = make(map[interface{}]interface{})
@ -80,12 +80,12 @@ func (rs *Store) Flush(ctx context.Context) error {
}
// SessionID get redis session id
func (rs *Store) SessionID(ctx context.Context) string {
func (rs *Store) SessionID(_ context.Context) string {
return rs.sid
}
// SessionRelease save session values to redis
func (rs *Store) SessionRelease(ctx context.Context, w http.ResponseWriter) {
func (rs *Store) SessionRelease(ctx context.Context, _ http.ResponseWriter) {
b, err := session.EncodeGob(rs.values)
if err != nil {
return
@ -192,11 +192,11 @@ func (rp *Provider) SessionDestroy(ctx context.Context, sid string) error {
}
// SessionGC Implement method, no used.
func (rp *Provider) SessionGC(ctx context.Context) {
func (rp *Provider) SessionGC(_ context.Context) {
}
// SessionAll return all activeSession
func (rp *Provider) SessionAll(ctx context.Context) int {
func (rp *Provider) SessionAll(_ context.Context) int {
return 0
}

View File

@ -91,7 +91,7 @@ func (gc *GarbageCollector) ShouldRetry() bool {
}
// Validate implements the interface in job/Interface
func (gc *GarbageCollector) Validate(params job.Parameters) error {
func (gc *GarbageCollector) Validate(_ job.Parameters) error {
return nil
}

View File

@ -60,7 +60,7 @@ func (wj *WebhookJob) ShouldRetry() bool {
}
// Validate implements the interface in job/Interface
func (wj *WebhookJob) Validate(params job.Parameters) error {
func (wj *WebhookJob) Validate(_ job.Parameters) error {
return nil
}
@ -98,7 +98,7 @@ func (wj *WebhookJob) init(ctx job.Context, params map[string]interface{}) error
}
// execute webhook job
func (wj *WebhookJob) execute(ctx job.Context, params map[string]interface{}) error {
func (wj *WebhookJob) execute(_ job.Context, params map[string]interface{}) error {
payload := params["payload"].(string)
address := params["address"].(string)

View File

@ -47,7 +47,7 @@ func (j *Job) ShouldRetry() bool {
}
// Validate is implementation of same method in Interface.
func (j *Job) Validate(params job.Parameters) error {
func (j *Job) Validate(_ job.Parameters) error {
return nil
}

View File

@ -73,7 +73,7 @@ func (r *Replication) ShouldRetry() bool {
}
// Validate does nothing
func (r *Replication) Validate(params job.Parameters) error {
func (r *Replication) Validate(_ job.Parameters) error {
return nil
}

View File

@ -71,7 +71,7 @@ func (sde *ScanDataExport) ShouldRetry() bool {
// Validate Indicate whether the parameters of job are valid.
// Return:
// error if parameters are not valid. NOTES: If no parameters needed, directly return nil.
func (sde *ScanDataExport) Validate(params job.Parameters) error {
func (sde *ScanDataExport) Validate(_ job.Parameters) error {
return nil
}

View File

@ -35,11 +35,11 @@ func (c *Cleanup) ShouldRetry() bool {
return true
}
func (c *Cleanup) Validate(params job.Parameters) error {
func (c *Cleanup) Validate(_ job.Parameters) error {
return nil
}
func (c *Cleanup) Run(ctx job.Context, params job.Parameters) error {
func (c *Cleanup) Run(ctx job.Context, _ job.Parameters) error {
logger := ctx.GetLogger()
logger.Infof("Running system data artifact cleanup job...")
c.init()

View File

@ -41,6 +41,6 @@ func FileGetterFactory(options ...OptionItem) (getter.Interface, error) {
}
// DBGetterFactory creates a getter for the DB logger
func DBGetterFactory(options ...OptionItem) (getter.Interface, error) {
func DBGetterFactory(_ ...OptionItem) (getter.Interface, error) {
return getter.NewDBGetter(), nil
}

View File

@ -95,11 +95,11 @@ func (rj *RedisJob) Run(j *work.Job) (err error) {
<-time.After(time.Duration(b) * time.Millisecond)
span.AddEvent("retrying to get job stat")
continue
} else {
// Exit and never try.
// Directly return without retry again as we have no way to restore the stats again.
j.Fails = 10000000000 // never retry
}
// else
// Exit and never try.
// Directly return without retry again as we have no way to restore the stats again.
j.Fails = 10000000000 // never retry
}
// Log error and exit

View File

@ -347,15 +347,16 @@ func (bs *Bootstrap) loadAndRunRedisWorkerPool(
// Get a redis connection pool
func (bs *Bootstrap) getRedisPool(redisPoolConfig *config.RedisPoolConfig) *redis.Pool {
if pool, err := redislib.GetRedisPool("JobService", redisPoolConfig.RedisURL, &redislib.PoolParam{
pool, err := redislib.GetRedisPool("JobService", redisPoolConfig.RedisURL, &redislib.PoolParam{
PoolMaxIdle: 6,
PoolIdleTimeout: time.Duration(redisPoolConfig.IdleTimeoutSecond) * time.Second,
DialConnectionTimeout: dialConnectionTimeout,
DialReadTimeout: dialReadTimeout,
DialWriteTimeout: dialWriteTimeout,
}); err != nil {
})
if err != nil {
panic(err)
} else {
return pool
}
// else
return pool
}

View File

@ -251,7 +251,7 @@ func (w *basicWorker) Schedule(jobName string, params job.Parameters, runAfterSe
}
// PeriodicallyEnqueue job
func (w *basicWorker) PeriodicallyEnqueue(jobName string, params job.Parameters, cronSetting string, isUnique bool, webHook string) (*job.Stats, error) {
func (w *basicWorker) PeriodicallyEnqueue(jobName string, params job.Parameters, cronSetting string, _ bool, webHook string) (*job.Stats, error) {
p := &period.Policy{
ID: utils.MakeIdentifier(),
JobName: jobName,
@ -369,7 +369,7 @@ func (w *basicWorker) StopJob(jobID string) error {
}
// RetryJob retry the job
func (w *basicWorker) RetryJob(jobID string) error {
func (w *basicWorker) RetryJob(_ string) error {
return errors.New("not implemented")
}

View File

@ -60,7 +60,7 @@ func (c *Cache) Contains(ctx context.Context, key string) bool {
}
// Delete delete item from cache by key
func (c *Cache) Delete(ctx context.Context, key string) error {
func (c *Cache) Delete(_ context.Context, key string) error {
c.storage.Delete(c.opts.Key(key))
return nil
}
@ -89,12 +89,12 @@ func (c *Cache) Fetch(ctx context.Context, key string, value interface{}) error
}
// Ping ping the cache
func (c *Cache) Ping(ctx context.Context) error {
func (c *Cache) Ping(_ context.Context) error {
return nil
}
// Save cache the value by key
func (c *Cache) Save(ctx context.Context, key string, value interface{}, expiration ...time.Duration) error {
func (c *Cache) Save(_ context.Context, key string, value interface{}, expiration ...time.Duration) error {
data, err := c.opts.Codec.Encode(value)
if err != nil {
return fmt.Errorf("failed to encode value, key %s, error: %v", key, err)
@ -118,7 +118,7 @@ func (c *Cache) Save(ctx context.Context, key string, value interface{}, expirat
}
// Scan scans the keys matched by match string
func (c *Cache) Scan(ctx context.Context, match string) (cache.Iterator, error) {
func (c *Cache) Scan(_ context.Context, match string) (cache.Iterator, error) {
var keys []string
c.storage.Range(func(k, v interface{}) bool {
matched := true
@ -147,7 +147,7 @@ type ScanIterator struct {
}
// Next checks whether has the next element
func (i *ScanIterator) Next(ctx context.Context) bool {
func (i *ScanIterator) Next(_ context.Context) bool {
i.mu.Lock()
defer i.mu.Unlock()

View File

@ -112,7 +112,7 @@ func InitWithSettings(cfgs map[string]interface{}, kp ...encrypt.KeyProvider) {
}
// GetCfgManager return the current config manager
func GetCfgManager(ctx context.Context) Manager {
func GetCfgManager(_ context.Context) Manager {
return DefaultMgr()
}

View File

@ -38,7 +38,7 @@ type Type interface {
type StringType struct {
}
func (t *StringType) validate(str string) error {
func (t *StringType) validate(_ string) error {
return nil
}
@ -177,7 +177,7 @@ func (t *BoolType) get(str string) (interface{}, error) {
type PasswordType struct {
}
func (t *PasswordType) validate(str string) error {
func (t *PasswordType) validate(_ string) error {
return nil
}

View File

@ -37,7 +37,7 @@ func NewFileKeyProvider(path string) KeyProvider {
}
// Get returns the key read from file
func (f *FileKeyProvider) Get(params map[string]interface{}) (string, error) {
func (f *FileKeyProvider) Get(_ map[string]interface{}) (string, error) {
b, err := os.ReadFile(f.path)
if err != nil {
return "", err
@ -51,6 +51,6 @@ type PresetKeyProvider struct {
}
// Get ...
func (p *PresetKeyProvider) Get(params map[string]interface{}) (string, error) {
func (p *PresetKeyProvider) Get(_ map[string]interface{}) (string, error) {
return p.Key, nil
}

View File

@ -116,7 +116,7 @@ func PaginationOnRawSQL(query *q.Query, sql string, params []interface{}) (strin
}
// QuerySetterForCount creates the query setter used for count with the sort and pagination information ignored
func QuerySetterForCount(ctx context.Context, model interface{}, query *q.Query, ignoredCols ...string) (orm.QuerySeter, error) {
func QuerySetterForCount(ctx context.Context, model interface{}, query *q.Query, _ ...string) (orm.QuerySeter, error) {
query = q.MustClone(query)
query.Sorts = nil
query.PageSize = 0

View File

@ -102,9 +102,9 @@ func GetRedisPool(name string, rawurl string, param *PoolParam) (*redis.Pool, er
}
knownPool.Store(name, pool)
return pool, nil
} else {
return nil, fmt.Errorf("bad redis url: not support scheme %s", u.Scheme)
}
return nil, fmt.Errorf("bad redis url: not support scheme %s", u.Scheme)
}
func getSentinelPool(u *url.URL, param *PoolParam, name string) (*redis.Pool, error) {

View File

@ -50,7 +50,7 @@ func (s *selector) Select(artifacts []*iselector.Candidate) (selected []*iselect
}
// New is factory method for label selector
func New(decoration string, pattern interface{}, extras string) iselector.Selector {
func New(decoration string, pattern interface{}, _ string) iselector.Selector {
labels := make([]string, 0)
if pattern != nil {

View File

@ -82,7 +82,7 @@ func (s *selector) Select(artifacts []*sl.Candidate) (selected []*sl.Candidate,
}
// New is factory method for vulnerability severity selector
func New(decoration string, pattern interface{}, extras string) sl.Selector {
func New(decoration string, pattern interface{}, _ string) sl.Selector {
var sev int
if pattern != nil {
sev, _ = pattern.(int)

View File

@ -64,7 +64,7 @@ func (s *selector) Select(artifacts []*sl.Candidate) (selected []*sl.Candidate,
}
// New is factory method for signature selector
func New(decoration string, pattern interface{}, extras string) sl.Selector {
func New(decoration string, pattern interface{}, _ string) sl.Selector {
var e bool
if pattern != nil {
e, _ = pattern.(bool)

View File

@ -35,7 +35,7 @@ type LoggerManager struct {
}
// Init redirect the audit log to the forward endpoint
func (a *LoggerManager) Init(ctx context.Context, logEndpoint string) {
func (a *LoggerManager) Init(_ context.Context, logEndpoint string) {
var w io.Writer
w, err := syslog.Dial("tcp", logEndpoint,
syslog.LOG_INFO, "audit")

View File

@ -123,7 +123,7 @@ func (b *Blob) IsManifest() bool {
}
// FilterByArtifactDigest returns orm.QuerySeter with artifact digest filter
func (b *Blob) FilterByArtifactDigest(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter {
func (b *Blob) FilterByArtifactDigest(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
v, ok := value.(string)
if !ok {
return qs
@ -133,7 +133,7 @@ func (b *Blob) FilterByArtifactDigest(ctx context.Context, qs orm.QuerySeter, ke
}
// FilterByArtifactDigests returns orm.QuerySeter with artifact digests filter
func (b *Blob) FilterByArtifactDigests(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter {
func (b *Blob) FilterByArtifactDigests(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
artifactDigests, ok := value.([]string)
if !ok {
return qs
@ -148,7 +148,7 @@ func (b *Blob) FilterByArtifactDigests(ctx context.Context, qs orm.QuerySeter, k
}
// FilterByProjectID returns orm.QuerySeter with project id filter
func (b *Blob) FilterByProjectID(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter {
func (b *Blob) FilterByProjectID(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
projectID, ok := value.(int64)
if !ok {
return qs

View File

@ -87,12 +87,12 @@ func (bm *BaseManager) WithCacheClient(cc cache.Cache) *BaseManager {
}
// CacheClient returns the cache client.
func (bm *BaseManager) CacheClient(ctx context.Context) cache.Cache {
func (bm *BaseManager) CacheClient(_ context.Context) cache.Cache {
return bm.cacheClient
}
// ResourceType returns the resource type.
func (bm *BaseManager) ResourceType(ctx context.Context) string {
func (bm *BaseManager) ResourceType(_ context.Context) string {
return bm.resourceType
}

View File

@ -48,7 +48,7 @@ func (d *Driver) Load(context.Context) (map[string]interface{}, error) {
}
// Save only save user config setting to driver, for example: database, REST
func (d *Driver) Save(ctx context.Context, cfg map[string]interface{}) error {
func (d *Driver) Save(_ context.Context, cfg map[string]interface{}) error {
d.Lock()
defer d.Unlock()
for k, v := range cfg {

View File

@ -136,7 +136,7 @@ func (c *CfgManager) Save(ctx context.Context) error {
}
// Get ...
func (c *CfgManager) Get(ctx context.Context, key string) *metadata.ConfigureValue {
func (c *CfgManager) Get(_ context.Context, key string) *metadata.ConfigureValue {
configValue, err := c.Store.Get(key)
if err != nil {
log.Debugf("failed to get key %v, error: %v, maybe default value not defined before get", key, err)
@ -146,7 +146,7 @@ func (c *CfgManager) Get(ctx context.Context, key string) *metadata.ConfigureVal
}
// Set ...
func (c *CfgManager) Set(ctx context.Context, key string, value interface{}) {
func (c *CfgManager) Set(_ context.Context, key string, value interface{}) {
configValue, err := metadata.NewCfgValue(key, utils.GetStrValueOfAnyType(value))
if err != nil {
log.Errorf("error when setting key: %v, error %v", key, err)

View File

@ -41,7 +41,7 @@ type Value struct {
}
// Load - load config data from REST server
func (h *Driver) Load(ctx context.Context) (map[string]interface{}, error) {
func (h *Driver) Load(_ context.Context) (map[string]interface{}, error) {
cfgMap := map[string]interface{}{}
origMap := map[string]*Value{}
log.Infof("get configuration from url: %+v", h.configRESTURL)
@ -59,6 +59,6 @@ func (h *Driver) Load(ctx context.Context) (map[string]interface{}, error) {
}
// Save - Save config data to REST server by PUT method
func (h *Driver) Save(ctx context.Context, cfg map[string]interface{}) error {
func (h *Driver) Save(_ context.Context, cfg map[string]interface{}) error {
return h.client.Put(h.configRESTURL, cfg)
}

View File

@ -82,7 +82,7 @@ func (e *Exporter) RegisterCollector(collectors ...collector) error {
return nil
}
func newServer(opt *Opt, r *prometheus.Registry) *http.Server {
func newServer(opt *Opt, _ *prometheus.Registry) *http.Server {
exporterMux := http.NewServeMux()
exporterMux.Handle(opt.MetricsPath, promhttp.Handler())
exporterMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

View File

@ -94,6 +94,6 @@ func initRepositoryMgr(cacheEnabled bool) {
}
}
func initManifestManager(cacheEnabled bool) {
func initManifestManager(_ bool) {
ManifestMgr = cachedManifest.NewManager()
}

View File

@ -45,7 +45,7 @@ func NewPoolManager() PoolManager {
return &poolManager{}
}
func (p poolManager) List(ctx context.Context, monitorClient JobServiceMonitorClient) ([]*WorkerPool, error) {
func (p poolManager) List(_ context.Context, monitorClient JobServiceMonitorClient) ([]*WorkerPool, error) {
workerPool := make([]*WorkerPool, 0)
wh, err := monitorClient.WorkerPoolHeartbeats()
if err != nil {

View File

@ -30,7 +30,7 @@ func NewQueueClient() QueueManager {
return &queueManagerImpl{}
}
func (w *queueManagerImpl) List(ctx context.Context, monitClient JobServiceMonitorClient) ([]*Queue, error) {
func (w *queueManagerImpl) List(_ context.Context, monitClient JobServiceMonitorClient) ([]*Queue, error) {
resultQueues := make([]*Queue, 0)
queues, err := monitClient.Queues()
if err != nil {

View File

@ -126,7 +126,7 @@ func (r *redisClientImpl) StopPendingJobs(ctx context.Context, jobType string) (
}
// removeJobStatusInRedis remove job status track information from redis, to avoid performance impact when the jobIDs is too large, use batch to remove
func (r *redisClientImpl) removeJobStatusInRedis(ctx context.Context, jobIDs []string) {
func (r *redisClientImpl) removeJobStatusInRedis(_ context.Context, jobIDs []string) {
conn := r.redisPool.Get()
defer conn.Close()
for _, id := range jobIDs {
@ -146,13 +146,13 @@ func (r *redisClientImpl) removeJobStatusInRedis(ctx context.Context, jobIDs []s
}
}
func (r *redisClientImpl) AllJobTypes(ctx context.Context) ([]string, error) {
func (r *redisClientImpl) AllJobTypes(_ context.Context) ([]string, error) {
conn := r.redisPool.Get()
defer conn.Close()
return redis.Strings(conn.Do("SMEMBERS", fmt.Sprintf("{%s}:known_jobs", r.namespace)))
}
func (r *redisClientImpl) PauseJob(ctx context.Context, jobName string) error {
func (r *redisClientImpl) PauseJob(_ context.Context, jobName string) error {
log.Infof("pause job type:%s", jobName)
redisKeyJobPaused := fmt.Sprintf("{%s}:jobs:%s:paused", r.namespace, jobName)
conn := r.redisPool.Get()
@ -161,7 +161,7 @@ func (r *redisClientImpl) PauseJob(ctx context.Context, jobName string) error {
return err
}
func (r *redisClientImpl) UnpauseJob(ctx context.Context, jobName string) error {
func (r *redisClientImpl) UnpauseJob(_ context.Context, jobName string) error {
log.Infof("unpause job %s", jobName)
redisKeyJobPaused := fmt.Sprintf("{%s}:jobs:%s:paused", r.namespace, jobName)
conn := r.redisPool.Get()

View File

@ -40,7 +40,7 @@ func NewWorkerManager() WorkerManager {
return &workerManagerImpl{taskMgr: task.NewManager()}
}
func (w *workerManagerImpl) List(ctx context.Context, monitClient JobServiceMonitorClient, poolID string) ([]*Worker, error) {
func (w *workerManagerImpl) List(_ context.Context, monitClient JobServiceMonitorClient, poolID string) ([]*Worker, error) {
wphs, err := monitClient.WorkerPoolHeartbeats()
if err != nil {
return nil, err

View File

@ -49,11 +49,11 @@ func New() Manager {
type manager struct {
}
func (m *manager) Ping(ctx context.Context, cfg cfgModels.LdapConf) (bool, error) {
func (m *manager) Ping(_ context.Context, cfg cfgModels.LdapConf) (bool, error) {
return TestConfig(cfg)
}
func (m *manager) SearchUser(ctx context.Context, sess *Session, username string) ([]model.User, error) {
func (m *manager) SearchUser(_ context.Context, sess *Session, username string) ([]model.User, error) {
users := make([]model.User, 0)
if err := sess.Open(); err != nil {
return users, err
@ -133,7 +133,7 @@ func (m *manager) ImportUser(ctx context.Context, sess *Session, ldapImportUsers
return failedImportUser, nil
}
func (m *manager) SearchGroup(ctx context.Context, sess *Session, groupName, groupDN string) ([]model.Group, error) {
func (m *manager) SearchGroup(_ context.Context, sess *Session, groupName, groupDN string) ([]model.Group, error) {
err := sess.Open()
if err != nil {
return nil, err

View File

@ -111,7 +111,7 @@ func (d *dao) GetProjectMember(ctx context.Context, queryMember models.Member, q
return members, err
}
func (d *dao) GetTotalOfProjectMembers(ctx context.Context, projectID int64, query *q.Query, roles ...int) (int, error) {
func (d *dao) GetTotalOfProjectMembers(ctx context.Context, projectID int64, _ *q.Query, roles ...int) (int, error) {
log.Debugf("Query condition %+v", projectID)
if projectID == 0 {
return 0, fmt.Errorf("failed to get total of project members, project id required %v", projectID)

View File

@ -77,7 +77,7 @@ func (h *HookMetaData) Resolve(evt *Event) error {
}
// Build an event by metadata
func (e *Event) Build(ctx context.Context, metadata ...Metadata) error {
func (e *Event) Build(_ context.Context, metadata ...Metadata) error {
for _, md := range metadata {
if err := md.Resolve(e); err != nil {
log.Debugf("failed to resolve event metadata: %v", md)

View File

@ -66,7 +66,7 @@ type Default struct{}
}
}
*/
func (d *Default) Format(ctx context.Context, he *model.HookEvent) (http.Header, []byte, error) {
func (d *Default) Format(_ context.Context, he *model.HookEvent) (http.Header, []byte, error) {
if he == nil {
return nil, nil, errors.Errorf("HookEvent should not be nil")
}

View File

@ -26,7 +26,7 @@ type fakeVerifier struct {
secret string
}
func (fv *fakeVerifier) VerifySecret(ctx context.Context, name string, secret string) (*UserInfo, error) {
func (fv *fakeVerifier) VerifySecret(_ context.Context, name string, secret string) (*UserInfo, error) {
if secret != fv.secret {
return nil, verifyError(errors.New("mismatch"))
}

View File

@ -28,7 +28,7 @@ func (nah *NoneAuthHandler) Mode() string {
}
// Authorize implements @Handler.Authorize
func (nah *NoneAuthHandler) Authorize(req *http.Request, cred *Credential) error {
func (nah *NoneAuthHandler) Authorize(req *http.Request, _ *Credential) error {
if req == nil {
return errors.New("nil request cannot be authorized")
}

View File

@ -31,7 +31,7 @@ type Evaluator struct {
}
// HasPermission always return true for the system administrator
func (e *Evaluator) HasPermission(ctx context.Context, resource types.Resource, action types.Action) bool {
func (e *Evaluator) HasPermission(_ context.Context, resource types.Resource, action types.Action) bool {
log.Debugf("system administrator %s require %s action for resource %s", e.username, action, resource)
// scanner-pull is for scanner to bypass the policy checking so admin user should not have this permission
return action != rbac.ActionScannerPull

View File

@ -88,18 +88,18 @@ func (a *adapter) LoadPolicy(model model.Model) error {
return nil
}
func (a *adapter) SavePolicy(model model.Model) error {
func (a *adapter) SavePolicy(_ model.Model) error {
return errNotImplemented
}
func (a *adapter) AddPolicy(sec string, ptype string, rule []string) error {
func (a *adapter) AddPolicy(_ string, _ string, _ []string) error {
return errNotImplemented
}
func (a *adapter) RemovePolicy(sec string, ptype string, rule []string) error {
func (a *adapter) RemovePolicy(_ string, _ string, _ []string) error {
return errNotImplemented
}
func (a *adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error {
func (a *adapter) RemoveFilteredPolicy(_ string, _ string, _ int, _ ...string) error {
return errNotImplemented
}

View File

@ -34,7 +34,7 @@ type Evaluator struct {
}
// HasPermission returns true when the rbac user has action permission for the resource
func (e *Evaluator) HasPermission(ctx context.Context, resource types.Resource, action types.Action) bool {
func (e *Evaluator) HasPermission(_ context.Context, resource types.Resource, action types.Action) bool {
e.once.Do(func() {
e.enforcer = makeEnforcer(e.rbacUser)
})

View File

@ -148,7 +148,7 @@ func (p *Project) AutoScan() bool {
}
// FilterByPublic returns orm.QuerySeter with public filter
func (p *Project) FilterByPublic(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter {
func (p *Project) FilterByPublic(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
subQuery := `SELECT project_id FROM project_metadata WHERE name = 'public' AND value = '%s'`
if isTrue(value) {
subQuery = fmt.Sprintf(subQuery, "true")
@ -159,7 +159,7 @@ func (p *Project) FilterByPublic(ctx context.Context, qs orm.QuerySeter, key str
}
// FilterByOwner returns orm.QuerySeter with owner filter
func (p *Project) FilterByOwner(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter {
func (p *Project) FilterByOwner(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
username, ok := value.(string)
if !ok {
return qs
@ -169,7 +169,7 @@ func (p *Project) FilterByOwner(ctx context.Context, qs orm.QuerySeter, key stri
}
// FilterByMember returns orm.QuerySeter with member filter
func (p *Project) FilterByMember(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter {
func (p *Project) FilterByMember(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
query, ok := value.(*MemberQuery)
if !ok {
return qs
@ -197,7 +197,7 @@ func (p *Project) FilterByMember(ctx context.Context, qs orm.QuerySeter, key str
}
// FilterByNames returns orm.QuerySeter with name filter
func (p *Project) FilterByNames(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter {
func (p *Project) FilterByNames(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
query, ok := value.(*NamesQuery)
if !ok {
return qs

View File

@ -50,7 +50,7 @@ func (resource ResourceName) FormatValue(value int64) string {
type ResourceList map[ResourceName]int64
// Validate validates this resource list
func (resources ResourceList) Validate(formats strfmt.Registry) error {
func (resources ResourceList) Validate(_ strfmt.Registry) error {
return nil
}

View File

@ -339,7 +339,7 @@ func (a *adapter) FetchArtifacts(filters []*model.Filter) (resources []*model.Re
return
}
func (a *adapter) listReposByNamespace(region string, namespace string, c *cr.Client) (repos []aliRepo, err error) {
func (a *adapter) listReposByNamespace(_ string, namespace string, c *cr.Client) (repos []aliRepo, err error) {
var reposReq = cr.CreateGetRepoListByNamespaceRequest()
var reposResp = cr.CreateGetRepoListByNamespaceResponse()
reposReq.SetDomain(a.domain)

View File

@ -207,6 +207,6 @@ func (a *adapter) listArtifacts(repository string, filters []*model.Filter) ([]*
return filter.DoFilterArtifacts(artifacts, filters)
}
func (a *adapter) DeleteManifest(repository, reference string) error {
func (a *adapter) DeleteManifest(_, _ string) error {
return nil
}

View File

@ -146,7 +146,7 @@ func (a *adapter) ListNamespaces(query *model.NamespaceQuery) ([]*model.Namespac
}
// ConvertResourceMetadata convert resource metadata for Huawei SWR
func (a *adapter) ConvertResourceMetadata(resourceMetadata *model.ResourceMetadata, namespace *model.Namespace) (*model.ResourceMetadata, error) {
func (a *adapter) ConvertResourceMetadata(resourceMetadata *model.ResourceMetadata, _ *model.Namespace) (*model.ResourceMetadata, error) {
metadata := &model.ResourceMetadata{
Repository: resourceMetadata.Repository,
Vtags: resourceMetadata.Vtags,

View File

@ -28,7 +28,7 @@ import (
)
// FetchArtifacts gets resources from Huawei SWR
func (a *adapter) FetchArtifacts(filters []*model.Filter) ([]*model.Resource, error) {
func (a *adapter) FetchArtifacts(_ []*model.Filter) ([]*model.Resource, error) {
resources := []*model.Resource{}
urls := fmt.Sprintf("%s/dockyard/v2/repositories?filter=center::self", a.registry.URL)
@ -111,9 +111,9 @@ func (a *adapter) ManifestExist(repository, reference string) (exist bool, desc
}
contentType := resp.Header.Get("Content-Type")
contentLen := resp.Header.Get("Content-Length")
len, _ := strconv.Atoi(contentLen)
lenth, _ := strconv.Atoi(contentLen)
return exist, &distribution.Descriptor{MediaType: contentType, Size: int64(len)}, nil
return exist, &distribution.Descriptor{MediaType: contentType, Size: int64(lenth)}, nil
}
// DeleteManifest delete the manifest of Huawei SWR

View File

@ -342,7 +342,7 @@ func (a *adapter) preparePushBlob(repository string) (string, error) {
return "", err
}
func (a *adapter) ackPushBlob(repository, digest, location, size string) error {
func (a *adapter) ackPushBlob(repository, digest, location, _ string) error {
url := fmt.Sprintf("%s/v2/%s/blobs/uploads/%s?digest=%s", a.registry.URL, repository, location, digest)
req, err := http.NewRequest(http.MethodPut, url, nil)
if err != nil {

View File

@ -240,11 +240,11 @@ func (a *Adapter) PingSimple() error {
}
// DeleteTag isn't supported for docker registry
func (a *Adapter) DeleteTag(repository, tag string) error {
func (a *Adapter) DeleteTag(_, _ string) error {
return errors.New("the tag deletion isn't supported")
}
// CanBeMount isn't supported for docker registry
func (a *Adapter) CanBeMount(digest string) (mount bool, repository string, err error) {
func (a *Adapter) CanBeMount(_ string) (mount bool, repository string, err error) {
return false, "", nil
}

View File

@ -144,7 +144,7 @@ func (m *manager) Delete(ctx context.Context, id int64) error {
return m.dao.Delete(ctx, id)
}
func (m *manager) CreateAdapter(ctx context.Context, registry *model.Registry) (adapter.Adapter, error) {
func (m *manager) CreateAdapter(_ context.Context, registry *model.Registry) (adapter.Adapter, error) {
factory, err := adapter.GetFactory(registry.Type)
if err != nil {
return nil, err
@ -152,11 +152,11 @@ func (m *manager) CreateAdapter(ctx context.Context, registry *model.Registry) (
return factory.Create(registry)
}
func (m *manager) ListRegistryProviderTypes(ctx context.Context) ([]string, error) {
func (m *manager) ListRegistryProviderTypes(_ context.Context) ([]string, error) {
return adapter.ListRegisteredAdapterTypes(), nil
}
func (m *manager) ListRegistryProviderInfos(ctx context.Context) (infos map[string]*model.AdapterPattern, err error) {
func (m *manager) ListRegistryProviderInfos(_ context.Context) (infos map[string]*model.AdapterPattern, err error) {
return adapter.ListRegisteredAdapterInfos(), nil
}

View File

@ -27,7 +27,7 @@ func NewAuthorizer() lib.Authorizer {
type authorizer struct{}
func (a *authorizer) Modify(req *http.Request) error {
func (a *authorizer) Modify(_ *http.Request) error {
// do nothing
return nil
}

View File

@ -281,8 +281,8 @@ func (c *client) ManifestExist(repository, reference string) (bool, *distributio
dig := resp.Header.Get("Docker-Content-Digest")
contentType := resp.Header.Get("Content-Type")
contentLen := resp.Header.Get("Content-Length")
len, _ := strconv.Atoi(contentLen)
return true, &distribution.Descriptor{Digest: digest.Digest(dig), MediaType: contentType, Size: int64(len)}, nil
lenth, _ := strconv.Atoi(contentLen)
return true, &distribution.Descriptor{Digest: digest.Digest(dig), MediaType: contentType, Size: int64(lenth)}, nil
}
func (c *client) PullManifest(repository, reference string, acceptedMediaTypes ...string) (
@ -399,7 +399,7 @@ func (c *client) PullBlob(repository, digest string) (int64, io.ReadCloser, erro
}
// PullBlobChunk pulls the specified blob, but by chunked, refer to https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pull for more details.
func (c *client) PullBlobChunk(repository, digest string, blobSize int64, start, end int64) (int64, io.ReadCloser, error) {
func (c *client) PullBlobChunk(repository, digest string, _ int64, start, end int64) (int64, io.ReadCloser, error) {
req, err := http.NewRequest(http.MethodGet, buildBlobURL(c.url, repository, digest), nil)
if err != nil {
return 0, nil, err

View File

@ -42,7 +42,7 @@ type RepoRecord struct {
}
// FilterByBlobDigest filters the repositories by the blob digest
func (r *RepoRecord) FilterByBlobDigest(ctx context.Context, qs orm.QuerySeter, key string, value interface{}) orm.QuerySeter {
func (r *RepoRecord) FilterByBlobDigest(_ context.Context, qs orm.QuerySeter, _ string, value interface{}) orm.QuerySeter {
digest, ok := value.(string)
if !ok || len(digest) == 0 {
return qs

View File

@ -278,7 +278,7 @@ func getProjects(ctx context.Context, projectMgr project.Manager) ([]*selector.C
return candidates, nil
}
func getRepositories(ctx context.Context, projectMgr project.Manager, repositoryMgr repository.Manager, projectID int64) ([]*selector.Candidate, error) {
func getRepositories(ctx context.Context, _ project.Manager, repositoryMgr repository.Manager, projectID int64) ([]*selector.Candidate, error) {
var candidates []*selector.Candidate
/*
pro, err := projectMgr.Get(projectID)

View File

@ -28,7 +28,7 @@ const (
type evaluator struct{}
// Process for the "nothing" Evaluator simply returns the input with no error
func (e *evaluator) Process(artifacts []*selector.Candidate) (processed []*selector.Candidate, err error) {
func (e *evaluator) Process(_ []*selector.Candidate) (processed []*selector.Candidate, err error) {
return processed, err
}

View File

@ -160,7 +160,7 @@ func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter
return filteredArts, nil
}
func (dfp *DefaultFilterProcessor) ProcessLabelFilter(ctx context.Context, labelIDs []int64, arts []*artifact.Artifact) ([]*artifact.Artifact, error) {
func (dfp *DefaultFilterProcessor) ProcessLabelFilter(_ context.Context, labelIDs []int64, arts []*artifact.Artifact) ([]*artifact.Artifact, error) {
// return all artifacts if no label need to be filtered
if len(labelIDs) == 0 {
return arts, nil

View File

@ -98,7 +98,7 @@ func (c *nativeToRelationalSchemaConverter) FromRelationalSchema(ctx context.Con
return rp, nil
}
func (c *nativeToRelationalSchemaConverter) toSchema(ctx context.Context, reportUUID string, registrationUUID string, digest string, rawReportData string) error {
func (c *nativeToRelationalSchemaConverter) toSchema(ctx context.Context, reportUUID string, registrationUUID string, _ string, rawReportData string) error {
var vulnReport vuln.Report
err := json.Unmarshal([]byte(rawReportData), &vulnReport)
if err != nil {
@ -198,7 +198,7 @@ func (c *nativeToRelationalSchemaConverter) toSchema(ctx context.Context, report
return nil
}
func (c *nativeToRelationalSchemaConverter) fromSchema(ctx context.Context, reportUUID string, artifactDigest string, reportSummary string, records []*scan.VulnerabilityRecord) (string, error) {
func (c *nativeToRelationalSchemaConverter) fromSchema(_ context.Context, _ string, artifactDigest string, reportSummary string, records []*scan.VulnerabilityRecord) (string, error) {
if len(reportSummary) == 0 {
return "", nil
}

Some files were not shown because too many files have changed in this diff Show More