[ Server ] [ Harbor ] - sync projects - 7

This commit is contained in:
zeaslity
2023-11-16 10:52:49 +08:00
parent 1132d37adf
commit a31d9318b4

View File

@@ -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 !",
}
}
}
}