-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathgithub_create_user_migration.go
78 lines (72 loc) · 1.88 KB
/
github_create_user_migration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"context"
"log"
"time"
)
func handleGithubCreateUserMigration(client interface{}, c *appConfig) {
repos, err := getRepositories(
client,
c.service,
c.githubRepoType,
c.githubNamespaceWhitelist,
c.gitlabProjectVisibility,
c.gitlabProjectMembershipType,
c.ignoreFork,
)
if err != nil {
log.Fatalf("Error getting list of repositories: %v", err)
}
log.Printf("Creating a user migration for %d repos", len(repos))
m, err := createGithubUserMigration(
context.Background(),
client, repos,
c.githubCreateUserMigrationRetry,
c.githubCreateUserMigrationRetryMax,
)
if err != nil {
log.Fatalf("Error creating migration: %v", err)
}
if c.githubWaitForMigrationComplete {
migrationStatePollingDuration := 60 * time.Second
err = downloadGithubUserMigrationData(
context.Background(),
client, c.backupDir,
m.ID,
migrationStatePollingDuration,
)
if err != nil {
log.Fatalf("Error querying/downloading migration: %v", err)
}
}
orgs, err := getGithubUserOwnedOrgs(context.Background(), client)
if err != nil {
log.Fatal("Error getting user organizations", err)
}
for _, o := range orgs {
orgRepos, err := getGithubOrgRepositories(context.Background(), client, o)
if err != nil {
log.Fatal("Error getting org repos", err)
}
if len(orgRepos) == 0 {
log.Printf("No repos found in %s", *o.Login)
continue
}
log.Printf("Creating a org migration (%s) for %d repos", *o.Login, len(orgRepos))
oMigration, err := createGithubOrgMigration(context.Background(), client, *o.Login, orgRepos)
if err != nil {
log.Fatalf("Error creating migration: %v", err)
}
if c.githubWaitForMigrationComplete {
migrationStatePollingDuration := 60 * time.Second
downloadGithubOrgMigrationData(
context.Background(),
client,
*o.Login,
c.backupDir,
oMigration.ID,
migrationStatePollingDuration,
)
}
}
}