[ Server ] [ Harbor ] - sync projects - 5
This commit is contained in:
@@ -255,13 +255,14 @@ func (hOp *HarborOperator) SyncProjectExec(funcArgs []string) (bool, []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 创建复制策略
|
// 创建复制策略
|
||||||
newPolicy := &model.ReplicationPolicy{
|
octopusReplicationPolicy := &model.ReplicationPolicy{
|
||||||
CopyByChunk: nil,
|
CopyByChunk: nil,
|
||||||
Deletion: false,
|
Deletion: false,
|
||||||
Description: "",
|
Description: "",
|
||||||
DestNamespace: "", // 可以指定目标 Harbor 中的特定项目,如果为空,则使用源项目名称
|
DestNamespace: "", // 可以指定目标 Harbor 中的特定项目,如果为空,则使用源项目名称
|
||||||
DestNamespaceReplaceCount: nil,
|
DestNamespaceReplaceCount: nil,
|
||||||
SrcRegistry: octopusSourceRegistry,
|
SrcRegistry: octopusSourceRegistry,
|
||||||
|
DestRegistry: nil,
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
Filters: []*model.ReplicationFilter{
|
Filters: []*model.ReplicationFilter{
|
||||||
{
|
{
|
||||||
@@ -287,7 +288,23 @@ func (hOp *HarborOperator) SyncProjectExec(funcArgs []string) (bool, []string) {
|
|||||||
|
|
||||||
// 在源 Harbor 中创建复制策略
|
// 在源 Harbor 中创建复制策略
|
||||||
log.Info("[Harbor Sync Project ] - Start To Sync Project !")
|
log.Info("[Harbor Sync Project ] - Start To Sync Project !")
|
||||||
err = targetClient.NewReplicationPolicy(ctx, newPolicy.DestRegistry, newPolicy.SrcRegistry, newPolicy.Deletion, newPolicy.Override, newPolicy.Enabled, newPolicy.Filters, newPolicy.Trigger, newPolicy.DestNamespace, newPolicy.Name, newPolicy.Name)
|
|
||||||
|
existReplicationPolicy, err := targetClient.GetReplicationPolicyByName(ctx, octopusReplicationPolicy.Name)
|
||||||
|
if err != nil {
|
||||||
|
return false, []string{
|
||||||
|
"[Harbor Sync Project ] - get exists replication policy failed !",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if existReplicationPolicy != nil {
|
||||||
|
err := targetClient.DeleteReplicationPolicyByID(ctx, existReplicationPolicy.ID)
|
||||||
|
if err != nil {
|
||||||
|
return false, []string{
|
||||||
|
"[Harbor Sync Project ] - delete exists replication policy failed !",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = targetClient.NewReplicationPolicy(ctx, octopusReplicationPolicy.DestRegistry, octopusReplicationPolicy.SrcRegistry, octopusReplicationPolicy.Deletion, octopusReplicationPolicy.Override, octopusReplicationPolicy.Enabled, octopusReplicationPolicy.Filters, octopusReplicationPolicy.Trigger, octopusReplicationPolicy.DestNamespace, octopusReplicationPolicy.Name, octopusReplicationPolicy.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
syncErrorMessage := fmt.Sprintf("[Harbor Sync Project ] - Sync Project Failed !: %s\n", err.Error())
|
syncErrorMessage := fmt.Sprintf("[Harbor Sync Project ] - Sync Project Failed !: %s\n", err.Error())
|
||||||
log.Error(syncErrorMessage)
|
log.Error(syncErrorMessage)
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ public class TestBaseFuncScheduler {
|
|||||||
|
|
||||||
ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
|
ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
|
||||||
// exsi server
|
// exsi server
|
||||||
// serverQueryEntity.setServerName("Chengdu-amd64-99");
|
serverQueryEntity.setServerName("Chengdu-amd64-99");
|
||||||
|
|
||||||
// lappro
|
// lappro
|
||||||
serverQueryEntity.setServerName("Chengdu-amd64-65");
|
// serverQueryEntity.setServerName("Chengdu-amd64-65");
|
||||||
|
|
||||||
ServerInfoPO serverInfoPO = serverService
|
ServerInfoPO serverInfoPO = serverService
|
||||||
.serverGetByPage(serverQueryEntity)
|
.serverGetByPage(serverQueryEntity)
|
||||||
|
|||||||
Reference in New Issue
Block a user