prstatus

package
v0.0.0-...-7a2065e Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Context     string
	Description string
	State       string
}

Context represent github contexts.

type DashboardAgent

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

Dashboard Agent is responsible for handling request to /pr-status endpoint. It will serve list of open pull requests owned by the user.

func NewDashboardAgent

func NewDashboardAgent(repos []string, config *config.GithubOAuthConfig, log *logrus.Entry) *DashboardAgent

Returns new user dashboard agent.

func (*DashboardAgent) ConstructSearchQuery

func (da *DashboardAgent) ConstructSearchQuery(login string) string

func (*DashboardAgent) GetUser

func (da *DashboardAgent) GetUser(client *ghclient.Client) (*gogithub.User, error)

func (*DashboardAgent) HandlePrStatus

func (da *DashboardAgent) HandlePrStatus(queryHandler PullRequestQueryHandler) http.HandlerFunc

HandlePrStatus returns a http handler function that handles request to /pr-status endpoint. The handler takes user access token stored in the cookie to query to Github on behalf of the user and serve the data in return. The Query handler is passed to the method so as it can be mocked in the unit test..

func (*DashboardAgent) HeadContexts

func (da *DashboardAgent) HeadContexts(ghc githubClient, pr PullRequest) ([]Context, error)

func (*DashboardAgent) QueryPullRequests

func (da *DashboardAgent) QueryPullRequests(ctx context.Context, ghc githubClient, query string) ([]PullRequest, error)

Query function that returns a list of open pull requests owned by the user whose access token is consumed by the github client.

type Label

type Label struct {
	ID   githubv4.ID
	Name githubv4.String
}

type PullRequest

type PullRequest struct {
	Number githubv4.Int
	Merged githubv4.Boolean
	Title  githubv4.String
	Author struct {
		Login githubv4.String
	}
	BaseRef struct {
		Name   githubv4.String
		Prefix githubv4.String
	}
	HeadRefOID githubv4.String `graphql:"headRefOid"`
	Repository struct {
		Name          githubv4.String
		NameWithOwner githubv4.String
		Owner         struct {
			Login githubv4.String
		}
	}
	Labels struct {
		Nodes []struct {
			Label Label `graphql:"... on Label"`
		}
	} `graphql:"labels(first: 100)"`
	Milestone struct {
		ID     githubv4.ID
		Closed githubv4.Boolean
	}
}

PullRequest holds graphql response data for github pull request.

type PullRequestQueryHandler

type PullRequestQueryHandler interface {
	HeadContexts(ghc githubClient, pr PullRequest) ([]Context, error)
	QueryPullRequests(context.Context, githubClient, string) ([]PullRequest, error)
	GetUser(*ghclient.Client) (*gogithub.User, error)
}

PullRequestQueryHandler defines an interface that query handlers should implement.

type PullRequestWithContext

type PullRequestWithContext struct {
	Contexts    []Context
	PullRequest PullRequest
}

PullRequestWithContext contains a pull request with its latest context.

type UserData

type UserData struct {
	Login                    bool
	PullRequestsWithContexts []PullRequestWithContext
}

UserData represents data returned to client request to the endpoint. It has a flag that indicates whether the user has logged in his github or not and list of open pull requests owned by the user.

type UserLoginQuery

type UserLoginQuery struct {
	Viewer struct {
		Login githubv4.String
	}
}

Jump to

Keyboard shortcuts

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