Documentation ¶
Index ¶
- func CreateHook(c context.Context, client *github.Client, owner, name, url string) (*github.Hook, error)
- func DeleteHook(c context.Context, client *github.Client, owner, name, url string) error
- func GetFile(c context.Context, client *github.Client, owner, name, path, ref string) ([]byte, error)
- func GetHook(c context.Context, client *github.Client, owner, name, rawurl string) (*github.Hook, error)
- func GetUserRepos(c context.Context, client *github.Client) ([]*github.Repository, error)
- type Branch
- type Client
- func (c *Client) GetBranchStatusCheck(owner, name, branch string) (*RequiredStatusChecks, error)
- func (c *Client) PatchBranchStatusCheck(owner, name, branch string, in *RequiredStatusChecks) error
- func (c *Client) SetClient(client *http.Client)
- func (c *Client) UpdateBranch(owner, name, branch string, in *Branch) error
- type DismissalRestrictions
- type Error
- type Github
- func (g *Github) AddIssueLabels(c context.Context, user *model.User, repo *model.Repo, number int, ...) error
- func (g *Github) DelHook(c context.Context, user *model.User, repo *model.Repo, link string) error
- func (g *Github) GetComments(c context.Context, u *model.User, r *model.Repo, num int) ([]*model.Comment, error)
- func (g *Github) GetContents(c context.Context, u *model.User, r *model.Repo, path string) ([]byte, error)
- func (g *Github) GetHook(c context.Context, r *http.Request) (*model.Hook, error)
- func (g *Github) GetIssueLabels(c context.Context, user *model.User, repo *model.Repo, number int) ([]string, error)
- func (g *Github) GetMembers(c context.Context, user *model.User, team string) ([]*model.Member, error)
- func (g *Github) GetPerm(c context.Context, user *model.User, owner, name string) (*model.Perm, error)
- func (g *Github) GetRepo(c context.Context, user *model.User, owner, name string) (*model.Repo, error)
- func (g *Github) GetRepos(c context.Context, u *model.User) ([]*model.Repo, error)
- func (g *Github) GetReviews(c context.Context, u *model.User, r *model.Repo, num int) ([]*model.Review, error)
- func (g *Github) GetTeams(c context.Context, user *model.User) ([]*model.Team, error)
- func (g *Github) GetUser(c context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error)
- func (g *Github) GetUserToken(c context.Context, token string) (string, error)
- func (g *Github) RemoveIssueLabels(c context.Context, user *model.User, repo *model.Repo, number int, ...) error
- func (g *Github) SetHook(c context.Context, user *model.User, repo *model.Repo, link string) error
- func (g *Github) SetStatus(c context.Context, u *model.User, r *model.Repo, num, granted, required int) error
- type RequiredPullRequestReviews
- type RequiredStatusChecks
- type Restrictions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateHook ¶
func CreateHook(c context.Context, client *github.Client, owner, name, url string) (*github.Hook, error)
CreateHook is a helper function that creates a post-commit hook for the specified repository.
func DeleteHook ¶
DeleteHook is a helper function that deletes a post-commit hook for the specified repository.
func GetFile ¶
func GetFile(c context.Context, client *github.Client, owner, name, path, ref string) ([]byte, error)
GetFile is a helper function that retrieves a file from GitHub and returns its contents in byte array format.
func GetHook ¶
func GetHook(c context.Context, client *github.Client, owner, name, rawurl string) (*github.Hook, error)
GetHook is a helper function that retrieves a hook by hostname. To do this, it will retrieve a list of all hooks and iterate through the list.
func GetUserRepos ¶
GetUserRepos is a helper function that returns a list of all user repositories. Paginated results are aggregated into a single list.
Types ¶
type Branch ¶
type Branch struct { RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"` EnforceAdmins bool `json:"enforce_admins"` RequiredPullRequestReviews *RequiredPullRequestReviews `json:"required_pull_request_reviews"` Restrictions *Restrictions `json:"restrictions"` }
Branch represents a branch, including protection.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the simple HTTP client for the GitHub API.
func NewClientToken ¶
NewClientToken returns a client at the specified url that authenticates all outbound requests with the given token.
func (*Client) GetBranchStatusCheck ¶
func (c *Client) GetBranchStatusCheck(owner, name, branch string) (*RequiredStatusChecks, error)
GetBranchStatusCheck retrives informations about status checks of protected branch from the GitHub API.
func (*Client) PatchBranchStatusCheck ¶
func (c *Client) PatchBranchStatusCheck(owner, name, branch string, in *RequiredStatusChecks) error
PatchBranchStatusCheck update required status checks of protected branchEnabled for GitHub Apps
type DismissalRestrictions ¶
DismissalRestrictions object must have the following keys
type Github ¶
Github provides the available configuration values.
func (*Github) AddIssueLabels ¶
func (g *Github) AddIssueLabels(c context.Context, user *model.User, repo *model.Repo, number int, labels []string) error
AddIssueLabels adds labels to an issue.
func (*Github) GetComments ¶
func (g *Github) GetComments(c context.Context, u *model.User, r *model.Repo, num int) ([]*model.Comment, error)
GetComments retrieves comments from the API.
func (*Github) GetContents ¶
func (g *Github) GetContents(c context.Context, u *model.User, r *model.Repo, path string) ([]byte, error)
GetContents retrieves a file from the API.
func (*Github) GetIssueLabels ¶
func (g *Github) GetIssueLabels(c context.Context, user *model.User, repo *model.Repo, number int) ([]string, error)
GetIssueLabels get all labels of issue
func (*Github) GetMembers ¶
func (g *Github) GetMembers(c context.Context, user *model.User, team string) ([]*model.Member, error)
GetMembers retrieves members from the API.
func (*Github) GetPerm ¶
func (g *Github) GetPerm(c context.Context, user *model.User, owner, name string) (*model.Perm, error)
GetPerm retrieves permissions from the API.
func (*Github) GetRepo ¶
func (g *Github) GetRepo(c context.Context, user *model.User, owner, name string) (*model.Repo, error)
GetRepo retrieves a repository from the API.
func (*Github) GetReviews ¶
func (g *Github) GetReviews(c context.Context, u *model.User, r *model.Repo, num int) ([]*model.Review, error)
GetReviews retrieves reviews from the API.
func (*Github) GetUser ¶
func (g *Github) GetUser(c context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error)
GetUser retrieves the current user from the API.
func (*Github) GetUserToken ¶
GetUserToken retrieves a user token from the API.
func (*Github) RemoveIssueLabels ¶
func (g *Github) RemoveIssueLabels(c context.Context, user *model.User, repo *model.Repo, number int, labels []string) error
RemoveIssueLabels removes labels from an issue.
type RequiredPullRequestReviews ¶
type RequiredPullRequestReviews struct { DismissalRestrictions DismissalRestrictions `json:"dismissal_restrictions"` DismissStaleReviews bool `json:"dismiss_stale_reviews"` RequireCodeOwnerReviews bool `json:"require_code_owner_reviews"` }
RequiredPullRequestReviews pull request review enforcement of protected branchEnabled for GitHub Apps
type RequiredStatusChecks ¶
type RequiredStatusChecks struct { URL string `json:"url"` Strict bool `json:"strict"` Contexts []string `json:"contexts"` ContextsURL string `json:"contexts_url"` }
RequiredStatusChecks status checks of protected branch
type Restrictions ¶
Restrictions restrict who can push to this branch.