github

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2018 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Provider = "github"

Variables

View Source
var (
	// ErrGitHubAPI signals an error while making a request to the GitHub API.
	ErrGitHubAPI = errors.NewKind("github api error")
	// ErrEventNotSupported signals that this provider does not support the
	// given event for a given operation.
	ErrEventNotSupported = errors.NewKind("event not supported")
)
View Source
var (
	NoErrNotModified       = errors.NewKind("Not modified")
	ErrParsingEventPayload = errors.NewKind("Parse error in event")

	// RequestTimeout is the max time to wait until the request context is
	// cancelled.
	RequestTimeout = time.Second * 5
)
View Source
var (
	ErrLineOutOfDiff = errors.NewKind("line number is not in diff")
)

Functions

This section is empty.

Types

type Client added in v0.1.0

type Client struct {
	*github.Client
	// contains filtered or unexported fields
}

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, l log.Logger) *Client

NewClient creates new Client

func (*Client) PollInterval added in v0.1.0

func (c *Client) PollInterval(cat pollLimitCategory) time.Duration

PollInterval returns last duration from X-Poll-Interval for a client by category

func (*Client) Rate added in v0.1.0

func (c *Client) Rate(cat rateLimitCategory) github.Rate

Rate returns last github.Rate for a client by category

func (*Client) Validate added in v0.1.0

func (c *Client) Validate(path string) error

Validate validates cache by path

type ClientPool added in v0.1.0

type ClientPool struct {
	// contains filtered or unexported fields
}

ClientPool holds mapping of repositories to clients

func NewClientPoolFromTokens added in v0.1.0

func NewClientPoolFromTokens(urls map[string]UserToken, defaultToken UserToken, cache *cache.ValidableCache) (*ClientPool, error)

NewClientPoolFromTokens creates new ClientPool based on map[repoURL]UserToken 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][]*lookout.RepositoryInfo

Clients returns map[Client]RepositoryInfo

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

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) 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.

func (*Poster) Status added in v0.0.3

func (p *Poster) Status(ctx context.Context, e lookout.Event, status lookout.AnalysisStatus) error

Status sets the Pull Request global status, visible from the GitHub UI If a GitHub API request fails, ErrGitHubAPI is returned.

type ProviderConfig added in v0.0.4

type ProviderConfig struct {
	CommentFooter string `yaml:"comment_footer"`
}

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.

type UserToken added in v0.1.0

type UserToken struct {
	User  string
	Token string
}

UserToken holds github username and token

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher(pool *ClientPool, o *lookout.WatchOptions) (*Watcher, error)

NewWatcher returns a new

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context, cb lookout.EventHandler) error

Watch start to make request to the GitHub API and return the new events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL