-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathrepositories.go
76 lines (68 loc) · 1.74 KB
/
repositories.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
package main
import (
"net/http"
)
// Response is derived from the following sources:
// https://github.com/google/go-github/blob/27c7c32b6d369610435bd2ad7b4d8554f235eb01/github/github.go#L301
// https://github.com/xanzy/go-gitlab/blob/3acf8d75e9de17ad4b41839a7cabbf2537760ab4/gitlab.go#L286
type Response struct {
*http.Response
// These fields provide the page values for paginating through a set of
// results. Any or all of these may be set to the zero value for
// responses that are not part of a paginated set, or for which there
// are no additional pages.
NextPage int
PrevPage int
FirstPage int
LastPage int
}
// Repository is a container for the details for a repository
// we will backup
type Repository struct {
CloneURL string
Name string
Namespace string
Private bool
}
func getRepositories(
client interface{},
service string, githubRepoType string, githubNamespaceWhitelist []string,
gitlabProjectVisibility string, gitlabProjectMembershipType string,
ignoreFork bool,
) ([]*Repository, error) {
var repositories []*Repository
var err error
switch service {
case "github":
repositories, err = getGithubRepositories(
client,
service,
githubRepoType,
githubNamespaceWhitelist,
gitlabProjectVisibility,
gitlabProjectMembershipType,
ignoreFork,
)
case "gitlab":
repositories, err = getGitlabRepositories(
client,
service,
githubRepoType,
githubNamespaceWhitelist,
gitlabProjectVisibility,
gitlabProjectMembershipType,
ignoreFork,
)
case "bitbucket":
repositories, err = getBitbucketRepositories(
client,
service,
githubRepoType,
githubNamespaceWhitelist,
gitlabProjectVisibility,
gitlabProjectMembershipType,
ignoreFork,
)
}
return repositories, err
}