diff --git a/agent-go/executor/HarborExecutor.go b/agent-go/executor/HarborExecutor.go index f979eb2..c14d783 100644 --- a/agent-go/executor/HarborExecutor.go +++ b/agent-go/executor/HarborExecutor.go @@ -289,18 +289,15 @@ func (hOp *HarborOperator) SyncProjectExec(funcArgs []string) (bool, []string) { // 在源 Harbor 中创建复制策略 log.Info("[Harbor Sync Project ] - Start To Sync Project !") - policies, err := targetClient.ListReplicationPolicies(ctx) - if err != nil { - return false, []string{ - "[Harbor Sync Project ] - get exists replication policy failed !", - } - } - for _, policy := range policies { - if policy.Name == octopusReplicationPolicy.Name { - err := targetClient.DeleteReplicationPolicyByID(ctx, policy.ID) - if err != nil { - return false, []string{ - "[Harbor Sync Project ] - delete exists replication policy failed !", + policies, _ := targetClient.ListReplicationPolicies(ctx) + if policies != nil { + for _, policy := range policies { + if policy.Name == octopusReplicationPolicy.Name { + err := targetClient.DeleteReplicationPolicyByID(ctx, policy.ID) + if err != nil { + return false, []string{ + "[Harbor Sync Project ] - delete exists replication policy failed !", + } } } }