Skip to content

Commit

Permalink
Merge pull request #47 from arnabkaycee/org-repo-scrape-config
Browse files Browse the repository at this point in the history
Add config to choose types of repo to scrape
  • Loading branch information
arsulegai authored Jul 3, 2021
2 parents cdba14c + 9e890a0 commit cb38c97
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions assets/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ global:
name: "Hyperledger Labs"
github: "hyperledger-labs"
scrape-duration-days: 7
scrape-repo-class: public
external-template:
enabled: false
# Possible values "repository"
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func getExpectedReportsLists(

for _, organization := range config.GlobalConfiguration.Organizations {

repos, err := client.ListRepositories(organization.Organization.Github)
repos, err := client.ListRepositories(organization.Organization.Github, config.GlobalConfiguration.RepoClass)
if err != nil {
log.Fatalf("Err: %v", err)
return nil, nil, nil, true
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import "github-updates/internal/pkg/configs"

// GHClientInterface is for testing
type GHClientInterface interface {
ListRepositories(string) ([]string, error)
ListRepositories(string, string) ([]string, error)
ListPRs(string, []string, int) ([]configs.PrList, error)
ListReleases(string, []string, int) ([]configs.ReleaseList, error)
IssueWithLabels(string, []string, []string, int) ([]configs.IssueList, error)
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/client/ghclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ func NewClient() GHClientInterface {
}

// ListRepositories returns the list of all repositories
func (c Client) ListRepositories(org string) ([]string, error) {
func (c Client) ListRepositories(org string, repoClass string) ([]string, error) {
var listOfRepositories []string
listOption := &github.RepositoryListByOrgOptions{
ListOptions: github.ListOptions{
PerPage: 20,
},
Type: repoClass,
}
for {
repositories, response, err :=
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/configs/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type GlobalConfiguration struct {
Organizations []Organization `yaml:"organizations"`
DaysCount int `yaml:"scrape-duration-days"`
ExternalTemplate ExternalTemplate `yaml:"external-template"`
RepoClass string `yaml:"scrape-repo-class"`
}

type ExternalTemplate struct {
Expand Down

0 comments on commit cb38c97

Please sign in to comment.