From a9978368b0fd7a408820d2e40405ec60b2a67ded Mon Sep 17 00:00:00 2001 From: bupd Date: Sun, 22 Dec 2024 22:44:02 +0530 Subject: [PATCH] update mocks & lint Signed-off-by: bupd --- src/controller/replication/execution.go | 3 +-- .../job/impl/replication/replication.go | 1 + src/server/v2.0/handler/replication.go | 2 +- src/testing/pkg/task/execution_manager.go | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/controller/replication/execution.go b/src/controller/replication/execution.go index bee22caee6d..8f6d9ae509d 100644 --- a/src/controller/replication/execution.go +++ b/src/controller/replication/execution.go @@ -21,9 +21,9 @@ import ( "time" "github.com/gocraft/work" - "github.com/goharbor/harbor/src/controller/jobmonitor" "github.com/goharbor/harbor/src/controller/event/operator" + "github.com/goharbor/harbor/src/controller/jobmonitor" "github.com/goharbor/harbor/src/controller/replication/flow" replicationmodel "github.com/goharbor/harbor/src/controller/replication/model" "github.com/goharbor/harbor/src/jobservice/job" @@ -120,7 +120,6 @@ func (c *controller) Start(ctx context.Context, policy *replicationmodel.Policy, } if policy.SkipIfRunning { - log.Infof("kumar eh policy with ID %v skipped.", policy.ID) monitorClient, err := jobmonitor.JobServiceMonitorClient() if err != nil { return 0, errors.New(nil).WithCode(errors.PreconditionCode).WithMessagef("unable to get job monitor's client: %v", err) diff --git a/src/jobservice/job/impl/replication/replication.go b/src/jobservice/job/impl/replication/replication.go index dc0de101284..453fa5e032b 100644 --- a/src/jobservice/job/impl/replication/replication.go +++ b/src/jobservice/job/impl/replication/replication.go @@ -17,6 +17,7 @@ package replication import ( "encoding/json" "fmt" + "github.com/goharbor/harbor/src/controller/replication/transfer" // import chart transfer _ "github.com/goharbor/harbor/src/controller/replication/transfer/image" diff --git a/src/server/v2.0/handler/replication.go b/src/server/v2.0/handler/replication.go index af4366e48e6..452e73d8171 100644 --- a/src/server/v2.0/handler/replication.go +++ b/src/server/v2.0/handler/replication.go @@ -454,7 +454,7 @@ func convertReplicationPolicy(policy *repctlmodel.Policy) *models.ReplicationPol Speed: &policy.Speed, UpdateTime: strfmt.DateTime(policy.UpdateTime), CopyByChunk: &policy.CopyByChunk, - SkipIfRunning: &policy.SkipIfRunning, + SkipIfRunning: &policy.SkipIfRunning, } if policy.SrcRegistry != nil { p.SrcRegistry = convertRegistry(policy.SrcRegistry) diff --git a/src/testing/pkg/task/execution_manager.go b/src/testing/pkg/task/execution_manager.go index bd2b7988831..058dc14ee10 100644 --- a/src/testing/pkg/task/execution_manager.go +++ b/src/testing/pkg/task/execution_manager.go @@ -213,6 +213,24 @@ func (_m *ExecutionManager) MarkError(ctx context.Context, id int64, message str return r0 } +// MarkSkipped provides a mock function with given fields: ctx, id, message +func (_m *ExecutionManager) MarkSkipped(ctx context.Context, id int64, message string) error { + ret := _m.Called(ctx, id, message) + + if len(ret) == 0 { + panic("no return value specified for MarkSkipped") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok { + r0 = rf(ctx, id, message) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // Stop provides a mock function with given fields: ctx, id func (_m *ExecutionManager) Stop(ctx context.Context, id int64) error { ret := _m.Called(ctx, id)