prstatus

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 13 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 a GitHub status check context.

type DashboardAgent

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

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

func NewDashboardAgent

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

NewDashboardAgent creates a new user dashboard agent .

func (*DashboardAgent) ConstructSearchQuery

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

ConstructSearchQuery returns the GitHub search query string for PRs that are open and authored by the user passed. The search is scoped to repositories that are configured with either Prow or Tide.

func (*DashboardAgent) HandlePrStatus

func (da *DashboardAgent) HandlePrStatus(queryHandler pullRequestQueryHandler, createClient githubClientCreator) 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..

type GitHubClient

type GitHubClient interface {
	BotUser() (*github.UserData, error)
	// contains filtered or unexported methods
}

type Label

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

Label represents a GitHub label.

type PullRequest

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

PullRequest holds the GraphQL response data for a GitHub pull request.

type PullRequestWithContexts

type PullRequestWithContexts struct {
	Contexts    []Context
	PullRequest PullRequest
}

PullRequestWithContexts contains a pull request with its latest commit contexts.

type UserData

type UserData struct {
	Login                    bool
	PullRequestsWithContexts []PullRequestWithContexts
}

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 githubql.String
	}
}

UserLoginQuery holds the GraphQL query for the currently authenticated user.

Jump to

Keyboard shortcuts

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