Documentation ¶
Index ¶
- Variables
- type AppInstallation
- type AppInstallations
- type AppRepoPermissions
- type BranchInfo
- type CommitStatus
- type FakeRepoClient
- func (frc *FakeRepoClient) GetBranch(ctx context.Context, repo string, branch string) (BranchInfo, error)
- func (frc *FakeRepoClient) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
- func (frc *FakeRepoClient) GetCommitMessage(ctx context.Context, repo string, sha string) (string, error)
- func (frc *FakeRepoClient) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
- func (frc *FakeRepoClient) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error)
- func (frc *FakeRepoClient) GetPRStatus(ctx context.Context, repo string, pr uint) (string, error)
- func (frc *FakeRepoClient) GetRepoArchive(ctx context.Context, repo, ref string) (string, error)
- func (frc *FakeRepoClient) GetTags(ctx context.Context, repo string) ([]BranchInfo, error)
- func (frc *FakeRepoClient) GetUser(ctx context.Context) (string, error)
- func (frc *FakeRepoClient) GetUserAppInstallations(ctx context.Context) (AppInstallations, error)
- func (frc *FakeRepoClient) GetUserAppRepoPermissions(ctx context.Context, instID int64) (map[string]AppRepoPermissions, error)
- func (frc *FakeRepoClient) GetUserAppRepos(ctx context.Context, instID int64) ([]string, error)
- func (frc *FakeRepoClient) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
- type FileContents
- type GitHubAppInstallationClient
- type GitHubClient
- func (ghc *GitHubClient) GetBranch(ctx context.Context, repo, branch string) (BranchInfo, error)
- func (ghc *GitHubClient) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
- func (ghc *GitHubClient) GetCommitMessage(ctx context.Context, repo string, sha string) (string, error)
- func (ghc *GitHubClient) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
- func (ghc *GitHubClient) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error)
- func (ghc *GitHubClient) GetPRStatus(ctx context.Context, repo string, pr uint) (string, error)
- func (ghc *GitHubClient) GetRepoArchive(ctx context.Context, repo, ref string) (string, error)
- func (ghc *GitHubClient) GetTags(ctx context.Context, repo string) ([]BranchInfo, error)
- func (ghc *GitHubClient) GetUser(ctx context.Context) (string, error)
- func (ghc *GitHubClient) GetUserAppInstallations(ctx context.Context) (AppInstallations, error)
- func (ghc *GitHubClient) GetUserAppRepoPermissions(ctx context.Context, instID int64) (map[string]AppRepoPermissions, error)
- func (ghc *GitHubClient) GetUserAppRepos(ctx context.Context, instID int64) ([]string, error)
- func (ghc *GitHubClient) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
- type LocalRepoInfo
- type LocalWrapper
- func (lw *LocalWrapper) GetBranch(ctx context.Context, repo, branch string) (BranchInfo, error)
- func (lw *LocalWrapper) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
- func (lw *LocalWrapper) GetCommitMessage(ctx context.Context, repo, sha string) (string, error)
- func (lw *LocalWrapper) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
- func (lw *LocalWrapper) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error)
- func (lw *LocalWrapper) GetPRStatus(context.Context, string, uint) (string, error)
- func (lw *LocalWrapper) GetRepoArchive(ctx context.Context, repo, ref string) (string, error)
- func (lw *LocalWrapper) GetTags(context.Context, string) ([]BranchInfo, error)
- func (lw *LocalWrapper) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
- type RepoClient
- type RepoFinder
- type StatusCallback
Constants ¶
This section is empty.
Variables ¶
var ErrBranchNotFound = errors.New("branch not found")
var ErrRefNotFound = errors.New("reference not found")
var MaxFileDownloadSizeBytes = 500 * 1000000
MaxFileDownloadSizeBytes contains the size limit for file content downloads. Attempting to GetFileContents for a file larger than this will return an error.
Functions ¶
This section is empty.
Types ¶
type AppInstallation ¶ added in v0.7.6
type AppInstallation struct {
ID int64
}
type AppInstallations ¶ added in v0.7.6
type AppInstallations []AppInstallation
func (AppInstallations) IDPresent ¶ added in v0.7.6
func (ai AppInstallations) IDPresent(id int64) bool
type AppRepoPermissions ¶ added in v0.7.6
type BranchInfo ¶
BranchInfo includes the information about a specific branch of a git repo
type CommitStatus ¶
CommitStatus describes a status associated with a git commit
type FakeRepoClient ¶
type FakeRepoClient struct { GetBranchFunc func(context.Context, string, string) (BranchInfo, error) GetBranchesFunc func(context.Context, string) ([]BranchInfo, error) GetTagsFunc func(context.Context, string) ([]BranchInfo, error) SetStatusFunc func(context.Context, string, string, *CommitStatus) error GetPRStatusFunc func(context.Context, string, uint) (string, error) GetCommitMessageFunc func(context.Context, string, string) (string, error) GetFileContentsFunc func(ctx context.Context, repo string, path string, ref string) ([]byte, error) GetDirectoryContentsFunc func(ctx context.Context, repo, path, ref string) (map[string]FileContents, error) GetUserAppInstallationsFunc func(ctx context.Context) (AppInstallations, error) GetUserAppReposFunc func(ctx context.Context, instID int64) ([]string, error) GetUserFunc func(ctx context.Context) (string, error) GetUserAppRepoPermissionsFunc func(ctx context.Context, instID int64) (map[string]AppRepoPermissions, error) GetRepoArchiveFunc func(ctx context.Context, repo, ref string) (string, error) }
FakeRepoClient is fake implementaiton of RepoClient that runs user-supplied functions for each method
func (*FakeRepoClient) GetBranch ¶
func (frc *FakeRepoClient) GetBranch(ctx context.Context, repo string, branch string) (BranchInfo, error)
func (*FakeRepoClient) GetBranches ¶
func (frc *FakeRepoClient) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
func (*FakeRepoClient) GetCommitMessage ¶
func (*FakeRepoClient) GetDirectoryContents ¶
func (frc *FakeRepoClient) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
func (*FakeRepoClient) GetFileContents ¶
func (*FakeRepoClient) GetPRStatus ¶
func (*FakeRepoClient) GetRepoArchive ¶ added in v0.7.6
func (*FakeRepoClient) GetTags ¶
func (frc *FakeRepoClient) GetTags(ctx context.Context, repo string) ([]BranchInfo, error)
func (*FakeRepoClient) GetUser ¶ added in v0.7.6
func (frc *FakeRepoClient) GetUser(ctx context.Context) (string, error)
func (*FakeRepoClient) GetUserAppInstallations ¶ added in v0.7.6
func (frc *FakeRepoClient) GetUserAppInstallations(ctx context.Context) (AppInstallations, error)
func (*FakeRepoClient) GetUserAppRepoPermissions ¶ added in v0.7.6
func (frc *FakeRepoClient) GetUserAppRepoPermissions(ctx context.Context, instID int64) (map[string]AppRepoPermissions, error)
func (*FakeRepoClient) GetUserAppRepos ¶ added in v0.7.6
func (*FakeRepoClient) SetStatus ¶
func (frc *FakeRepoClient) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
type FileContents ¶
FileContents models a file from a repository
type GitHubAppInstallationClient ¶ added in v0.7.6
type GitHubAppInstallationClient interface { GetUserAppInstallations(ctx context.Context) (AppInstallations, error) GetUserAppRepos(ctx context.Context, appID int64) ([]string, error) GetUser(ctx context.Context) (string, error) GetUserAppRepoPermissions(ctx context.Context, instID int64) (map[string]AppRepoPermissions, error) }
GitHubAppInstallationClient describes a GitHub client that returns user-scoped metadata regarding an app installation
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
GitHubClient is an object that interacts with the GitHub API
func NewGitHubClient ¶
func NewGitHubClient(token string) *GitHubClient
NewGitHubClient returns a GitHubClient instance that authenticates using the personal access token provided
func (*GitHubClient) GetBranch ¶
func (ghc *GitHubClient) GetBranch(ctx context.Context, repo, branch string) (BranchInfo, error)
GetBranch gets the information for a specific branch
func (*GitHubClient) GetBranches ¶
func (ghc *GitHubClient) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
GetBranches returns the extant branches for repo (assumed to be "owner/repo-name")
func (*GitHubClient) GetCommitMessage ¶
func (ghc *GitHubClient) GetCommitMessage(ctx context.Context, repo string, sha string) (string, error)
GetCommitMessage returns the git message associated with a particular commit
func (*GitHubClient) GetDirectoryContents ¶
func (ghc *GitHubClient) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
GetDirectoryContents fetches path from repo at ref, returning a map of file path to file contents. If path is not a directory, an error is returned. The contents may include symlinks that point to arbitrary locations (ie, outside of the directory root).
func (*GitHubClient) GetFileContents ¶
func (ghc *GitHubClient) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error)
GetFileContents returns the file contents of path (which must be a regular file or a symlink to a regular file) in the specified repo at ref
func (*GitHubClient) GetPRStatus ¶
GetPRStatus returns the status of a PR on a repo
func (*GitHubClient) GetRepoArchive ¶ added in v0.7.6
GetRepoArchive fetches repo at ref as a gzip-compressed tar archive and returns the local filesystem path, or error It is the caller's responsibility to clean up the file when finished
func (*GitHubClient) GetTags ¶
func (ghc *GitHubClient) GetTags(ctx context.Context, repo string) ([]BranchInfo, error)
GetTags returns the extant tags for repo (assumed to be "owner/repo-name")
func (*GitHubClient) GetUser ¶ added in v0.7.6
func (ghc *GitHubClient) GetUser(ctx context.Context) (string, error)
GetUser gets the authenticated user login name This method only uses the static token associated with the GitHubClient and not anything present in the context GitHubClient should be populated with the user token returned by the oauth login endpoint via the oauth callback handler
func (*GitHubClient) GetUserAppInstallations ¶ added in v0.7.6
func (ghc *GitHubClient) GetUserAppInstallations(ctx context.Context) (AppInstallations, error)
GetUserAppInstallationCount returns the number of app installations that are accessible to the authenticated user This method only uses the static token associated with the GitHubClient and not anything present in the context GitHubClient should be populated with the user token returned by the oauth login endpoint via the oauth callback handler
func (*GitHubClient) GetUserAppRepoPermissions ¶ added in v0.7.6
func (ghc *GitHubClient) GetUserAppRepoPermissions(ctx context.Context, instID int64) (map[string]AppRepoPermissions, error)
func (*GitHubClient) GetUserAppRepos ¶ added in v0.7.6
GetUserAppRepos gets repositories that are accessible to the authenticated user for an app installation This method only uses the static token associated with the GitHubClient and not anything present in the context GitHubClient should be populated with the user token returned by the oauth login endpoint via the oauth callback handler
func (*GitHubClient) SetStatus ¶
func (ghc *GitHubClient) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
SetStatus creates or updates a status on repo at commit sha Note that the github client CreateStatus function will bail if the context was canceled. It is often recommended to pass a fresh context to this function.
type LocalRepoInfo ¶
type LocalRepoInfo struct {
GitHubRepoName, HeadBranch, HeadSHA string
}
LocalRepoInfo models information about a local git repo
type LocalWrapper ¶
type LocalWrapper struct { Backend RepoClient // FSFunc is a function that returns a filesystem given a path FSFunc func(path string) billy.Filesystem // RepoPathMap is a map of GitHub repo names (ex: "owner/repo") to absolute local filesystem path (which must be a valid git repository) RepoPathMap map[string]string // WorkingTreeRepos are the repos to read contents directly from disk (not via commit SHA) WorkingTreeRepos []string // SetStatusCallback is a callback executed whenever SetStatus is called, if non-nil SetStatusCallback StatusCallback // contains filtered or unexported fields }
LocalWrapper is on object that satisfies RepoClient and which can optionally use local git repositories for repo names according to RepoPathMap, falling back to Backend if not found
func (*LocalWrapper) GetBranch ¶
func (lw *LocalWrapper) GetBranch(ctx context.Context, repo, branch string) (BranchInfo, error)
func (*LocalWrapper) GetBranches ¶
func (lw *LocalWrapper) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
func (*LocalWrapper) GetCommitMessage ¶
func (*LocalWrapper) GetDirectoryContents ¶
func (lw *LocalWrapper) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
func (*LocalWrapper) GetFileContents ¶
func (*LocalWrapper) GetPRStatus ¶
func (*LocalWrapper) GetRepoArchive ¶ added in v0.7.6
func (*LocalWrapper) GetTags ¶
func (lw *LocalWrapper) GetTags(context.Context, string) ([]BranchInfo, error)
stubs to satisfy the interface
func (*LocalWrapper) SetStatus ¶
func (lw *LocalWrapper) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
type RepoClient ¶
type RepoClient interface { GetBranch(context.Context, string, string) (BranchInfo, error) GetBranches(context.Context, string) ([]BranchInfo, error) GetTags(context.Context, string) ([]BranchInfo, error) SetStatus(context.Context, string, string, *CommitStatus) error GetPRStatus(context.Context, string, uint) (string, error) GetCommitMessage(context.Context, string, string) (string, error) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error) GetRepoArchive(ctx context.Context, repo, ref string) (string, error) }
RepoClient describes an object capable of operating on git repositories
type RepoFinder ¶
type RepoFinder struct { // GitHubHostname is the GitHub hostname to use when finding GitHub repos // (some people use fake GitHub hostnames to toggle SSH keys ("me.github.com") via ~/.ssh/config) GitHubHostname string FSFunc func(path string) afero.Fs LF func(string, ...interface{}) }
RepoFinder is an object that searches the local filesystem for git repositories configured for use with GitHub
func (*RepoFinder) Find ¶
func (rf *RepoFinder) Find(searchPaths []string) (map[string]string, error)
Find recursively searches searchPaths and finds any valid git repositories with remotes configured for GitHub. It returns a map of GitHub repo name ("owner/repo") to absolute local filesystem path, or error.