From a31d9318b472f5d4b6c217875191ee6f4a5828a7 Mon Sep 17 00:00:00 2001 From: zeaslity Date: Thu, 16 Nov 2023 10:52:49 +0800 Subject: [PATCH] [ Server ] [ Harbor ] - sync projects - 7 --- agent-go/executor/HarborExecutor.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) 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 !", + } } } }