diff --git a/src/controller/artifact/const.go b/src/controller/artifact/const.go deleted file mode 100644 index e5a2a1130..000000000 --- a/src/controller/artifact/const.go +++ /dev/null @@ -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" -) diff --git a/src/controller/scan/checker.go b/src/controller/scan/checker.go index f6755a933..856e77431 100644 --- a/src/controller/scan/checker.go +++ b/src/controller/scan/checker.go @@ -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) diff --git a/src/server/middleware/contenttrust/contenttrust_test.go b/src/server/middleware/contenttrust/contenttrust_test.go index 2cc9ddd07..9b79f84b0 100644 --- a/src/server/middleware/contenttrust/contenttrust_test.go +++ b/src/server/middleware/contenttrust/contenttrust_test.go @@ -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" diff --git a/src/server/middleware/vulnerable/vulnerable.go b/src/server/middleware/vulnerable/vulnerable.go index 6fe043cfb..5162bddd6 100644 --- a/src/server/middleware/vulnerable/vulnerable.go +++ b/src/server/middleware/vulnerable/vulnerable.go @@ -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, "+ diff --git a/src/server/middleware/vulnerable/vulnerable_test.go b/src/server/middleware/vulnerable/vulnerable_test.go index 221a83ef1..551b84edf 100644 --- a/src/server/middleware/vulnerable/vulnerable_test.go +++ b/src/server/middleware/vulnerable/vulnerable_test.go @@ -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"