Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func main() {
- client := github.NewClient(nil)
- opt := &github.RepositoryListByOrgOptions{Type: "public"}
- // get our public repositories list to the repos variable
- repos, _, _ := client.Repositories.ListByOrg(context.Background(), os.Getenv("GITHUB_ORG_NAME"), opt)
- // the list of repositories that are expected to be public
- allowedRepos := strings.Fields(os.Getenv("ALLOWED_REPOS"))
- for _, repo := range repos {
- fmt.Printf("nChecking %sn", *repo.Name)
- if isAllowedRepo(*repo.Name, allowedRepos) {
- fmt.Printf("OK: repo %s found in Allowedn", *repo.Name)
- } else {
- fmt.Printf("ALARM: repo %s was NOT found in Allowed!n", *repo.Name)
- sendSlackAlarm(*repo.Name, *repo.HTMLURL)
- }
- }
- }
- func isAllowedRepo(repoName string, allowedRepos []string) bool {
- // and just iterate the repoName over the allowedRepos list
- for _, i := range allowedRepos {
- if i == repoName {
- return true
- }
- }
- return false
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement