fix go imports order issues

Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
Steven Zou 2019-10-22 18:47:18 +08:00
parent 370a364c29
commit 962bafb7ce
9 changed files with 31 additions and 19 deletions

View File

@ -24,11 +24,6 @@ import (
"strings"
"time"
"github.com/goharbor/harbor/src/jobservice/logger"
"github.com/goharbor/harbor/src/pkg/scan/api/scan"
v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1"
"github.com/docker/distribution/manifest/schema1"
"github.com/docker/distribution/manifest/schema2"
"github.com/goharbor/harbor/src/common"
@ -44,8 +39,11 @@ import (
"github.com/goharbor/harbor/src/core/config"
notifierEvt "github.com/goharbor/harbor/src/core/notifier/event"
coreutils "github.com/goharbor/harbor/src/core/utils"
"github.com/goharbor/harbor/src/jobservice/logger"
"github.com/goharbor/harbor/src/pkg/art"
"github.com/goharbor/harbor/src/pkg/immutabletag/match/rule"
"github.com/goharbor/harbor/src/pkg/scan/api/scan"
v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1"
"github.com/goharbor/harbor/src/replication"
"github.com/goharbor/harbor/src/replication/event"
"github.com/goharbor/harbor/src/replication/model"

View File

@ -23,8 +23,6 @@ import (
"syscall"
"time"
"github.com/goharbor/harbor/src/pkg/scan/event"
"github.com/astaxie/beego"
_ "github.com/astaxie/beego/session/redis"
"github.com/goharbor/harbor/src/common/dao"
@ -34,16 +32,14 @@ import (
"github.com/goharbor/harbor/src/common/utils"
"github.com/goharbor/harbor/src/common/utils/log"
"github.com/goharbor/harbor/src/core/api"
quota "github.com/goharbor/harbor/src/core/api/quota"
_ "github.com/goharbor/harbor/src/core/api/quota/chart"
_ "github.com/goharbor/harbor/src/core/api/quota/registry"
_ "github.com/goharbor/harbor/src/core/auth/authproxy"
_ "github.com/goharbor/harbor/src/core/auth/db"
_ "github.com/goharbor/harbor/src/core/auth/ldap"
_ "github.com/goharbor/harbor/src/core/auth/oidc"
_ "github.com/goharbor/harbor/src/core/auth/uaa"
quota "github.com/goharbor/harbor/src/core/api/quota"
_ "github.com/goharbor/harbor/src/core/api/quota/chart"
_ "github.com/goharbor/harbor/src/core/api/quota/registry"
"github.com/goharbor/harbor/src/core/config"
"github.com/goharbor/harbor/src/core/filter"
"github.com/goharbor/harbor/src/core/middlewares"
@ -52,6 +48,7 @@ import (
"github.com/goharbor/harbor/src/pkg/notification"
"github.com/goharbor/harbor/src/pkg/scan"
"github.com/goharbor/harbor/src/pkg/scan/dao/scanner"
"github.com/goharbor/harbor/src/pkg/scan/event"
"github.com/goharbor/harbor/src/pkg/scheduler"
"github.com/goharbor/harbor/src/pkg/types"
"github.com/goharbor/harbor/src/replication"

View File

@ -57,12 +57,19 @@ func (suite *ScanImagePreprocessHandlerSuite) SetupSuite() {
Artifact: a,
}
reports := []*scan.Report{
{
Report: "{}",
},
}
suite.c = sc.DefaultController
mc := &MockScanAPIController{}
var options []report.Option
s := make(map[string]interface{})
mc.On("GetSummary", a, []string{v1.MimeTypeNativeReport}, options).Return(s, nil)
mc.On("GetReport", a, []string{v1.MimeTypeNativeReport}).Return(reports, nil)
sc.DefaultController = mc
@ -140,6 +147,16 @@ func (msc *MockScanAPIController) HandleJobHooks(trackID string, change *job.Sta
return args.Error(0)
}
func (msc *MockScanAPIController) DeleteReports(digests ...string) error {
pl := make([]interface{}, 0)
for _, d := range digests {
pl = append(pl, d)
}
args := msc.Called(pl...)
return args.Error(0)
}
// MockHTTPHandler ...
type MockHTTPHandler struct{}

View File

@ -18,8 +18,6 @@ import (
"encoding/json"
"time"
"github.com/goharbor/harbor/src/pkg/scan/api/scan"
"github.com/goharbor/harbor/src/common/job"
"github.com/goharbor/harbor/src/common/models"
"github.com/goharbor/harbor/src/common/utils/log"
@ -29,6 +27,7 @@ import (
"github.com/goharbor/harbor/src/pkg/notification"
"github.com/goharbor/harbor/src/pkg/retention"
sc "github.com/goharbor/harbor/src/pkg/scan"
"github.com/goharbor/harbor/src/pkg/scan/api/scan"
"github.com/goharbor/harbor/src/replication"
"github.com/goharbor/harbor/src/replication/operation/hook"
"github.com/goharbor/harbor/src/replication/policy/scheduler"

View File

@ -27,7 +27,7 @@ type basicController struct {
m Manager
}
// NewController
// NewController ...
func NewController() Controller {
return &basicController{
m: NewManager(),

View File

@ -19,6 +19,7 @@ import (
"github.com/goharbor/harbor/src/pkg/q"
)
// Manager is designed to manage the artifact
type Manager interface {
// List the artifacts with queries
//

View File

@ -19,11 +19,10 @@ import (
"fmt"
"time"
"github.com/goharbor/harbor/src/common/utils/log"
cj "github.com/goharbor/harbor/src/common/job"
jm "github.com/goharbor/harbor/src/common/job/models"
"github.com/goharbor/harbor/src/common/rbac"
"github.com/goharbor/harbor/src/common/utils/log"
"github.com/goharbor/harbor/src/core/config"
"github.com/goharbor/harbor/src/jobservice/job"
"github.com/goharbor/harbor/src/jobservice/logger"
@ -306,7 +305,7 @@ func (bc *basicController) HandleJobHooks(trackID string, change *job.StatusChan
// Should not block the main flow, just logged
log.Error(errors.Wrap(err, "scan controller: handle job hook"))
} else {
log.Debugf("Robot account with id %d for the scan %s is removed", rid, trackID)
log.Debugf("Robot account with id %d for the scan %s is removed", int64(rid), trackID)
}
}
}

View File

@ -199,6 +199,7 @@ func (suite *ControllerTestSuite) SetupSuite() {
params[sca.JobParamRegistration] = regJSON
params[sca.JobParameterRequest] = rJSON
params[sca.JobParameterMimes] = []string{v1.MimeTypeNativeReport}
params[sca.JobParameterRobotID] = int64(1)
j := &jm.JobData{
Name: job.ImageScanJob,

View File

@ -23,7 +23,7 @@ import (
// Init the events for scan
func Init() {
log.Debugf("Subscribe topic %s for cascade deletion of scan reports")
log.Debugf("Subscribe topic %s for cascade deletion of scan reports", model.DeleteImageTopic)
err := notifier.Subscribe(model.DeleteImageTopic, NewOnDelImageHandler())
log.Error(errors.Wrap(err, "register on delete image handler: init: scan"))