Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterProvider ¶
func RegisterProvider(name string, reg ProviderRegistration)
RegisterProvider is called by provider implementation packages to register themselves as a git provider.
Types ¶
type CreatePullRequestOpts ¶
type GitProviderOptions ¶ added in v0.8.0
type GitProviderOptions struct { // Name specifies which Git provider to use when that information cannot be // inferred from the repository URL. Name string // Token is the access token used to authenticate against the Git provider's // API. Token string // InsecureSkipTLSVerify specifies whether certificate verification errors // should be ignored when connecting to the Git provider's API. InsecureSkipTLSVerify bool }
GitProviderOptions contains the options for a GitProvider.
type GitProviderService ¶
type GitProviderService interface { // CreatePullRequest creates a pull request CreatePullRequest(ctx context.Context, opts CreatePullRequestOpts) (*PullRequest, error) // Get gets an existing pull request by ID GetPullRequest(ctx context.Context, number int64) (*PullRequest, error) // ListPullRequests lists pull requests by the given options ListPullRequests(ctx context.Context, opts ListPullRequestOpts) ([]*PullRequest, error) // IsPullRequestMerged returns whether or not the pull request was merged IsPullRequestMerged(ctx context.Context, number int64) (bool, error) }
GitProviderService is an abstracted interface for a git providers (GitHub, GitLab, BitBucket) when interacting against a single git repository (e.g. managing pull requests).
func NewGitProviderService ¶ added in v0.8.0
func NewGitProviderService(repoURL string, opts *GitProviderOptions) (GitProviderService, error)
NewGitProviderService returns an implementation of the GitProviderService interface.
type ListPullRequestOpts ¶
type ListPullRequestOpts struct { // State is the pull request state (one of: Open, Closed). Defaults to Open State PullRequestState Head string Base string }
type ProviderRegistration ¶
type ProviderRegistration struct { // Predicate is a function which should return true if the given repoURL is appropriate // for the provider to handle (e.g. github.com is the domain name) Predicate func(repoURL string) bool // NewService instantiates the git provider NewService func(repoURL string, opts *GitProviderOptions) (GitProviderService, error) }
ProviderRegistration holds details on how to instantiate the correct git provider based on parameters (i.e. repo URL). It allows programs to selectively register GitProviderService implementations by anonymously importing implementation packages.
type PullRequest ¶
type PullRequest struct { // Number is the numeric pull request number (not an ID) // Pull requests numbers are unique only within a repository Number int64 `json:"id"` // URL is the url to the pull request URL string `json:"url"` // State is the pull request state (one of: Open, Closed) State PullRequestState `json:"state"` // MergeCommitSHA is the SHA of the merge commit MergeCommitSHA string `json:"mergeCommitSHA"` // Object is the underlying object from the provider Object any `json:"-"` }
func (*PullRequest) IsOpen ¶
func (pr *PullRequest) IsOpen() bool
type PullRequestState ¶
type PullRequestState string
const ( PullRequestStateOpen PullRequestState = "Open" PullRequestStateClosed PullRequestState = "Closed" )