github

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

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

func DeleteHook(c context.Context, client *github.Client, owner, name, url string) error

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

func GetUserRepos(c context.Context, client *github.Client) ([]*github.Repository, error)

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 NewClient

func NewClient(uri string) *Client

NewClient returns a client at the specified url.

func NewClientToken

func NewClientToken(uri, token string) *Client

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

func (*Client) SetClient

func (c *Client) SetClient(client *http.Client)

SetClient sets the default http client. This should be used in conjunction with golang.org/x/oauth2 to authenticate requests to the server.

func (*Client) UpdateBranch

func (c *Client) UpdateBranch(owner, name, branch string, in *Branch) error

UpdateBranch enables the branch protection for a specific branch.

type DismissalRestrictions

type DismissalRestrictions struct {
	Users []string `json:"users"`
	Teams []string `json:"teams"`
}

DismissalRestrictions object must have the following keys

type Error

type Error struct {
	Message string `json:"message"`
}

Error represents an API error.

func (Error) Error

func (e Error) Error() string

func (Error) String

func (e Error) String() string

type Github

type Github struct {
	URL    string
	API    string
	Client string
	Secret string
	Scopes []string
}

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) DelHook

func (g *Github) DelHook(c context.Context, user *model.User, repo *model.Repo, link string) error

DelHook removes a webhook through the API.

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) GetHook

func (g *Github) GetHook(c context.Context, r *http.Request) (*model.Hook, error)

GetHook gets a webhook 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) GetRepos

func (g *Github) GetRepos(c context.Context, u *model.User) ([]*model.Repo, error)

GetRepos retrieves repositories 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) GetTeams

func (g *Github) GetTeams(c context.Context, user *model.User) ([]*model.Team, error)

GetTeams retrieves teams 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

func (g *Github) GetUserToken(c context.Context, token string) (string, error)

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.

func (*Github) SetHook

func (g *Github) SetHook(c context.Context, user *model.User, repo *model.Repo, link string) error

SetHook injects a webhook through the API.

func (*Github) SetStatus

func (g *Github) SetStatus(c context.Context, u *model.User, r *model.Repo, num, granted, required int) error

SetStatus sets the pull request status through the API.

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

type Restrictions struct {
	Users []string `json:"users"`
	Teams []string `json:"teams"`
}

Restrictions restrict who can push to this branch.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL