mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 10:15:35 +01:00
fix deadcode lint & update golangci-lint.yaml (#16896)
* fix deadcode lint & update golangci-lint.yaml Signed-off-by: yminer <yminer@vmmware.com> mock.go Signed-off-by: yminer <yminer@vmmware.com> commentfmt Signed-off-by: yminer <yminer@vmmware.com> mock.go update Signed-off-by: yminer <yminer@vmmware.com> update makefile Signed-off-by: yminer <yminer@vmmware.com> * update /pkg/allowlist/validator.go Signed-off-by: yminer <yminer@vmmware.com> Co-authored-by: yminer <yminer@vmmware.com>
This commit is contained in:
parent
d26b5792c0
commit
9d8e9158de
2
Makefile
2
Makefile
@ -537,7 +537,7 @@ GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint
|
||||
lint:
|
||||
@echo checking lint
|
||||
@echo $(GOLANGCI_LINT)
|
||||
@$(GOLANGCI_LINT) -v run ./src/...
|
||||
@cd ./src/; $(GOLANGCI_LINT) -v run ./...;
|
||||
|
||||
pushimage:
|
||||
@echo "pushing harbor images ..."
|
||||
|
@ -27,12 +27,12 @@ linters:
|
||||
# - nolintlint
|
||||
# - revive
|
||||
# - whitespace
|
||||
# - bodyclose
|
||||
# - deadcode
|
||||
- bodyclose
|
||||
- deadcode
|
||||
# - errcheck
|
||||
# - gosec
|
||||
# - gosimple
|
||||
# - govet
|
||||
- govet
|
||||
# - noctx
|
||||
# - rowserrcheck
|
||||
# - staticcheck
|
||||
@ -47,8 +47,8 @@ run:
|
||||
skip-files:
|
||||
- ".*_test.go"
|
||||
- ".*test.go"
|
||||
skip-dir:
|
||||
- "./testing/"
|
||||
skip-dirs:
|
||||
- "testing/"
|
||||
timeout: 5m
|
||||
|
||||
issue:
|
||||
|
@ -29,7 +29,6 @@ const (
|
||||
|
||||
defaultRepo = "library"
|
||||
rootUploadingEndpoint = "/api/chartrepo/charts"
|
||||
rootIndexEndpoint = "/chartrepo/index.yaml"
|
||||
chartRepoHealthEndpoint = "/api/chartrepo/health"
|
||||
)
|
||||
|
||||
|
@ -10,11 +10,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
contentTypeHeader = "content-type"
|
||||
contentTypeJSON = "application/json"
|
||||
)
|
||||
|
||||
// Extract error object '{"error": "****---***"}' from the content if existing
|
||||
// nil error will be returned if it does exist
|
||||
func extractError(content []byte) (text string, err error) {
|
||||
|
@ -27,7 +27,6 @@ const (
|
||||
internalVerifyClientCert = "INTERNAL_VERIFY_CLIENT_CERT"
|
||||
internalTLSKeyPath = "INTERNAL_TLS_KEY_PATH"
|
||||
internalTLSCertPath = "INTERNAL_TLS_CERT_PATH"
|
||||
internalTrustCAPath = "INTERNAL_TLS_TRUST_CA_PATH"
|
||||
)
|
||||
|
||||
// InternalTLSEnabled returns true if internal TLS enabled
|
||||
|
@ -14,11 +14,12 @@
|
||||
|
||||
package flow
|
||||
|
||||
import (
|
||||
"github.com/goharbor/harbor/src/pkg/reg/adapter"
|
||||
)
|
||||
import "github.com/goharbor/harbor/src/pkg/reg/adapter"
|
||||
|
||||
// define a new interface to combine the two interfaces of adapter for mockery to generate the mocks
|
||||
|
||||
// nolint:deadcode
|
||||
// for make gen_mocks use
|
||||
type registryAdapter interface {
|
||||
adapter.Adapter
|
||||
adapter.ArtifactRegistry
|
||||
|
@ -39,12 +39,6 @@ const (
|
||||
rootIndexEndpoint = "/chartrepo/index.yaml"
|
||||
chartRepoHealthEndpoint = "/api/chartrepo/health"
|
||||
|
||||
accessLevelPublic = iota
|
||||
accessLevelRead
|
||||
accessLevelWrite
|
||||
accessLevelAll
|
||||
accessLevelSystem
|
||||
|
||||
formFieldNameForChart = "chart"
|
||||
formFiledNameForProv = "prov"
|
||||
headerContentType = "Content-Type"
|
||||
|
@ -48,12 +48,6 @@ func (cc *CommonController) Render() error {
|
||||
// Prepare overwrites the Prepare func in api.BaseController to ignore unnecessary steps
|
||||
func (cc *CommonController) Prepare() {}
|
||||
|
||||
type messageDetail struct {
|
||||
Hint string
|
||||
URL string
|
||||
UUID string
|
||||
}
|
||||
|
||||
func redirectForOIDC(ctx context.Context, username string) bool {
|
||||
if lib.GetAuthMode(ctx) != common.OIDCAuth {
|
||||
return false
|
||||
|
@ -41,17 +41,10 @@ func IsInvalidErr(err error) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
const cveIDPattern = `^CVE-\d{4}-\d+$`
|
||||
|
||||
// Validate help validates the CVE allowlist, to ensure the CVE ID is valid and there's no duplication
|
||||
func Validate(wl models2.CVEAllowlist) error {
|
||||
m := map[string]struct{}{}
|
||||
// re := regexp.MustCompile(cveIDPattern)
|
||||
for _, it := range wl.Items {
|
||||
// Bypass the cve format checking
|
||||
// if !re.MatchString(it.CVEID) {
|
||||
// return &invalidErr{fmt.Sprintf("invalid CVE ID: %s", it.CVEID)}
|
||||
// }
|
||||
if _, ok := m[it.CVEID]; ok {
|
||||
return &invalidErr{fmt.Sprintf("duplicate CVE ID in allowlist: %s", it.CVEID)}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ const (
|
||||
dialConnectionTimeout = 30 * time.Second
|
||||
dialReadTimeout = 10 * time.Second
|
||||
dialWriteTimeout = 10 * time.Second
|
||||
pageItemNum = 20.0
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -3,7 +3,7 @@ package aliacr
|
||||
import "time"
|
||||
|
||||
const (
|
||||
defaultTemporaryTokenExpiredTime = time.Hour * 1
|
||||
defaultTemporaryTokenExpiredTime = time.Hour * 1 // nolint:deadcode
|
||||
registryEndpointTpl = "https://registry.%s.aliyuncs.com"
|
||||
endpointTpl = "cr.%s.aliyuncs.com"
|
||||
)
|
||||
|
@ -24,19 +24,6 @@ const (
|
||||
// ErrHTTPNotFound defines the return error when receiving 404 response code
|
||||
var ErrHTTPNotFound = errors.New("not found")
|
||||
|
||||
func searchPackages(kind, offset, limit int, queryString string) string {
|
||||
if len(queryString) == 0 {
|
||||
return fmt.Sprintf("/api/v1/packages/search?kind=%d&limit=%d&offset=%d",
|
||||
kind, limit, offset)
|
||||
}
|
||||
return fmt.Sprintf("/api/v1/packages/search?kind=%d&limit=%d&offset=%d&ts_query_web=%s",
|
||||
kind, limit, offset, queryString)
|
||||
}
|
||||
|
||||
func getHelmPackageDetail(fullName string) string {
|
||||
return fmt.Sprintf("/api/v1/packages/helm/%s", fullName)
|
||||
}
|
||||
|
||||
func getHelmVersion(fullName, version string) string {
|
||||
return fmt.Sprintf("/api/v1/packages/helm/%s/%s", fullName, version)
|
||||
}
|
||||
|
@ -17,10 +17,6 @@ import (
|
||||
common_http "github.com/goharbor/harbor/src/common/http"
|
||||
)
|
||||
|
||||
const (
|
||||
scheme = "bearer"
|
||||
)
|
||||
|
||||
// Client is a client to interact with GitLab
|
||||
type Client struct {
|
||||
client *common_http.Client
|
||||
@ -55,9 +51,6 @@ func NewClient(registry *model.Registry) (*Client, error) {
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func buildPingURL(endpoint string) string {
|
||||
return fmt.Sprintf("%s/v2/", endpoint)
|
||||
}
|
||||
func (c *Client) newRequest(method, url string, body io.Reader) (*http.Request, error) {
|
||||
req, err := http.NewRequest(method, url, body)
|
||||
if err != nil {
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
|
||||
var (
|
||||
errInvalidTcrEndpoint error = errors.New("[tencent-tcr.newAdapter] Invalid TCR instance endpoint")
|
||||
errPingTcrEndpointFailed error = errors.New("[tencent-tcr.newAdapter] Ping TCR instance endpoint failed")
|
||||
errPingTcrEndpointFailed error = errors.New("[tencent-tcr.newAdapter] Ping TCR instance endpoint failed") // nolint:deadcode
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -299,7 +299,3 @@ func toVulnerabilityItem(record *scan.VulnerabilityRecord, artifactDigest string
|
||||
|
||||
return item
|
||||
}
|
||||
|
||||
func convertingKey(reportUUID string) string {
|
||||
return fmt.Sprintf("converting:%s", reportUUID)
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ package report
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/errors"
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
@ -103,10 +102,6 @@ type Manager interface {
|
||||
List(ctx context.Context, query *q.Query) ([]*scan.Report, error)
|
||||
}
|
||||
|
||||
const (
|
||||
reportTimeout = 1 * time.Hour
|
||||
)
|
||||
|
||||
// basicManager is a default implementation of report manager.
|
||||
type basicManager struct {
|
||||
dao scan.DAO
|
||||
|
@ -2,6 +2,7 @@ package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/orm"
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
"github.com/goharbor/harbor/src/pkg/systemartifact/model"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
|
||||
const (
|
||||
sizeQuery = "select sum(size) as total_size from system_artifact"
|
||||
totalSizeColumn = "total_size"
|
||||
)
|
||||
|
||||
// DAO defines an data access interface for manging the CRUD and read of system
|
||||
|
Loading…
Reference in New Issue
Block a user