-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrepositories.go
42 lines (38 loc) · 838 Bytes
/
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
package main
import (
"fmt"
"k8s.io/test-infra/prow/github"
)
// Repository represents the full name of a repo.
type Repository struct {
Org string
Repo string
Branch string
}
func getRepositories(ghClient github.Client, org string) ([]Repository, error) {
repos := []Repository{}
// Obtain all the repositories in the organization
res, err := ghClient.GetRepos(org, false)
if err != nil {
return nil, fmt.Errorf("Unable to obtain GitHub repositories")
}
for _, v := range res {
// Ignore archived repositories
if v.Archived {
continue
}
// Ignore private repositories
if v.Private {
continue
}
repos = append(repos, Repository{
Org: org,
Repo: v.Name,
Branch: v.DefaultBranch,
})
}
if len(repos) == 0 {
return nil, fmt.Errorf("Empty repository list")
}
return repos, nil
}