mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 01:27:49 +01:00
Remove the duplicated const definition
Remove the duplicated const definition for artifact type Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
parent
49c9e4f696
commit
7553845b4d
@ -1,29 +0,0 @@
|
||||
// Copyright Project Harbor Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package artifact
|
||||
|
||||
const (
|
||||
// ChartType chart type of artifact
|
||||
ChartType = "CHART"
|
||||
|
||||
// CNABType cnab type of artifact
|
||||
CNABType = "CNAB"
|
||||
|
||||
// ImageType image type of artifact
|
||||
ImageType = "IMAGE"
|
||||
|
||||
// UnknownType unknown type of artifact
|
||||
UnknownType = "UNKNOWN"
|
||||
)
|
@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/goharbor/harbor/src/controller/artifact"
|
||||
"github.com/goharbor/harbor/src/controller/artifact/processor/image"
|
||||
"github.com/goharbor/harbor/src/controller/scanner"
|
||||
models "github.com/goharbor/harbor/src/pkg/scan/dao/scanner"
|
||||
)
|
||||
@ -88,7 +89,7 @@ func (c *checker) IsScannable(ctx context.Context, art *artifact.Artifact) (bool
|
||||
func hasCapability(r *models.Registration, a *artifact.Artifact) bool {
|
||||
// use whitelist here because currently only docker image is supported by the scanner
|
||||
// https://github.com/goharbor/pluggable-scanner-spec/issues/2
|
||||
whitelist := []string{artifact.ImageType}
|
||||
whitelist := []string{image.ArtifactTypeImage}
|
||||
for _, t := range whitelist {
|
||||
if a.Type == t {
|
||||
return r.HasCapability(a.ManifestMediaType)
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/security"
|
||||
"github.com/goharbor/harbor/src/controller/artifact"
|
||||
"github.com/goharbor/harbor/src/controller/artifact/processor/image"
|
||||
"github.com/goharbor/harbor/src/controller/project"
|
||||
"github.com/goharbor/harbor/src/lib"
|
||||
securitytesting "github.com/goharbor/harbor/src/testing/common/security"
|
||||
@ -59,7 +60,7 @@ func (suite *MiddlewareTestSuite) SetupTest() {
|
||||
|
||||
suite.isArtifactSigned = isArtifactSigned
|
||||
suite.artifact = &artifact.Artifact{}
|
||||
suite.artifact.Type = artifact.ImageType
|
||||
suite.artifact.Type = image.ArtifactTypeImage
|
||||
suite.artifact.ProjectID = 1
|
||||
suite.artifact.RepositoryName = "library/photon"
|
||||
suite.artifact.Digest = "digest"
|
||||
|
@ -18,7 +18,8 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/goharbor/harbor/src/controller/artifact"
|
||||
"github.com/goharbor/harbor/src/controller/artifact/processor/cnab"
|
||||
"github.com/goharbor/harbor/src/controller/artifact/processor/image"
|
||||
"github.com/goharbor/harbor/src/controller/project"
|
||||
"github.com/goharbor/harbor/src/controller/scan"
|
||||
"github.com/goharbor/harbor/src/lib"
|
||||
@ -114,7 +115,7 @@ func Middleware() func(http.Handler) http.Handler {
|
||||
|
||||
if art.IsImageIndex() {
|
||||
// artifact is image index, skip the checking when it is in the whitelist
|
||||
skippingWhitelist := []string{artifact.ImageType, artifact.CNABType}
|
||||
skippingWhitelist := []string{image.ArtifactTypeImage, cnab.ArtifactTypeCNAB}
|
||||
for _, t := range skippingWhitelist {
|
||||
if art.Type == t {
|
||||
logger.Debugf("artifact %s@%s is image index and its type is %s in skipping whitelist, "+
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/security"
|
||||
"github.com/goharbor/harbor/src/controller/artifact"
|
||||
"github.com/goharbor/harbor/src/controller/artifact/processor/image"
|
||||
"github.com/goharbor/harbor/src/controller/project"
|
||||
"github.com/goharbor/harbor/src/controller/scan"
|
||||
"github.com/goharbor/harbor/src/lib"
|
||||
@ -79,7 +80,7 @@ func (suite *MiddlewareTestSuite) SetupTest() {
|
||||
}
|
||||
|
||||
suite.artifact = &artifact.Artifact{}
|
||||
suite.artifact.Type = artifact.ImageType
|
||||
suite.artifact.Type = image.ArtifactTypeImage
|
||||
suite.artifact.ProjectID = 1
|
||||
suite.artifact.RepositoryName = "library/photon"
|
||||
suite.artifact.Digest = "digest"
|
||||
|
Loading…
Reference in New Issue
Block a user