mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-25 03:35:21 +01:00
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:
parent
5f828ea72f
commit
b38de22054
10
.github/workflows/CI.yml
vendored
10
.github/workflows/CI.yml
vendored
@ -44,7 +44,7 @@ jobs:
|
|||||||
- name: Set up Go 1.21
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.21.4
|
go-version: 1.21.5
|
||||||
id: go
|
id: go
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@ -105,7 +105,7 @@ jobs:
|
|||||||
- name: Set up Go 1.21
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.21.4
|
go-version: 1.21.5
|
||||||
id: go
|
id: go
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@ -160,7 +160,7 @@ jobs:
|
|||||||
- name: Set up Go 1.21
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.21.4
|
go-version: 1.21.5
|
||||||
id: go
|
id: go
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@ -215,7 +215,7 @@ jobs:
|
|||||||
- name: Set up Go 1.21
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.21.4
|
go-version: 1.21.5
|
||||||
id: go
|
id: go
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
@ -268,7 +268,7 @@ jobs:
|
|||||||
- name: Set up Go 1.21
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.21.4
|
go-version: 1.21.5
|
||||||
id: go
|
id: go
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/build-package.yml
vendored
2
.github/workflows/build-package.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Set up Go 1.21
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.21.4
|
go-version: 1.21.5
|
||||||
id: go
|
id: go
|
||||||
- name: Setup Docker
|
- name: Setup Docker
|
||||||
uses: docker-practice/actions-setup-docker@master
|
uses: docker-practice/actions-setup-docker@master
|
||||||
|
2
.github/workflows/conformance_test.yml
vendored
2
.github/workflows/conformance_test.yml
vendored
@ -28,7 +28,7 @@ jobs:
|
|||||||
- name: Set up Go 1.21
|
- name: Set up Go 1.21
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.21.4
|
go-version: 1.21.5
|
||||||
id: go
|
id: go
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
@ -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.7 | 1.19.4 |
|
||||||
| 2.8 | 1.20.6 |
|
| 2.8 | 1.20.6 |
|
||||||
| 2.9 | 1.21.3 |
|
| 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.
|
Ensure your GOPATH and PATH have been configured in accordance with the Go environment instructions.
|
||||||
|
4
Makefile
4
Makefile
@ -140,7 +140,7 @@ GOINSTALL=$(GOCMD) install
|
|||||||
GOTEST=$(GOCMD) test
|
GOTEST=$(GOCMD) test
|
||||||
GODEP=$(GOTEST) -i
|
GODEP=$(GOTEST) -i
|
||||||
GOFMT=gofmt -w
|
GOFMT=gofmt -w
|
||||||
GOBUILDIMAGE=golang:1.21.4
|
GOBUILDIMAGE=golang:1.21.5
|
||||||
GOBUILDPATHINCONTAINER=/harbor
|
GOBUILDPATHINCONTAINER=/harbor
|
||||||
|
|
||||||
# go build
|
# go build
|
||||||
@ -479,7 +479,7 @@ misspell:
|
|||||||
@find . -type d \( -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error
|
@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
|
# 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
|
GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint
|
||||||
lint:
|
lint:
|
||||||
@echo checking lint
|
@echo checking lint
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.21.4
|
FROM golang:1.21.5
|
||||||
|
|
||||||
ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution
|
ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution
|
||||||
ENV BUILDTAGS include_oss include_gcs
|
ENV BUILDTAGS include_oss include_gcs
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.21.4
|
FROM golang:1.21.5
|
||||||
|
|
||||||
ADD . /go/src/github.com/aquasecurity/harbor-scanner-trivy/
|
ADD . /go/src/github.com/aquasecurity/harbor-scanner-trivy/
|
||||||
WORKDIR /go/src/github.com/aquasecurity/harbor-scanner-trivy/
|
WORKDIR /go/src/github.com/aquasecurity/harbor-scanner-trivy/
|
||||||
|
@ -19,7 +19,7 @@ TEMP=$(mktemp -d ${TMPDIR-/tmp}/trivy-adapter.XXXXXX)
|
|||||||
git clone https://github.com/aquasecurity/harbor-scanner-trivy.git $TEMP
|
git clone https://github.com/aquasecurity/harbor-scanner-trivy.git $TEMP
|
||||||
cd $TEMP; git checkout $VERSION; cd -
|
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
|
cp Dockerfile.binary $TEMP
|
||||||
docker build -f $TEMP/Dockerfile.binary -t trivy-adapter-golang $TEMP
|
docker build -f $TEMP/Dockerfile.binary -t trivy-adapter-golang $TEMP
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ func (s *SecurityContext) IsSolutionUser() bool {
|
|||||||
// Can returns whether the user can do action on resource
|
// Can returns whether the user can do action on resource
|
||||||
// returns true if the corresponding user of the secret
|
// returns true if the corresponding user of the secret
|
||||||
// is jobservice or core service, otherwise returns false
|
// 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 {
|
if s.store == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ func (t *tokenSecurityCtx) GetMyProjects() ([]*models.Project, error) {
|
|||||||
return []*models.Project{}, nil
|
return []*models.Project{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tokenSecurityCtx) GetProjectRoles(projectIDOrName interface{}) []int {
|
func (t *tokenSecurityCtx) GetProjectRoles(_ interface{}) []int {
|
||||||
return []int{}
|
return []int{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ type GCResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRegistryCtl returns a mock registry server
|
// 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{}
|
m := []*RequestHandlerMapping{}
|
||||||
|
|
||||||
gcr := GCResult{true, "hello-world", time.Now(), time.Now()}
|
gcr := GCResult{true, "hello-world", time.Now(), time.Now()}
|
||||||
|
@ -49,7 +49,7 @@ func (fc *FakeClient) GetUserInfo(token string) (*UserInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateConfig ...
|
// UpdateConfig ...
|
||||||
func (fc *FakeClient) UpdateConfig(cfg *ClientConfig) error {
|
func (fc *FakeClient) UpdateConfig(_ *ClientConfig) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ type v1alpha1Parser struct {
|
|||||||
regCli reg.Client
|
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 {
|
if artifact.ManifestMediaType != v1.MediaTypeImageManifest && artifact.ManifestMediaType != schema2.MediaTypeManifest {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -37,22 +37,22 @@ type IndexProcessor struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AbstractMetadata abstracts metadata of artifact
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbstractAddition abstracts the addition of artifact
|
// 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).
|
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
|
||||||
WithMessage("addition %s isn't supported", addition)
|
WithMessage("addition %s isn't supported", addition)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetArtifactType returns the artifact type
|
// 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 ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListAdditionTypes returns the supported addition types
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -64,23 +64,23 @@ func (m *ManifestProcessor) AbstractMetadata(ctx context.Context, artifact *arti
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AbstractAddition abstracts the addition of artifact
|
// 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).
|
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
|
||||||
WithMessage("addition %s isn't supported", addition)
|
WithMessage("addition %s isn't supported", addition)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetArtifactType returns the artifact type
|
// 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 ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListAdditionTypes returns the supported addition types
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalConfig unmarshal the config blob of the artifact into the specified object "v"
|
// 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
|
// unmarshal manifest
|
||||||
mani := &v1.Manifest{}
|
mani := &v1.Manifest{}
|
||||||
if err := json.Unmarshal(manifest, mani); err != nil {
|
if err := json.Unmarshal(manifest, mani); err != nil {
|
||||||
|
@ -58,7 +58,7 @@ type processor struct {
|
|||||||
chartOperator chart.Operator
|
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 {
|
if addition != AdditionTypeValues && addition != AdditionTypeReadme && addition != AdditionTypeDependencies {
|
||||||
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
|
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
|
||||||
WithMessage("addition %s isn't supported for %s", addition, ArtifactTypeChart)
|
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
|
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
|
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}
|
return []string{AdditionTypeValues, AdditionTypeReadme, AdditionTypeDependencies}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ type processor struct {
|
|||||||
manifestProcessor *base.ManifestProcessor
|
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 := ""
|
cfgManiDgt := ""
|
||||||
// try to get the digest of the manifest that the config layer is referenced by
|
// try to get the digest of the manifest that the config layer is referenced by
|
||||||
for _, reference := range art.References {
|
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)
|
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
|
return ArtifactTypeCNAB
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ type defaultProcessor struct {
|
|||||||
regCli registry.Client
|
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
|
// try to parse the type from the media type
|
||||||
strs := artifactTypeRegExp.FindStringSubmatch(artifact.MediaType)
|
strs := artifactTypeRegExp.FindStringSubmatch(artifact.MediaType)
|
||||||
if len(strs) == 2 {
|
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
|
// can not get the artifact type from the media type, return unknown
|
||||||
return ArtifactTypeUnknown
|
return ArtifactTypeUnknown
|
||||||
}
|
}
|
||||||
func (d *defaultProcessor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
|
func (d *defaultProcessor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ func (d *defaultProcessor) AbstractMetadata(ctx context.Context, artifact *artif
|
|||||||
return nil
|
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.
|
// Addition not support for user-defined artifact yet.
|
||||||
// It will be support in the future.
|
// It will be support in the future.
|
||||||
// return error directly
|
// return error directly
|
||||||
|
@ -44,6 +44,6 @@ type indexProcessor struct {
|
|||||||
*base.IndexProcessor
|
*base.IndexProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *indexProcessor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
|
func (i *indexProcessor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
|
||||||
return ArtifactTypeImage
|
return ArtifactTypeImage
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func init() {
|
|||||||
type manifestV1Processor struct {
|
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{}
|
mani := &schema1.Manifest{}
|
||||||
if err := json.Unmarshal(manifest, mani); err != nil {
|
if err := json.Unmarshal(manifest, mani); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -50,15 +50,15 @@ func (m *manifestV1Processor) AbstractMetadata(ctx context.Context, artifact *ar
|
|||||||
return nil
|
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).
|
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
|
||||||
WithMessage("addition %s isn't supported for %s(manifest version 1)", addition, ArtifactTypeImage)
|
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
|
return ArtifactTypeImage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *manifestV1Processor) ListAdditionTypes(ctx context.Context, artifact *artifact.Artifact) []string {
|
func (m *manifestV1Processor) ListAdditionTypes(_ context.Context, _ *artifact.Artifact) []string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,10 @@ func (m *manifestV2Processor) AbstractAddition(ctx context.Context, artifact *ar
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *manifestV2Processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
|
func (m *manifestV2Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
|
||||||
return ArtifactTypeImage
|
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}
|
return []string{AdditionTypeBuildHistory}
|
||||||
}
|
}
|
||||||
|
@ -128,10 +128,10 @@ func (m *Processor) AbstractAddition(ctx context.Context, artifact *artifact.Art
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Processor) GetArtifactType(ctx context.Context, artifact *artifact.Artifact) string {
|
func (m *Processor) GetArtifactType(_ context.Context, _ *artifact.Artifact) string {
|
||||||
return ArtifactTypeWASM
|
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}
|
return []string{AdditionTypeBuildHistory}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// 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)
|
maxValue := maxValueLimitedByLength(common.UIMaxLengthLimitedOfNumber)
|
||||||
validateCfgs := []string{
|
validateCfgs := []string{
|
||||||
common.TokenExpiration,
|
common.TokenExpiration,
|
||||||
|
@ -159,7 +159,7 @@ func (a *ArtifactEventHandler) onPull(ctx context.Context, event *event.Artifact
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ArtifactEventHandler) updatePullTimeInCache(ctx context.Context, event *event.ArtifactEvent) {
|
func (a *ArtifactEventHandler) updatePullTimeInCache(_ context.Context, event *event.ArtifactEvent) {
|
||||||
var tagName string
|
var tagName string
|
||||||
if len(event.Tags) != 0 {
|
if len(event.Tags) != 0 {
|
||||||
tagName = event.Tags[0]
|
tagName = event.Tags[0]
|
||||||
@ -173,7 +173,7 @@ func (a *ArtifactEventHandler) updatePullTimeInCache(ctx context.Context, event
|
|||||||
a.pullTimeStore[key] = time.Now()
|
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()
|
a.pullCountLock.Lock()
|
||||||
defer a.pullCountLock.Unlock()
|
defer a.pullCountLock.Unlock()
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ func gcCallback(ctx context.Context, p string) error {
|
|||||||
return err
|
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) {
|
if status == job.SuccessStatus.String() && config.QuotaPerProjectEnable(ctx) {
|
||||||
go func() {
|
go func() {
|
||||||
err := quota.RefreshForProjects(orm.Context())
|
err := quota.RefreshForProjects(orm.Context())
|
||||||
|
@ -41,7 +41,7 @@ type Controller interface {
|
|||||||
|
|
||||||
type controller struct{}
|
type controller struct{}
|
||||||
|
|
||||||
func (c *controller) GetHealth(ctx context.Context) *OverallHealthStatus {
|
func (c *controller) GetHealth(_ context.Context) *OverallHealthStatus {
|
||||||
var isHealthy healthy = true
|
var isHealthy healthy = true
|
||||||
components := []*ComponentHealthStatus{}
|
components := []*ComponentHealthStatus{}
|
||||||
ch := make(chan *ComponentHealthStatus, len(registry))
|
ch := make(chan *ComponentHealthStatus, len(registry))
|
||||||
|
@ -495,7 +495,7 @@ func (c *controller) ListPoliciesByProject(ctx context.Context, project int64, q
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CheckHealth checks the instance health, for test connection
|
// 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 {
|
if instance == nil {
|
||||||
return errors.New("instance can not be nil")
|
return errors.New("instance can not be nil")
|
||||||
}
|
}
|
||||||
|
@ -150,9 +150,9 @@ func (c *controller) Exists(ctx context.Context, projectIDOrName interface{}) (b
|
|||||||
return true, nil
|
return true, nil
|
||||||
} else if errors.IsNotFoundErr(err) {
|
} else if errors.IsNotFoundErr(err) {
|
||||||
return false, nil
|
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) {
|
func (c *controller) Get(ctx context.Context, projectIDOrName interface{}, options ...Option) (*models.Project, error) {
|
||||||
|
@ -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
|
// search the digest in cache and query with trimmed digest
|
||||||
var trimmedDigest string
|
var trimmedDigest string
|
||||||
err := c.cache.Fetch(ctx, TrimmedManifestlist+art.Digest, &trimmedDigest)
|
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
|
// skip to update digest, continue
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
// for other error, return
|
// for other error, return
|
||||||
@ -260,7 +260,7 @@ func (c *controller) ProxyManifest(ctx context.Context, art lib.ArtifactInfo, re
|
|||||||
return man, nil
|
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)
|
remoteRepo := getRemoteRepo(art)
|
||||||
ref := getReference(art)
|
ref := getReference(art)
|
||||||
return remote.ManifestExist(remoteRepo, ref)
|
return remote.ManifestExist(remoteRepo, ref)
|
||||||
|
@ -81,7 +81,7 @@ func newLocalHelper() localInterface {
|
|||||||
return l
|
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)
|
return l.registry.BlobExist(art.Repository, art.Digest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ type ManifestListCache struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CacheContent ...
|
// 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()
|
_, payload, err := man.Payload()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to get payload, error %v", err)
|
log.Errorf("failed to get payload, error %v", err)
|
||||||
@ -171,7 +171,7 @@ type ManifestCache struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CacheContent ...
|
// 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
|
var waitBlobs []distribution.Descriptor
|
||||||
for n := 0; n < maxManifestWait; n++ {
|
for n := 0; n < maxManifestWait; n++ {
|
||||||
time.Sleep(sleepIntervalSec * time.Second)
|
time.Sleep(sleepIntervalSec * time.Second)
|
||||||
|
@ -464,7 +464,7 @@ func (c *controller) Update(ctx context.Context, u *quota.Quota) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Driver returns quota driver for the reference
|
// 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)
|
d, ok := driver.Get(reference)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("quota not support for %s", reference)
|
return nil, fmt.Errorf("quota not support for %s", reference)
|
||||||
|
@ -43,7 +43,7 @@ type driver struct {
|
|||||||
blobCtl blob.Controller
|
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.
|
// 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 {
|
if err := d.cfg.Load(ctx); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -326,7 +326,7 @@ func (t *transfer) copyChunkWithRetry(srcRepo, dstRepo, digest string, sizeFromD
|
|||||||
}
|
}
|
||||||
|
|
||||||
// tryMountBlob try to check existence and mount, return true if mounted.
|
// 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() {
|
if t.shouldStop() {
|
||||||
return false, errStopped
|
return false, errStopped
|
||||||
}
|
}
|
||||||
|
@ -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)
|
err := cleanupController.Start(ctx, true, task.ExecutionTriggerSchedule)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("System artifact cleanup job encountered errors: %v", err)
|
logger.Errorf("System artifact cleanup job encountered errors: %v", err)
|
||||||
|
@ -147,7 +147,7 @@ func OIDCProviderName(cfg map[string]interface{}) string {
|
|||||||
return utils.SafeCastString(cfg[common.OIDCName])
|
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()
|
systeminfo.Init()
|
||||||
return imagestorage.GlobalDriver.Cap()
|
return imagestorage.GlobalDriver.Cap()
|
||||||
}
|
}
|
||||||
@ -158,14 +158,15 @@ func (c *controller) GetCA(ctx context.Context) (io.ReadCloser, error) {
|
|||||||
if len(testRootCertPath) > 0 {
|
if len(testRootCertPath) > 0 {
|
||||||
path = testRootCertPath
|
path = testRootCertPath
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(path); err == nil {
|
_, err := os.Stat(path)
|
||||||
|
if err == nil {
|
||||||
return os.Open(path)
|
return os.Open(path)
|
||||||
} else if os.IsNotExist(err) {
|
} else if os.IsNotExist(err) {
|
||||||
return nil, errors.NotFoundError(fmt.Errorf("cert not found in path: %s", path))
|
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
|
// NewController return an instance of controller
|
||||||
|
@ -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()}
|
params := &SweepParams{ExecRetainCounts: job.GetExecutionSweeperCount()}
|
||||||
return SweepCtl.Start(ctx, params, task.ExecutionTriggerSchedule)
|
return SweepCtl.Start(ctx, params, task.ExecutionTriggerSchedule)
|
||||||
}
|
}
|
||||||
|
@ -88,35 +88,35 @@ type DefaultAuthenticateHelper struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Authenticate ...
|
// 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
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnBoardUser will check if a user exists in user table, if not insert the user and
|
// 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
|
// 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
|
// 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
|
return ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchUser - Get user information from account repository
|
// 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)
|
log.Errorf("Not support searching user, username: %s", username)
|
||||||
return nil, libErrors.NotFoundError(ErrNotSupported).WithMessage("%s not found", username)
|
return nil, libErrors.NotFoundError(ErrNotSupported).WithMessage("%s not found", username)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostAuthenticate - Update user information after authenticate, such as OnBoard or sync info etc
|
// 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
|
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.
|
// 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
|
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
|
// 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)
|
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).WithMessage("%s not found", groupKey)
|
||||||
}
|
}
|
||||||
|
@ -102,13 +102,13 @@ func (a *Auth) Authenticate(ctx context.Context, m models.AuthModel) (*models.Us
|
|||||||
return user, nil
|
return user, nil
|
||||||
} else if resp.StatusCode == http.StatusUnauthorized {
|
} else if resp.StatusCode == http.StatusUnauthorized {
|
||||||
return nil, auth.NewErrAuth(string(data))
|
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) {
|
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.
|
// 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 group name provided, on board the user group
|
||||||
if len(u.GroupName) == 0 {
|
if len(u.GroupName) == 0 {
|
||||||
return errors.New("should provide a group name")
|
return errors.New("should provide a group name")
|
||||||
|
@ -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)))
|
_, err := rw.Write([]byte(fmt.Sprintf(`{"session_id": "%s"}`, e.sessionID)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
// else
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
http.Error(rw, fmt.Sprintf("Do not find entry in entrylist, username: %s", html.EscapeString(u)), http.StatusUnauthorized)
|
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)))
|
_, err := rw.Write([]byte(fmt.Sprintf(reviewStatusTpl, e.username)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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)
|
http.Error(rw, html.EscapeString(fmt.Sprintf("failed to match token: %s, entrylist: %+v", reviewData.Spec.Token, rth.entries)), http.StatusUnauthorized)
|
||||||
|
@ -54,7 +54,7 @@ func (d *Auth) SearchUser(ctx context.Context, username string) (*models.User, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OnBoardUser -
|
// OnBoardUser -
|
||||||
func (d *Auth) OnBoardUser(ctx context.Context, u *models.User) error {
|
func (d *Auth) OnBoardUser(_ context.Context, _ *models.User) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ type Auth struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SearchGroup is skipped in OIDC mode, so it makes sure any group will be onboarded.
|
// 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{
|
return &model.UserGroup{
|
||||||
GroupName: groupKey,
|
GroupName: groupKey,
|
||||||
GroupType: common.OIDCGroupType,
|
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.
|
// 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 group name provided, on board the user group
|
||||||
if len(u.GroupName) == 0 || u.GroupType != common.OIDCGroupType {
|
if len(u.GroupName) == 0 || u.GroupType != common.OIDCGroupType {
|
||||||
return fmt.Errorf("invalid input group for OIDC mode: %v", *u)
|
return fmt.Errorf("invalid input group for OIDC mode: %v", *u)
|
||||||
|
@ -124,7 +124,7 @@ type accessFilter interface {
|
|||||||
type registryFilter struct {
|
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 {
|
a *token.ResourceActions) error {
|
||||||
// Do not filter if the request is to access registry catalog
|
// Do not filter if the request is to access registry catalog
|
||||||
if a.Name != "catalog" {
|
if a.Name != "catalog" {
|
||||||
|
@ -46,7 +46,7 @@ type Store struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set value in redis session
|
// 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()
|
rs.lock.Lock()
|
||||||
defer rs.lock.Unlock()
|
defer rs.lock.Unlock()
|
||||||
rs.values[key] = value
|
rs.values[key] = value
|
||||||
@ -54,7 +54,7 @@ func (rs *Store) Set(ctx context.Context, key, value interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get value in redis session
|
// 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()
|
rs.lock.RLock()
|
||||||
defer rs.lock.RUnlock()
|
defer rs.lock.RUnlock()
|
||||||
if v, ok := rs.values[key]; ok {
|
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
|
// 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()
|
rs.lock.Lock()
|
||||||
defer rs.lock.Unlock()
|
defer rs.lock.Unlock()
|
||||||
delete(rs.values, key)
|
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
|
// 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()
|
rs.lock.Lock()
|
||||||
defer rs.lock.Unlock()
|
defer rs.lock.Unlock()
|
||||||
rs.values = make(map[interface{}]interface{})
|
rs.values = make(map[interface{}]interface{})
|
||||||
@ -80,12 +80,12 @@ func (rs *Store) Flush(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SessionID get redis session id
|
// SessionID get redis session id
|
||||||
func (rs *Store) SessionID(ctx context.Context) string {
|
func (rs *Store) SessionID(_ context.Context) string {
|
||||||
return rs.sid
|
return rs.sid
|
||||||
}
|
}
|
||||||
|
|
||||||
// SessionRelease save session values to redis
|
// 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)
|
b, err := session.EncodeGob(rs.values)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -192,11 +192,11 @@ func (rp *Provider) SessionDestroy(ctx context.Context, sid string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SessionGC Implement method, no used.
|
// SessionGC Implement method, no used.
|
||||||
func (rp *Provider) SessionGC(ctx context.Context) {
|
func (rp *Provider) SessionGC(_ context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SessionAll return all activeSession
|
// SessionAll return all activeSession
|
||||||
func (rp *Provider) SessionAll(ctx context.Context) int {
|
func (rp *Provider) SessionAll(_ context.Context) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ func (gc *GarbageCollector) ShouldRetry() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate implements the interface in job/Interface
|
// Validate implements the interface in job/Interface
|
||||||
func (gc *GarbageCollector) Validate(params job.Parameters) error {
|
func (gc *GarbageCollector) Validate(_ job.Parameters) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ func (wj *WebhookJob) ShouldRetry() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate implements the interface in job/Interface
|
// Validate implements the interface in job/Interface
|
||||||
func (wj *WebhookJob) Validate(params job.Parameters) error {
|
func (wj *WebhookJob) Validate(_ job.Parameters) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ func (wj *WebhookJob) init(ctx job.Context, params map[string]interface{}) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// execute webhook job
|
// 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)
|
payload := params["payload"].(string)
|
||||||
address := params["address"].(string)
|
address := params["address"].(string)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func (j *Job) ShouldRetry() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate is implementation of same method in Interface.
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ func (r *Replication) ShouldRetry() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate does nothing
|
// Validate does nothing
|
||||||
func (r *Replication) Validate(params job.Parameters) error {
|
func (r *Replication) Validate(_ job.Parameters) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ func (sde *ScanDataExport) ShouldRetry() bool {
|
|||||||
// Validate Indicate whether the parameters of job are valid.
|
// Validate Indicate whether the parameters of job are valid.
|
||||||
// Return:
|
// Return:
|
||||||
// error if parameters are not valid. NOTES: If no parameters needed, directly return nil.
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ func (c *Cleanup) ShouldRetry() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cleanup) Validate(params job.Parameters) error {
|
func (c *Cleanup) Validate(_ job.Parameters) error {
|
||||||
return nil
|
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 := ctx.GetLogger()
|
||||||
logger.Infof("Running system data artifact cleanup job...")
|
logger.Infof("Running system data artifact cleanup job...")
|
||||||
c.init()
|
c.init()
|
||||||
|
@ -41,6 +41,6 @@ func FileGetterFactory(options ...OptionItem) (getter.Interface, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DBGetterFactory creates a getter for the DB logger
|
// 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
|
return getter.NewDBGetter(), nil
|
||||||
}
|
}
|
||||||
|
@ -95,11 +95,11 @@ func (rj *RedisJob) Run(j *work.Job) (err error) {
|
|||||||
<-time.After(time.Duration(b) * time.Millisecond)
|
<-time.After(time.Duration(b) * time.Millisecond)
|
||||||
span.AddEvent("retrying to get job stat")
|
span.AddEvent("retrying to get job stat")
|
||||||
continue
|
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
|
// Log error and exit
|
||||||
|
@ -347,15 +347,16 @@ func (bs *Bootstrap) loadAndRunRedisWorkerPool(
|
|||||||
|
|
||||||
// Get a redis connection pool
|
// Get a redis connection pool
|
||||||
func (bs *Bootstrap) getRedisPool(redisPoolConfig *config.RedisPoolConfig) *redis.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,
|
PoolMaxIdle: 6,
|
||||||
PoolIdleTimeout: time.Duration(redisPoolConfig.IdleTimeoutSecond) * time.Second,
|
PoolIdleTimeout: time.Duration(redisPoolConfig.IdleTimeoutSecond) * time.Second,
|
||||||
DialConnectionTimeout: dialConnectionTimeout,
|
DialConnectionTimeout: dialConnectionTimeout,
|
||||||
DialReadTimeout: dialReadTimeout,
|
DialReadTimeout: dialReadTimeout,
|
||||||
DialWriteTimeout: dialWriteTimeout,
|
DialWriteTimeout: dialWriteTimeout,
|
||||||
}); err != nil {
|
})
|
||||||
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
} else {
|
|
||||||
return pool
|
|
||||||
}
|
}
|
||||||
|
// else
|
||||||
|
return pool
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ func (w *basicWorker) Schedule(jobName string, params job.Parameters, runAfterSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PeriodicallyEnqueue job
|
// 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{
|
p := &period.Policy{
|
||||||
ID: utils.MakeIdentifier(),
|
ID: utils.MakeIdentifier(),
|
||||||
JobName: jobName,
|
JobName: jobName,
|
||||||
@ -369,7 +369,7 @@ func (w *basicWorker) StopJob(jobID string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RetryJob retry the job
|
// RetryJob retry the job
|
||||||
func (w *basicWorker) RetryJob(jobID string) error {
|
func (w *basicWorker) RetryJob(_ string) error {
|
||||||
return errors.New("not implemented")
|
return errors.New("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/lib/cache/memory/memory.go
vendored
10
src/lib/cache/memory/memory.go
vendored
@ -60,7 +60,7 @@ func (c *Cache) Contains(ctx context.Context, key string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete delete item from cache by key
|
// 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))
|
c.storage.Delete(c.opts.Key(key))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -89,12 +89,12 @@ func (c *Cache) Fetch(ctx context.Context, key string, value interface{}) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ping ping the cache
|
// Ping ping the cache
|
||||||
func (c *Cache) Ping(ctx context.Context) error {
|
func (c *Cache) Ping(_ context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save cache the value by key
|
// 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)
|
data, err := c.opts.Codec.Encode(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to encode value, key %s, error: %v", key, err)
|
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
|
// 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
|
var keys []string
|
||||||
c.storage.Range(func(k, v interface{}) bool {
|
c.storage.Range(func(k, v interface{}) bool {
|
||||||
matched := true
|
matched := true
|
||||||
@ -147,7 +147,7 @@ type ScanIterator struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Next checks whether has the next element
|
// 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()
|
i.mu.Lock()
|
||||||
defer i.mu.Unlock()
|
defer i.mu.Unlock()
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ func InitWithSettings(cfgs map[string]interface{}, kp ...encrypt.KeyProvider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetCfgManager return the current config manager
|
// GetCfgManager return the current config manager
|
||||||
func GetCfgManager(ctx context.Context) Manager {
|
func GetCfgManager(_ context.Context) Manager {
|
||||||
return DefaultMgr()
|
return DefaultMgr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ type Type interface {
|
|||||||
type StringType struct {
|
type StringType struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *StringType) validate(str string) error {
|
func (t *StringType) validate(_ string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ func (t *BoolType) get(str string) (interface{}, error) {
|
|||||||
type PasswordType struct {
|
type PasswordType struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *PasswordType) validate(str string) error {
|
func (t *PasswordType) validate(_ string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ func NewFileKeyProvider(path string) KeyProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the key read from file
|
// 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)
|
b, err := os.ReadFile(f.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -51,6 +51,6 @@ type PresetKeyProvider struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func (p *PresetKeyProvider) Get(params map[string]interface{}) (string, error) {
|
func (p *PresetKeyProvider) Get(_ map[string]interface{}) (string, error) {
|
||||||
return p.Key, nil
|
return p.Key, nil
|
||||||
}
|
}
|
||||||
|
@ -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
|
// 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 = q.MustClone(query)
|
||||||
query.Sorts = nil
|
query.Sorts = nil
|
||||||
query.PageSize = 0
|
query.PageSize = 0
|
||||||
|
@ -102,9 +102,9 @@ func GetRedisPool(name string, rawurl string, param *PoolParam) (*redis.Pool, er
|
|||||||
}
|
}
|
||||||
knownPool.Store(name, pool)
|
knownPool.Store(name, pool)
|
||||||
return pool, nil
|
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) {
|
func getSentinelPool(u *url.URL, param *PoolParam, name string) (*redis.Pool, error) {
|
||||||
|
@ -50,7 +50,7 @@ func (s *selector) Select(artifacts []*iselector.Candidate) (selected []*iselect
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New is factory method for label selector
|
// 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)
|
labels := make([]string, 0)
|
||||||
|
|
||||||
if pattern != nil {
|
if pattern != nil {
|
||||||
|
@ -82,7 +82,7 @@ func (s *selector) Select(artifacts []*sl.Candidate) (selected []*sl.Candidate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New is factory method for vulnerability severity selector
|
// 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
|
var sev int
|
||||||
if pattern != nil {
|
if pattern != nil {
|
||||||
sev, _ = pattern.(int)
|
sev, _ = pattern.(int)
|
||||||
|
@ -64,7 +64,7 @@ func (s *selector) Select(artifacts []*sl.Candidate) (selected []*sl.Candidate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New is factory method for signature selector
|
// 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
|
var e bool
|
||||||
if pattern != nil {
|
if pattern != nil {
|
||||||
e, _ = pattern.(bool)
|
e, _ = pattern.(bool)
|
||||||
|
@ -35,7 +35,7 @@ type LoggerManager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init redirect the audit log to the forward endpoint
|
// 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
|
var w io.Writer
|
||||||
w, err := syslog.Dial("tcp", logEndpoint,
|
w, err := syslog.Dial("tcp", logEndpoint,
|
||||||
syslog.LOG_INFO, "audit")
|
syslog.LOG_INFO, "audit")
|
||||||
|
@ -123,7 +123,7 @@ func (b *Blob) IsManifest() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FilterByArtifactDigest returns orm.QuerySeter with artifact digest filter
|
// 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)
|
v, ok := value.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return qs
|
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
|
// 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)
|
artifactDigests, ok := value.([]string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return qs
|
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
|
// 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)
|
projectID, ok := value.(int64)
|
||||||
if !ok {
|
if !ok {
|
||||||
return qs
|
return qs
|
||||||
|
@ -87,12 +87,12 @@ func (bm *BaseManager) WithCacheClient(cc cache.Cache) *BaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CacheClient returns the cache client.
|
// 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
|
return bm.cacheClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResourceType returns the resource type.
|
// ResourceType returns the resource type.
|
||||||
func (bm *BaseManager) ResourceType(ctx context.Context) string {
|
func (bm *BaseManager) ResourceType(_ context.Context) string {
|
||||||
return bm.resourceType
|
return bm.resourceType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
// 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()
|
d.Lock()
|
||||||
defer d.Unlock()
|
defer d.Unlock()
|
||||||
for k, v := range cfg {
|
for k, v := range cfg {
|
||||||
|
@ -136,7 +136,7 @@ func (c *CfgManager) Save(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get ...
|
// 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)
|
configValue, err := c.Store.Get(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("failed to get key %v, error: %v, maybe default value not defined before get", key, err)
|
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 ...
|
// 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))
|
configValue, err := metadata.NewCfgValue(key, utils.GetStrValueOfAnyType(value))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("error when setting key: %v, error %v", key, err)
|
log.Errorf("error when setting key: %v, error %v", key, err)
|
||||||
|
@ -41,7 +41,7 @@ type Value struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load - load config data from REST server
|
// 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{}{}
|
cfgMap := map[string]interface{}{}
|
||||||
origMap := map[string]*Value{}
|
origMap := map[string]*Value{}
|
||||||
log.Infof("get configuration from url: %+v", h.configRESTURL)
|
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
|
// 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)
|
return h.client.Put(h.configRESTURL, cfg)
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func (e *Exporter) RegisterCollector(collectors ...collector) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newServer(opt *Opt, r *prometheus.Registry) *http.Server {
|
func newServer(opt *Opt, _ *prometheus.Registry) *http.Server {
|
||||||
exporterMux := http.NewServeMux()
|
exporterMux := http.NewServeMux()
|
||||||
exporterMux.Handle(opt.MetricsPath, promhttp.Handler())
|
exporterMux.Handle(opt.MetricsPath, promhttp.Handler())
|
||||||
exporterMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
exporterMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -94,6 +94,6 @@ func initRepositoryMgr(cacheEnabled bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initManifestManager(cacheEnabled bool) {
|
func initManifestManager(_ bool) {
|
||||||
ManifestMgr = cachedManifest.NewManager()
|
ManifestMgr = cachedManifest.NewManager()
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func NewPoolManager() PoolManager {
|
|||||||
return &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)
|
workerPool := make([]*WorkerPool, 0)
|
||||||
wh, err := monitorClient.WorkerPoolHeartbeats()
|
wh, err := monitorClient.WorkerPoolHeartbeats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -30,7 +30,7 @@ func NewQueueClient() QueueManager {
|
|||||||
return &queueManagerImpl{}
|
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)
|
resultQueues := make([]*Queue, 0)
|
||||||
queues, err := monitClient.Queues()
|
queues, err := monitClient.Queues()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -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
|
// 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()
|
conn := r.redisPool.Get()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
for _, id := range jobIDs {
|
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()
|
conn := r.redisPool.Get()
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
return redis.Strings(conn.Do("SMEMBERS", fmt.Sprintf("{%s}:known_jobs", r.namespace)))
|
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)
|
log.Infof("pause job type:%s", jobName)
|
||||||
redisKeyJobPaused := fmt.Sprintf("{%s}:jobs:%s:paused", r.namespace, jobName)
|
redisKeyJobPaused := fmt.Sprintf("{%s}:jobs:%s:paused", r.namespace, jobName)
|
||||||
conn := r.redisPool.Get()
|
conn := r.redisPool.Get()
|
||||||
@ -161,7 +161,7 @@ func (r *redisClientImpl) PauseJob(ctx context.Context, jobName string) error {
|
|||||||
return err
|
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)
|
log.Infof("unpause job %s", jobName)
|
||||||
redisKeyJobPaused := fmt.Sprintf("{%s}:jobs:%s:paused", r.namespace, jobName)
|
redisKeyJobPaused := fmt.Sprintf("{%s}:jobs:%s:paused", r.namespace, jobName)
|
||||||
conn := r.redisPool.Get()
|
conn := r.redisPool.Get()
|
||||||
|
@ -40,7 +40,7 @@ func NewWorkerManager() WorkerManager {
|
|||||||
return &workerManagerImpl{taskMgr: task.NewManager()}
|
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()
|
wphs, err := monitClient.WorkerPoolHeartbeats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -49,11 +49,11 @@ func New() Manager {
|
|||||||
type manager struct {
|
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)
|
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)
|
users := make([]model.User, 0)
|
||||||
if err := sess.Open(); err != nil {
|
if err := sess.Open(); err != nil {
|
||||||
return users, err
|
return users, err
|
||||||
@ -133,7 +133,7 @@ func (m *manager) ImportUser(ctx context.Context, sess *Session, ldapImportUsers
|
|||||||
return failedImportUser, nil
|
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()
|
err := sess.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -111,7 +111,7 @@ func (d *dao) GetProjectMember(ctx context.Context, queryMember models.Member, q
|
|||||||
return members, err
|
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)
|
log.Debugf("Query condition %+v", projectID)
|
||||||
if projectID == 0 {
|
if projectID == 0 {
|
||||||
return 0, fmt.Errorf("failed to get total of project members, project id required %v", projectID)
|
return 0, fmt.Errorf("failed to get total of project members, project id required %v", projectID)
|
||||||
|
@ -77,7 +77,7 @@ func (h *HookMetaData) Resolve(evt *Event) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build an event by metadata
|
// 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 {
|
for _, md := range metadata {
|
||||||
if err := md.Resolve(e); err != nil {
|
if err := md.Resolve(e); err != nil {
|
||||||
log.Debugf("failed to resolve event metadata: %v", md)
|
log.Debugf("failed to resolve event metadata: %v", md)
|
||||||
|
@ -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 {
|
if he == nil {
|
||||||
return nil, nil, errors.Errorf("HookEvent should not be nil")
|
return nil, nil, errors.Errorf("HookEvent should not be nil")
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ type fakeVerifier struct {
|
|||||||
secret string
|
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 {
|
if secret != fv.secret {
|
||||||
return nil, verifyError(errors.New("mismatch"))
|
return nil, verifyError(errors.New("mismatch"))
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ func (nah *NoneAuthHandler) Mode() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Authorize implements @Handler.Authorize
|
// 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 {
|
if req == nil {
|
||||||
return errors.New("nil request cannot be authorized")
|
return errors.New("nil request cannot be authorized")
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ type Evaluator struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HasPermission always return true for the system administrator
|
// 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)
|
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
|
// scanner-pull is for scanner to bypass the policy checking so admin user should not have this permission
|
||||||
return action != rbac.ActionScannerPull
|
return action != rbac.ActionScannerPull
|
||||||
|
@ -88,18 +88,18 @@ func (a *adapter) LoadPolicy(model model.Model) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *adapter) SavePolicy(model model.Model) error {
|
func (a *adapter) SavePolicy(_ model.Model) error {
|
||||||
return errNotImplemented
|
return errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *adapter) AddPolicy(sec string, ptype string, rule []string) error {
|
func (a *adapter) AddPolicy(_ string, _ string, _ []string) error {
|
||||||
return errNotImplemented
|
return errNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *adapter) RemovePolicy(sec string, ptype string, rule []string) error {
|
func (a *adapter) RemovePolicy(_ string, _ string, _ []string) error {
|
||||||
return errNotImplemented
|
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
|
return errNotImplemented
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ type Evaluator struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HasPermission returns true when the rbac user has action permission for the resource
|
// 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.once.Do(func() {
|
||||||
e.enforcer = makeEnforcer(e.rbacUser)
|
e.enforcer = makeEnforcer(e.rbacUser)
|
||||||
})
|
})
|
||||||
|
@ -148,7 +148,7 @@ func (p *Project) AutoScan() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FilterByPublic returns orm.QuerySeter with public filter
|
// 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'`
|
subQuery := `SELECT project_id FROM project_metadata WHERE name = 'public' AND value = '%s'`
|
||||||
if isTrue(value) {
|
if isTrue(value) {
|
||||||
subQuery = fmt.Sprintf(subQuery, "true")
|
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
|
// 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)
|
username, ok := value.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return qs
|
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
|
// 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)
|
query, ok := value.(*MemberQuery)
|
||||||
if !ok {
|
if !ok {
|
||||||
return qs
|
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
|
// 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)
|
query, ok := value.(*NamesQuery)
|
||||||
if !ok {
|
if !ok {
|
||||||
return qs
|
return qs
|
||||||
|
@ -50,7 +50,7 @@ func (resource ResourceName) FormatValue(value int64) string {
|
|||||||
type ResourceList map[ResourceName]int64
|
type ResourceList map[ResourceName]int64
|
||||||
|
|
||||||
// Validate validates this resource list
|
// Validate validates this resource list
|
||||||
func (resources ResourceList) Validate(formats strfmt.Registry) error {
|
func (resources ResourceList) Validate(_ strfmt.Registry) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ func (a *adapter) FetchArtifacts(filters []*model.Filter) (resources []*model.Re
|
|||||||
return
|
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 reposReq = cr.CreateGetRepoListByNamespaceRequest()
|
||||||
var reposResp = cr.CreateGetRepoListByNamespaceResponse()
|
var reposResp = cr.CreateGetRepoListByNamespaceResponse()
|
||||||
reposReq.SetDomain(a.domain)
|
reposReq.SetDomain(a.domain)
|
||||||
|
@ -207,6 +207,6 @@ func (a *adapter) listArtifacts(repository string, filters []*model.Filter) ([]*
|
|||||||
return filter.DoFilterArtifacts(artifacts, filters)
|
return filter.DoFilterArtifacts(artifacts, filters)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *adapter) DeleteManifest(repository, reference string) error {
|
func (a *adapter) DeleteManifest(_, _ string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ func (a *adapter) ListNamespaces(query *model.NamespaceQuery) ([]*model.Namespac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ConvertResourceMetadata convert resource metadata for Huawei SWR
|
// 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{
|
metadata := &model.ResourceMetadata{
|
||||||
Repository: resourceMetadata.Repository,
|
Repository: resourceMetadata.Repository,
|
||||||
Vtags: resourceMetadata.Vtags,
|
Vtags: resourceMetadata.Vtags,
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// FetchArtifacts gets resources from Huawei SWR
|
// 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{}
|
resources := []*model.Resource{}
|
||||||
|
|
||||||
urls := fmt.Sprintf("%s/dockyard/v2/repositories?filter=center::self", a.registry.URL)
|
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")
|
contentType := resp.Header.Get("Content-Type")
|
||||||
contentLen := resp.Header.Get("Content-Length")
|
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
|
// DeleteManifest delete the manifest of Huawei SWR
|
||||||
|
@ -342,7 +342,7 @@ func (a *adapter) preparePushBlob(repository string) (string, error) {
|
|||||||
return "", err
|
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)
|
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)
|
req, err := http.NewRequest(http.MethodPut, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -240,11 +240,11 @@ func (a *Adapter) PingSimple() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeleteTag isn't supported for docker registry
|
// 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")
|
return errors.New("the tag deletion isn't supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanBeMount isn't supported for docker registry
|
// 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
|
return false, "", nil
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ func (m *manager) Delete(ctx context.Context, id int64) error {
|
|||||||
return m.dao.Delete(ctx, id)
|
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)
|
factory, err := adapter.GetFactory(registry.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -152,11 +152,11 @@ func (m *manager) CreateAdapter(ctx context.Context, registry *model.Registry) (
|
|||||||
return factory.Create(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
|
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
|
return adapter.ListRegisteredAdapterInfos(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func NewAuthorizer() lib.Authorizer {
|
|||||||
|
|
||||||
type authorizer struct{}
|
type authorizer struct{}
|
||||||
|
|
||||||
func (a *authorizer) Modify(req *http.Request) error {
|
func (a *authorizer) Modify(_ *http.Request) error {
|
||||||
// do nothing
|
// do nothing
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -281,8 +281,8 @@ func (c *client) ManifestExist(repository, reference string) (bool, *distributio
|
|||||||
dig := resp.Header.Get("Docker-Content-Digest")
|
dig := resp.Header.Get("Docker-Content-Digest")
|
||||||
contentType := resp.Header.Get("Content-Type")
|
contentType := resp.Header.Get("Content-Type")
|
||||||
contentLen := resp.Header.Get("Content-Length")
|
contentLen := resp.Header.Get("Content-Length")
|
||||||
len, _ := strconv.Atoi(contentLen)
|
lenth, _ := strconv.Atoi(contentLen)
|
||||||
return true, &distribution.Descriptor{Digest: digest.Digest(dig), MediaType: contentType, Size: int64(len)}, nil
|
return true, &distribution.Descriptor{Digest: digest.Digest(dig), MediaType: contentType, Size: int64(lenth)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) PullManifest(repository, reference string, acceptedMediaTypes ...string) (
|
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.
|
// 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)
|
req, err := http.NewRequest(http.MethodGet, buildBlobURL(c.url, repository, digest), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
|
@ -42,7 +42,7 @@ type RepoRecord struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FilterByBlobDigest filters the repositories by the blob digest
|
// 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)
|
digest, ok := value.(string)
|
||||||
if !ok || len(digest) == 0 {
|
if !ok || len(digest) == 0 {
|
||||||
return qs
|
return qs
|
||||||
|
@ -278,7 +278,7 @@ func getProjects(ctx context.Context, projectMgr project.Manager) ([]*selector.C
|
|||||||
return candidates, nil
|
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
|
var candidates []*selector.Candidate
|
||||||
/*
|
/*
|
||||||
pro, err := projectMgr.Get(projectID)
|
pro, err := projectMgr.Get(projectID)
|
||||||
|
@ -28,7 +28,7 @@ const (
|
|||||||
type evaluator struct{}
|
type evaluator struct{}
|
||||||
|
|
||||||
// Process for the "nothing" Evaluator simply returns the input with no error
|
// 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
|
return processed, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ func (dfp *DefaultFilterProcessor) ProcessTagFilter(ctx context.Context, filter
|
|||||||
return filteredArts, nil
|
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
|
// return all artifacts if no label need to be filtered
|
||||||
if len(labelIDs) == 0 {
|
if len(labelIDs) == 0 {
|
||||||
return arts, nil
|
return arts, nil
|
||||||
|
@ -98,7 +98,7 @@ func (c *nativeToRelationalSchemaConverter) FromRelationalSchema(ctx context.Con
|
|||||||
return rp, nil
|
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
|
var vulnReport vuln.Report
|
||||||
err := json.Unmarshal([]byte(rawReportData), &vulnReport)
|
err := json.Unmarshal([]byte(rawReportData), &vulnReport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -198,7 +198,7 @@ func (c *nativeToRelationalSchemaConverter) toSchema(ctx context.Context, report
|
|||||||
return nil
|
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 {
|
if len(reportSummary) == 0 {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user