Documentation ¶
Index ¶
- Constants
- Variables
- func TreeToDisplay(entries []*github.TreeEntry, schemaType protos.SchemaType) *protos.Directory
- type Github
- func (g *Github) CreateBranch(ctx context.Context, token, owner, repo, sha, branchName string) (*github.Reference, error)
- func (g *Github) CreateCommit(ctx context.Context, token, owner, repo, treeSHA, commitName string, ...) (*github.Commit, error)
- func (g *Github) CreatePullRequest(ctx context.Context, token, owner, repo string, opts *PullRequestOpts) (*github.PullRequest, error)
- func (g *Github) CreateTree(ctx context.Context, token, owner, repo, baseTreeSHA string, ...) (*github.Tree, error)
- func (g *Github) Get(url, oAuthToken string) ([]byte, int, error)
- func (g *Github) GetMainBranch(ctx context.Context, token, owner, repo string) (*github.Branch, error)
- func (g *Github) GetRepoArchive(ctx context.Context, token, owner, repo string) ([]byte, error)
- func (g *Github) GetRepoFile(ctx context.Context, token, owner, repo, sha string) ([]byte, error)
- func (g *Github) GetRepoList(ctx context.Context, installID int64, token string) ([]string, error)
- func (g *Github) GetRepoTree(ctx context.Context, token, owner, repo string) (*github.Tree, error)
- func (g *Github) Post(url string, values url.Values) ([]byte, int, error)
- func (g *Github) UpdateBranch(ctx context.Context, token, owner, repo, sha, branchName string) (*github.Reference, error)
- type IGithub
- type PullRequestFile
- type PullRequestOpts
- type RepoListResponse
Constants ¶
const ( // RepoListMaxResults is the number of results to return when getting a repository list // GitHub hard-limits this to 100 RepoListMaxResults = 100 )
Variables ¶
var (
ErrVerifyTimeout = errors.New("Unable to verify GitHub access after 15 minutes")
)
Functions ¶
func TreeToDisplay ¶
TreeToDisplay turns a github GetRepoTree response into a nested structure This is necessary because GitHub's API returns a flat list of files
Types ¶
type Github ¶
func (*Github) CreateBranch ¶
func (g *Github) CreateBranch(ctx context.Context, token, owner, repo, sha, branchName string) (*github.Reference, error)
CreateBranch creates a new branch under the repository for the given SHA and branchName
func (*Github) CreateCommit ¶
func (*Github) CreatePullRequest ¶
func (g *Github) CreatePullRequest(ctx context.Context, token, owner, repo string, opts *PullRequestOpts) (*github.PullRequest, error)
func (*Github) CreateTree ¶
func (g *Github) CreateTree(ctx context.Context, token, owner, repo, baseTreeSHA string, files []*github.TreeEntry) (*github.Tree, error)
CreateTree creates a new file tree.
func (*Github) Get ¶
Get makes a GET request with an oAuth token and returns the resulting body contents
func (*Github) GetMainBranch ¶
func (g *Github) GetMainBranch(ctx context.Context, token, owner, repo string) (*github.Branch, error)
GetMainBranch gets the name and latest commit details of the main/master branch for a repository
func (*Github) GetRepoArchive ¶
GetRepoArchive returns a zip of the contents of a github repository
func (*Github) GetRepoFile ¶
GetRepoFile gets a single file from github. Used for Avro and JSONSchema imports
func (*Github) GetRepoList ¶
GetRepoList gets all repositories that an install has access to
func (*Github) GetRepoTree ¶
type IGithub ¶
type IGithub interface { CreateBranch(ctx context.Context, token, owner, repo, sha, branchName string) (*github.Reference, error) CreateCommit(ctx context.Context, token, owner, repo, treeSHA, commitName string, parent *github.Commit) (*github.Commit, error) CreatePullRequest(ctx context.Context, token, owner, repo string, opts *PullRequestOpts) (*github.PullRequest, error) CreateTree(ctx context.Context, token, owner, repo, baseTreeSHA string, files []*github.TreeEntry) (*github.Tree, error) GetRepoArchive(ctx context.Context, token, owner, repo string) ([]byte, error) GetRepoFile(ctx context.Context, token, owner, repo, sha string) ([]byte, error) GetRepoList(ctx context.Context, installID int64, token string) ([]string, error) GetRepoTree(ctx context.Context, token, owner, repo string) (*github.Tree, error) Post(url string, values url.Values) ([]byte, int, error) UpdateBranch(ctx context.Context, token, owner, repo, sha, branchName string) (*github.Reference, error) }
type PullRequestFile ¶
type PullRequestFile struct { // Fill path to the file, including filename Path string // Contents of the file Content string }
PullRequestFile represents a path to a file under a repository and it's contents. If the file path already exists, the existing contents will be modified
type PullRequestOpts ¶
type PullRequestOpts struct { // Branch name, will be prefixed with "plumber_ BranchName string // Optional, default is "Plumber commit" CommitName string // Title of the PR Title string // Description for PR Body string Files []*PullRequestFile }
PullRequestOpts encapsulates all options necessary to create a PR with CreatePullRequest()
type RepoListResponse ¶
type RepoListResponse struct {
Repositories []*github.Repository `json:"repositories"`
}
RepoListResponse is used to unmarshal a response from api.github.com/user/installations/.../repositories The GitHub SDK does not have a method for that endpoint for some odd reason