This commit is contained in:
zeaslity
2023-11-14 16:01:16 +08:00
parent 7312a9830b
commit f6f1c174f5
4 changed files with 29 additions and 14 deletions

View File

@@ -63,7 +63,6 @@ func (hOp *HarborOperator) Exec(baseFuncName string, funcArgs ...string) (bool,
func (hOp *HarborOperator) CreateProjectExec(funcArgs []string) (bool, []string) {
client := hOp.TargetHarborClient
if hOp.TargetHarborClient == nil {
ok, createClient := hOp.CheckAndBuildHarborClient(funcArgs)
if !ok {
@@ -73,18 +72,18 @@ func (hOp *HarborOperator) CreateProjectExec(funcArgs []string) (bool, []string)
}
hOp.TargetHarborClient = createClient
}
client := hOp.TargetHarborClient
// create project
// 定义你想要创建的仓库(项目)的详细信息
log.Debug("[Harbor Create Project] - create project !")
needToCreateProjectNameList := []string{"cmii", "rancher"}
var err error
// 使用客户端创建项目
ctx := context.Background()
for _, projectName := range needToCreateProjectNameList {
log.DebugF("start to create => %s", projectName)
log.DebugF("start to create proect => %s", projectName)
projectReq := &model.ProjectReq{
ProjectName: projectName, // 仓库名称
Metadata: &model.ProjectMetadata{
@@ -93,16 +92,16 @@ func (hOp *HarborOperator) CreateProjectExec(funcArgs []string) (bool, []string)
}
exists, _ := client.ProjectExists(ctx, projectName)
if exists {
log.DebugF("[Harbor Create Project] - Project %s already exists ! continue ", projectName)
continue
if !exists {
err := client.NewProject(ctx, projectReq)
if err != nil {
errorLog := fmt.Sprintf("Error creating project %s: %s\n", projectName, err.Error())
return false, []string{errorLog}
}
}
err = client.NewProject(ctx, projectReq)
if err != nil {
errorLog := fmt.Sprintf("Error creating project %s: %s\n", projectName, err.Error())
return false, []string{errorLog}
}
log.DebugF("[Harbor Create Project] - Project %s already exists ! continue ", projectName)
}
@@ -141,7 +140,6 @@ func (hOp *HarborOperator) CheckAndBuildHarborClient(funcArgs []string) (bool, *
func (hOp *HarborOperator) ListProjectExec(funcArgs []string) (bool, []string) {
client := hOp.TargetHarborClient
if hOp.TargetHarborClient == nil {
ok, createClient := hOp.CheckAndBuildHarborClient(funcArgs)
if !ok {
@@ -151,10 +149,11 @@ func (hOp *HarborOperator) ListProjectExec(funcArgs []string) (bool, []string) {
}
hOp.TargetHarborClient = createClient
}
client := hOp.TargetHarborClient
// 使用客户端列出所有项目
ctx := context.Background()
projects, err := client.ListProjects(ctx, "*")
projects, err := client.ListProjects(ctx, "")
if err != nil {
fmt.Printf("Error listing projects: %v\n", err)
os.Exit(1)

View File

@@ -31,4 +31,5 @@ func main() {
// 永远等待 runtime的队列消息
<-businessForeverChan
}

View File

@@ -1,4 +1,17 @@
使用GO语言重构Octopus-Agent项目
---
# VS CODE RUN
go mod tidy
go mod download
go mod vender
#### in folder agent-go
go build && ./agent-go -version=shanghai -agentServerInfoConf=/home/wdd/IdeaProjects/ProjectOctopus/agent-go/server-env.yaml
---
## Message
@@ -38,3 +51,5 @@
4. 配置环境变量
5. 安装GONB
6. 启动jupyter lab即可

View File

@@ -1,6 +1,6 @@
serverName: "Chengdu-amd64-65"
serverIpPbV4: "183.220.149.17"
serverIpInV4: "10.250.0.65 "
serverIpInV4: "10.250.0.100 "
serverIpPbV6: ""
serverIpInV6: ""
location: "Chengdu Sichuan CN"