Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(h *RepoHelper)
Option creates an option for RepoHelper.
func WithLogger ¶
WithLogger creates an option to use the supplied logger.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a proxy server for GitHub. It proxies http requests using a GitHub app's credentials. This makes it easy to fetch documents from private repositories.
N.B jeremy@ tried using the gin framework but couldn't figure out how to properly handle path prefixes. I tried using NoRoute and overriding the not found handler but the response code was always 404.
func (*Proxy) HealthCheck ¶
func (f *Proxy) HealthCheck(w http.ResponseWriter, r *http.Request)
HealthCheck handles a health check
func (*Proxy) NotFoundHandler ¶
func (f *Proxy) NotFoundHandler(w http.ResponseWriter, r *http.Request)
NotFoundHandler is a custom not found handler A custom not found handler is useful for determining whether a 404 is coming because of an issue with ISTIO not hitting the server or the request is hitting the server but the path is wrong.
type PullRequest ¶
type PullRequest struct {
ID string
Number int
Title string
State string
Closed bool
URL string
BaseRefName string
HeadRefName string
Body string
Mergeable string
Author struct {
Login string
}
HeadRepositoryOwner struct {
Login string
}
HeadRepository struct {
Name string
DefaultBranchRef struct {
Name string
}
}
IsCrossRepository bool
IsDraft bool
MaintainerCanModify bool
ReviewDecision string
Commits struct {
TotalCount int
Nodes []struct {
Commit struct {
StatusCheckRollup struct {
Contexts struct {
Nodes []struct {
State string
Status string
Conclusion string
}
}
}
}
}
}
ReviewRequests struct {
Nodes []struct {
RequestedReviewer struct {
TypeName string `json:"__typename"`
Login string
Name string
}
}
TotalCount int
}
Reviews struct {
Nodes []struct {
Author struct {
Login string
}
State string
}
}
Assignees struct {
Nodes []struct {
Login string
}
TotalCount int
}
Labels struct {
Nodes []struct {
Name string
}
TotalCount int
}
ProjectCards struct {
Nodes []struct {
Project struct {
Name string
}
Column struct {
Name string
}
}
TotalCount int
}
Milestone struct {
Title string
}
}
PullRequest is a struct for representing PRs. This was largely copied from GitHub's CLI.
func (PullRequest) HeadLabel ¶
func (pr PullRequest) HeadLabel() string
HeadLabel returns the label for the head reference.
type RepoHelper ¶
type RepoHelper struct {
// contains filtered or unexported fields
}
RepoHelper provides a higher level API ontop of the GraphQL API.
TODO(https://github.com/PrimerAI/hydros-public/issues/2): Migrage to github.com/shurcooL/githubv4 It is inspired by the higher level API in GitHub's GoLang CLI. A lot of the code is modified from that.
We don't use the CLI The CLI authors suggested (https://github.com/cli/cli/issues/1327) that it would be better to use the API client libraries directly; github.com/shurcooL/githubv4. The CLI API is providing higher level functions ontop of the underlying GraphQL API; it seems silly to redo that rather than just import it and reuse it. https://github.com/cli/cli/blob/4d28c791921621550f19a4c6bcc13778a7525025/api/queries_pr.go
func NewGithubRepoHelper ¶
func NewGithubRepoHelper(transport *ghinstallation.Transport, baseRepo ghrepo.Interface, opts ...Option) (*RepoHelper, error)
NewGithubRepoHelper creates a helper for a specific repository. transport - must be a transport configured with permission to access the referenced repository. baseRepo - the repository to access.
func (*RepoHelper) CreatePr ¶
func (h *RepoHelper) CreatePr(baseBranch, forkRef, prMessage string, labels []string) error
CreatePr creates a pull request baseBranch the branch into which your code should be merged. forkRef the reference to the fork from which to create the PR
Forkref will either be OWNER:BRANCH when a different repository is used as the fork. or it will be just BRANCH when merging from a branch in the same Repo as Repo
func (*RepoHelper) PullRequestForBranch ¶
func (h *RepoHelper) PullRequestForBranch(baseBranch, headBranch string) (*PullRequest, error)
PullRequestForBranch returns the PR for the given branch if it exists and nil if no PR exists.
type TransportManager ¶
type TransportManager struct {
// contains filtered or unexported fields
}
TransportManager manages credentials for a GitHub App. TODO(jeremy): Can/should we wrap this in the OAuth flow. TODO(jeremy): Should we reuse some of palantir built? https://github.com/palantir/go-githubapp/blob/develop/githubapp/client_creator.go
func NewTransportManager ¶
func NewTransportManager(appID int64, privateKeyFile string, log logr.Logger) (*TransportManager, error)
NewTransportManager creates a new transport manager.
func (*TransportManager) Get ¶
func (m *TransportManager) Get(org string, repo string) (*ghinstallation.Transport, error)
Get returns a transport to talk to the specified Org and Repo.