@@ -152,29 +152,6 @@ func (p *ResourceProcessor) createGroupsWithOutput(username string, groups []typ
152152 return groupOutputs , nil
153153}
154154
155- // createGroups 创建多个组及其项目
156- func (p * ResourceProcessor ) createGroups (username string , groups []types.GroupSpec ) error {
157- for j , groupSpec := range groups {
158- log .Printf (" ------------------------------------------\n " )
159- log .Printf (" 处理组 [%d/%d]: %s\n " , j + 1 , len (groups ), groupSpec .Name )
160-
161- groupID , groupPath , err := p .ensureGroup (username , groupSpec )
162- if err != nil {
163- log .Printf (" ⚠ 创建组失败 %s: %v\n " , groupSpec .Path , err )
164- continue
165- }
166-
167- // 创建组下的项目
168- if len (groupSpec .Projects ) > 0 {
169- log .Printf (" 创建 %d 个项目...\n " , len (groupSpec .Projects ))
170- if err := p .createProjects (username , groupID , groupPath , groupSpec .Projects ); err != nil {
171- log .Printf (" ⚠ 创建项目失败: %v\n " , err )
172- }
173- }
174- }
175- return nil
176- }
177-
178155// ensureGroup 确保组存在,如果不存在则创建
179156func (p * ResourceProcessor ) ensureGroup (username string , groupSpec types.GroupSpec ) (int , string , error ) {
180157 existingGroup , _ := p .Client .GetGroup (groupSpec .Path )
@@ -245,36 +222,6 @@ func (p *ResourceProcessor) createProjectsWithOutput(username string, groupID in
245222 return projectOutputs , nil
246223}
247224
248- // createProjects 创建多个项目
249- func (p * ResourceProcessor ) createProjects (username string , groupID int , groupPath string , projects []types.ProjectSpec ) error {
250- for _ , projSpec := range projects {
251- fullPath := fmt .Sprintf ("%s/%s" , groupPath , projSpec .Path )
252- existingProj , _ := p .Client .GetProject (fullPath )
253-
254- if existingProj != nil {
255- log .Printf (" ⚠ 项目 '%s' 已存在 (ID: %d)\n " , projSpec .Name , existingProj .ID )
256- continue
257- }
258-
259- log .Printf (" 创建项目: %s\n " , projSpec .Name )
260- project , err := p .Client .CreateProject (
261- username ,
262- groupID ,
263- projSpec .Name ,
264- projSpec .Path ,
265- projSpec .Description ,
266- utils .GetVisibility (projSpec .Visibility ),
267- )
268- if err != nil {
269- log .Printf (" ⚠ 创建项目失败 %s: %v\n " , projSpec .Name , err )
270- continue
271- }
272-
273- log .Printf (" ✓ 项目创建成功 (ID: %d, Path: %s)\n " , project .ID , project .PathWithNamespace )
274- }
275- return nil
276- }
277-
278225// ========================================
279226// 用户清理流程
280227// ========================================
0 commit comments