func init() { accessToken := os.Getenv("GITHUB_ACCESS_TOKEN") if accessToken == "" { log.Fatal("GITHUB_ACCESS_TOKEN env required") } hClient := &http.Client{Transport: myRoundTripper{accessToken}} client = github.NewClient(hClient) }
func init() { accessToken := os.Getenv("GITHUB_ACCESS_TOKEN") if accessToken == "" { log.Fatal("GITHUB_ACCESS_TOKEN env required") } if number = os.Getenv("BUILD_NUMBER"); number == "" { log.Fatal("BUILD_NUMBER env required") } if sha = os.Getenv("GIT_SHA"); sha == "" { log.Fatal("GIT_SHA env required") } binDir = os.Getenv("OUTPUTDIR") hClient := &http.Client{Transport: myRoundTripper{accessToken}} client = github.NewClient(hClient) }
func startGithubCollectors(c *conf.Conf) { for _, gh := range c.Github { client := github.NewClient(&http.Client{Transport: githubRoundTripper{gh.Token}}) split := strings.Split(gh.Repo, "/") if len(split) != 2 { slog.Fatal("Repo must have two parts (owner/repo)") } owner, repo := split[0], split[1] collectors = append(collectors, &IntervalCollector{ F: func() (opentsdb.MultiDataPoint, error) { return githubCollect(client, owner, repo) }, name: fmt.Sprintf("github-%s", gh.Repo), Interval: 10 * time.Minute, //10 minutes to respect api limits }) } }