Documentation
¶
Index ¶
- Constants
- Variables
- func CanPostStatus(client *Client, repo *repositoryInfo) error
- func ValidateTokenPermissions(client *Client) error
- type Client
- type ClientConfig
- type ClientPool
- func (p *ClientPool) Client(username, repo string) (*Client, bool)
- func (p *ClientPool) Clients() map[*Client][]*repositoryInfo
- func (p *ClientPool) GitAuth(ctx context.Context, repoInfo *lookout.RepositoryInfo) transport.AuthMethod
- func (p *ClientPool) RemoveClient(c *Client)
- func (p *ClientPool) Repos() []string
- func (p *ClientPool) ReposByClient(c *Client) []*repositoryInfo
- func (p *ClientPool) Subscribe(ch chan ClientPoolEvent)
- func (p *ClientPool) Unsubscribe(ch chan ClientPoolEvent)
- func (p *ClientPool) Update(c *Client, newRepos []*repositoryInfo)
- type ClientPoolEvent
- type ClientPoolEventType
- type Installations
- type Poster
- type ProviderConfig
- type StatusCreator
- type Watcher
Constants ¶
const Provider = "github"
Variables ¶
var ( // ErrLineOutOfDiff is returned when the file line number is not // in the patch diff ErrLineOutOfDiff = errors.NewKind("line number is not in diff") // ErrLineNotAddition is returned when the file line number is not // a + change in the patch diff ErrLineNotAddition = errors.NewKind("line number is not an added change") // ErrFileNotFound is returned when the file name is not part of the diff ErrFileNotFound = errors.NewKind("file not found") // ErrBadPatch is returned when there was a problem parsing the diff ErrBadPatch = errors.NewKind("diff patch could not be parsed") )
var ( // ErrGitHubAPI signals an error while making a request to the GitHub API. ErrGitHubAPI = errors.NewKind("github api error: %s") // ErrEventNotSupported signals that this provider does not support the // given event for a given operation. ErrEventNotSupported = errors.NewKind("event not supported") )
var ( ErrEmptyTemplate = errors.NewKind("empty footer template") ErrOldTemplate = errors.NewKind("old footer template: '%%s' placeholder is no longer supported: '%s'") ErrParseTemplate = errors.NewKind("error parsing footer template: %s") ErrTemplateError = errors.NewKind("error generating the footer: %s") )
Functions ¶
func CanPostStatus ¶ added in v0.10.0
CanPostStatus check if the client has push access to a repository which is required for updating status. It assumes client has correct scope. returns error if it permission is missed
func ValidateTokenPermissions ¶ added in v0.10.0
ValidateTokenPermissions checks that client has necessary permissions required by lookout returns error if any is missed
Types ¶
type Client ¶ added in v0.1.0
Client is a wrapper for github.Client that supports cache and provides rate limit information
func NewClient ¶ added in v0.1.0
func NewClient( t http.RoundTripper, cache *cache.ValidableCache, watchMinInterval string, gitAuth gitAuthFn, timeout time.Duration, ) *Client
NewClient creates new Client. A timeout of zero means no timeout.
func (*Client) PollInterval ¶ added in v0.1.0
PollInterval returns last duration from X-Poll-Interval for a client by category
type ClientConfig ¶ added in v0.1.1
ClientConfig holds github username, token and watch interval
func (ClientConfig) IsZero ¶ added in v0.1.1
func (c ClientConfig) IsZero() bool
IsZero return true if config is empty and false otherwise
type ClientPool ¶ added in v0.1.0
type ClientPool struct {
// contains filtered or unexported fields
}
ClientPool holds mapping of repositories to clients
func NewClientPool ¶ added in v0.1.5
func NewClientPool() *ClientPool
NewClientPool creates new pool of clients with repositories
func NewClientPoolFromTokens ¶ added in v0.1.0
func NewClientPoolFromTokens( urlToConfig map[string]ClientConfig, cache *cache.ValidableCache, timeout time.Duration, ) (*ClientPool, error)
NewClientPoolFromTokens creates new ClientPool based on map[repoURL]ClientConfig later we will need another constructor that would request installations and create pool from it
func (*ClientPool) Client ¶ added in v0.1.0
func (p *ClientPool) Client(username, repo string) (*Client, bool)
Client returns client, ok by username and repository name
func (*ClientPool) Clients ¶ added in v0.1.0
func (p *ClientPool) Clients() map[*Client][]*repositoryInfo
Clients returns map[Client]RepositoryInfo
func (*ClientPool) GitAuth ¶ added in v0.3.0
func (p *ClientPool) GitAuth(ctx context.Context, repoInfo *lookout.RepositoryInfo) transport.AuthMethod
GitAuth returns a go-git auth method for a repo
func (*ClientPool) RemoveClient ¶ added in v0.1.5
func (p *ClientPool) RemoveClient(c *Client)
RemoveClient removes client from the pool and notifies about it
func (*ClientPool) Repos ¶ added in v0.1.5
func (p *ClientPool) Repos() []string
Repos returns list of repositories in the pool
func (*ClientPool) ReposByClient ¶ added in v0.1.5
func (p *ClientPool) ReposByClient(c *Client) []*repositoryInfo
ReposByClient returns list of repositories by client
func (*ClientPool) Subscribe ¶ added in v0.1.5
func (p *ClientPool) Subscribe(ch chan ClientPoolEvent)
Subscribe allows to subscribe to changes in the pool
func (*ClientPool) Unsubscribe ¶ added in v0.1.5
func (p *ClientPool) Unsubscribe(ch chan ClientPoolEvent)
Unsubscribe stops sending changes to the channel
func (*ClientPool) Update ¶ added in v0.1.5
func (p *ClientPool) Update(c *Client, newRepos []*repositoryInfo)
Update updates list of repositories for a client
type ClientPoolEvent ¶ added in v0.1.5
type ClientPoolEvent struct { Type ClientPoolEventType Client *Client }
ClientPoolEvent defines change in ClientPool
type ClientPoolEventType ¶ added in v0.1.5
type ClientPoolEventType string
ClientPoolEventType type of the change in ClientPool
const ( // ClientPoolEventAdd happens when new client is added in the pool ClientPoolEventAdd ClientPoolEventType = "add" // ClientPoolEventRemove happens when client is removed from the pool ClientPoolEventRemove ClientPoolEventType = "remove" )
type Installations ¶ added in v0.1.5
type Installations struct { Pool *ClientPool // contains filtered or unexported fields }
Installations keeps github installations and allows to sync them
func NewInstallations ¶ added in v0.1.5
func NewInstallations( appID int, privateKey string, cache *cache.ValidableCache, watchMinInterval string, clientTimeout time.Duration, ) (*Installations, error)
NewInstallations creates a new Installations using the App ID and private key
func (*Installations) Sync ¶ added in v0.1.5
func (t *Installations) Sync() error
Sync update state from github
type Poster ¶
type Poster struct {
// contains filtered or unexported fields
}
Poster posts comments as Pull Request Reviews.
func NewPoster ¶
func NewPoster(pool *ClientPool, conf ProviderConfig) (*Poster, error)
NewPoster creates a new poster for the GitHub API.
func (*Poster) Post ¶
func (p *Poster) Post(ctx context.Context, e lookout.Event, aCommentsList []lookout.AnalyzerComments, safe bool) error
Post posts comments as a Pull Request Review. If the event is not a GitHub Pull Request, ErrEventNotSupported is returned. If a GitHub API request fails, ErrGitHubAPI is returned.
type ProviderConfig ¶ added in v0.0.4
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"` }
ProviderConfig represents the yml config
type StatusCreator ¶ added in v0.0.3
type StatusCreator interface { // CreateStatus creates a new status for a repository at the specified // reference. Ref can be a SHA, a branch name, or a tag name. CreateStatus(ctx context.Context, owner, repo, ref string, status *github.RepoStatus) ( *github.RepoStatus, *github.Response, error) }
StatusCreator creates statuses on GitHub. *github.RepositoriesService fulfills this interface.