Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/lookoutd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func (c *lookoutdCommand) initProviderGithubApp(conf Config) error {
if conf.Providers.Github.AppID == 0 {
return fmt.Errorf("missing GitHub App ID in config")
}

installationsSyncInterval := defaultInstallationsSyncInterval
if conf.Providers.Github.InstallationSyncInterval != "" {
var err error
Expand All @@ -225,7 +226,7 @@ func (c *lookoutdCommand) initProviderGithubApp(conf Config) error {
cache := cache.NewValidableCache(diskcache.New("/tmp/github"))
insts, err := github.NewInstallations(
conf.Providers.Github.AppID, conf.Providers.Github.PrivateKey,
cache, conf.Timeout.GithubRequest)
cache, conf.Providers.Github.WatchMinInterval, conf.Timeout.GithubRequest)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions config.yml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ providers:
# app_id: 1234
# private_key: ./key.pem
# installation_sync_interval: 1h
# watch_min_interval: 2s

repositories:
- url: github.com/src-d/lookout
Expand Down
5 changes: 4 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ providers:
# app_id: 1234
# private_key: ./key.pem
# installation_sync_interval: 1h
# watch_min_interval: 2s
```

`comment_footer` key defines a format-string that will be used for custom messages for every message posted on GitHub; see how to [add a custom message to the posted comments](#custom-footer)
Expand Down Expand Up @@ -64,12 +65,14 @@ providers:
app_id: 1234
private_key: ./key.pem
installation_sync_interval: 1h
watch_min_interval: 10s
```

When the GitHub App authentication method is used, the repositories to analyze are retrieved automatically from the GitHub installations, so `repositories` list from `config.yml` is ignored.

The update interval is defined by `installation_sync_interval`.
The update interval to discover new installations and repositories is defined by `installation_sync_interval`.

The minimum watch interval to discover new pull requests and push events is defined by `watch_min_interval`.

## Repositories

Expand Down
27 changes: 14 additions & 13 deletions provider/github/installations.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (

// Installations keeps github installations and allows to sync them
type Installations struct {
appID int
privateKey string
appClient *github.Client
appID int
privateKey string
appClient *github.Client
watchMinInterval string

cache *cache.ValidableCache
clientTimeout time.Duration
Expand All @@ -37,6 +38,7 @@ type Installations struct {
func NewInstallations(
appID int, privateKey string,
cache *cache.ValidableCache,
watchMinInterval string,
clientTimeout time.Duration,
) (*Installations, error) {
// Use App authorization to list installations
Expand All @@ -55,13 +57,14 @@ func NewInstallations(
log.Infof("authorized as GitHub application %q, ID %v", app.GetName(), app.GetID())

i := &Installations{
appID: appID,
privateKey: privateKey,
appClient: appClient,
cache: cache,
clientTimeout: clientTimeout,
clients: make(map[int64]*Client),
Pool: NewClientPool(),
appID: appID,
privateKey: privateKey,
appClient: appClient,
watchMinInterval: watchMinInterval,
cache: cache,
clientTimeout: clientTimeout,
clients: make(map[int64]*Client),
Pool: NewClientPool(),
}

return i, nil
Expand Down Expand Up @@ -168,9 +171,7 @@ func (t *Installations) createClient(installationID int64) (*Client, error) {
}
}

// TODO (carlosms): hardcoded, take from config
watchMinInterval := ""
return NewClient(itr, t.cache, watchMinInterval, gitAuth, t.clientTimeout), nil
return NewClient(itr, t.cache, t.watchMinInterval, gitAuth, t.clientTimeout), nil
}

func (t *Installations) getRepos(iClient *Client) ([]*lookout.RepositoryInfo, error) {
Expand Down
1 change: 1 addition & 0 deletions provider/github/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ProviderConfig struct {
PrivateKey string `yaml:"private_key"`
AppID int `yaml:"app_id"`
InstallationSyncInterval string `yaml:"installation_sync_interval"`
WatchMinInterval string `yaml:"watch_min_interval"`
}

// don't call github more often than
Expand Down