@@ -18,7 +18,7 @@ import (
1818// createGroups creates GitLab groups in the destination GitLab instance based on the mirror mapping.
1919// It retrieves the source group path for each destination group and creates the group in the destination instance.
2020// The function also handles the copying of group avatars from the source to the destination instance.
21- func (destinationGitlab * GitlabInstance ) createGroups (sourceGitlab * GitlabInstance , mirrorMapping * utils.MirrorMapping ) error {
21+ func (destinationGitlab * GitlabInstance ) createGroups (sourceGitlab * GitlabInstance , mirrorMapping * utils.MirrorMapping ) [] error {
2222 zap .L ().Info ("Creating groups in GitLab Instance" , zap .String (ROLE , ROLE_DESTINATION ))
2323
2424 // Reverse the mirror mapping to get the source group path for each destination group
@@ -33,7 +33,7 @@ func (destinationGitlab *GitlabInstance) createGroups(sourceGitlab *GitlabInstan
3333 }
3434 }
3535 close (errorChan )
36- return utils .MergeErrors (errorChan , 2 )
36+ return utils .MergeErrors (errorChan )
3737}
3838
3939// createGroup creates a GitLab group in the destination GitLab instance based on the source group and mirror mapping.
@@ -115,7 +115,7 @@ func (g *GitlabInstance) createGroupFromSource(sourceGroup *gitlab.Group, copyOp
115115
116116// createProjects creates GitLab projects in the destination GitLab instance based on the mirror mapping.
117117// It retrieves the source project path for each destination project and creates the project in the destination instance.
118- func (destinationGitlab * GitlabInstance ) createProjects (sourceGitlab * GitlabInstance , mirrorMapping * utils.MirrorMapping ) error {
118+ func (destinationGitlab * GitlabInstance ) createProjects (sourceGitlab * GitlabInstance , mirrorMapping * utils.MirrorMapping ) [] error {
119119 zap .L ().Info ("Creating projects in GitLab Instance" , zap .String (ROLE , ROLE_DESTINATION ))
120120
121121 // Create a wait group to wait for all goroutines to finish
@@ -147,39 +147,36 @@ func (destinationGitlab *GitlabInstance) createProjects(sourceGitlab *GitlabInst
147147 wg .Wait ()
148148 close (errorChan )
149149
150- return utils .MergeErrors (errorChan , 2 )
150+ return utils .MergeErrors (errorChan )
151151}
152152
153153// createProject creates a GitLab project in the destination GitLab instance based on the source project and mirror mapping.
154154// It checks if the project already exists in the destination instance and creates it if not.
155155// The function also handles the copying of project avatars from the source to the destination instance.
156- func (destinationGitlab * GitlabInstance ) createProject (sourceProjectPath string , projectCreationOptions * utils.MirroringOptions , sourceGitlab * GitlabInstance ) (* gitlab.Project , error ) {
156+ func (destinationGitlab * GitlabInstance ) createProject (sourceProjectPath string , projectCreationOptions * utils.MirroringOptions , sourceGitlab * GitlabInstance ) (* gitlab.Project , [] error ) {
157157 destinationProjectPath := projectCreationOptions .DestinationPath
158158 // Check if the project already exists
159159 destinationProject := destinationGitlab .getProject (destinationProjectPath )
160160 var err error
161161 sourceProject := sourceGitlab .Projects [sourceProjectPath ]
162162 if sourceProject == nil {
163- return nil , fmt .Errorf ("project %s not found in source GitLab instance (internal error, please review script)" , sourceProjectPath )
163+ return nil , [] error { fmt .Errorf ("project %s not found in source GitLab instance (internal error, please review script)" , sourceProjectPath )}
164164 }
165165
166166 // Check if the project already exists in the destination GitLab instance
167167 // If it does not exist, create it
168168 if destinationProject == nil {
169169 destinationProject , err = destinationGitlab .createProjectFromSource (sourceProject , projectCreationOptions )
170170 if err != nil {
171- return nil , fmt .Errorf ("failed to create project %s in destination GitLab instance: %s" , destinationProjectPath , err )
171+ return nil , [] error { fmt .Errorf ("failed to create project %s in destination GitLab instance: %s" , destinationProjectPath , err )}
172172 }
173173 }
174174
175175 // If the project already exists, update it with the source project details
176- err = destinationGitlab .updateProjectFromSource (sourceGitlab , sourceProject , destinationProject , projectCreationOptions )
177- if err != nil {
178- return destinationProject , fmt .Errorf ("failed to update project %s in destination GitLab instance: %s" , destinationProjectPath , err )
179- }
176+ mergedError := destinationGitlab .updateProjectFromSource (sourceGitlab , sourceProject , destinationProject , projectCreationOptions )
180177
181178 zap .L ().Info ("Completed project mirroring" , zap .String (ROLE_SOURCE , sourceProjectPath ), zap .String (ROLE_DESTINATION , destinationProjectPath ))
182- return destinationProject , nil
179+ return destinationProject , mergedError
183180}
184181
185182// createProjectFromSource creates a GitLab project in the destination GitLab instance based on the source project.
@@ -228,12 +225,12 @@ func (g *GitlabInstance) createProjectFromSource(sourceProject *gitlab.Project,
228225// It fetches existing releases from the destination project and creates new releases for those that do not exist.
229226// The function handles the API calls concurrently using goroutines and a wait group.
230227// It returns an error if any of the API calls fail.
231- func (destinationGitlab * GitlabInstance ) mirrorReleases (sourceGitlab * GitlabInstance , sourceProject * gitlab.Project , destinationProject * gitlab.Project ) error {
228+ func (destinationGitlab * GitlabInstance ) mirrorReleases (sourceGitlab * GitlabInstance , sourceProject * gitlab.Project , destinationProject * gitlab.Project ) [] error {
232229 zap .L ().Debug ("Starting releases mirroring" , zap .String (ROLE_SOURCE , sourceProject .HTTPURLToRepo ), zap .String (ROLE_DESTINATION , destinationProject .HTTPURLToRepo ))
233230 // Fetch existing releases from the destination project
234231 existingReleases , _ , err := destinationGitlab .Gitlab .Releases .ListReleases (destinationProject .ID , & gitlab.ListReleasesOptions {})
235232 if err != nil {
236- return fmt .Errorf ("failed to fetch existing releases for destination project %s: %s" , destinationProject .HTTPURLToRepo , err )
233+ return [] error { fmt .Errorf ("failed to fetch existing releases for destination project %s: %s" , destinationProject .HTTPURLToRepo , err )}
237234 }
238235
239236 // Create a map of existing release tags for quick lookup
@@ -247,7 +244,7 @@ func (destinationGitlab *GitlabInstance) mirrorReleases(sourceGitlab *GitlabInst
247244 // Fetch releases from the source project
248245 sourceReleases , _ , err := sourceGitlab .Gitlab .Releases .ListReleases (sourceProject .ID , & gitlab.ListReleasesOptions {})
249246 if err != nil {
250- return fmt .Errorf ("failed to fetch releases for source project %s: %s" , sourceProject .HTTPURLToRepo , err )
247+ return [] error { fmt .Errorf ("failed to fetch releases for source project %s: %s" , sourceProject .HTTPURLToRepo , err )}
251248 }
252249
253250 // Create a wait group and an error channel for handling API calls concurrently
@@ -288,7 +285,7 @@ func (destinationGitlab *GitlabInstance) mirrorReleases(sourceGitlab *GitlabInst
288285 close (errorChan )
289286
290287 zap .L ().Info ("Releases mirroring completed" , zap .String (ROLE_SOURCE , sourceProject .HTTPURLToRepo ), zap .String (ROLE_DESTINATION , destinationProject .HTTPURLToRepo ))
291- return utils .MergeErrors (errorChan , 2 )
288+ return utils .MergeErrors (errorChan )
292289}
293290
294291// ============================================================ //
0 commit comments