Documentation ¶
Index ¶
- type Client
- func (gc *Client) AccessToken() string
- func (gc *Client) CreateBranch(owner, repo, branchName, baseRef string) (string, error)
- func (gc *Client) CreateFile(owner, repo, path, message, branch string, content []byte) (*scm.RepositoryContent, error)
- func (gc *Client) CreateHook(owner, repo, callback string, events []string) error
- func (gc *Client) CreateKey(owner, repo, key, title string) error
- func (gc *Client) CreatePullRequest(owner, repo, baseRef, headRef, title string) error
- func (gc *Client) CreateStatus(owner, repo, ref string, stageID int, stageName, state string) error
- func (gc *Client) GetContents(owner, repo, path, ref string) (*scm.RepositoryContent, bool)
- func (gc *Client) GetDirectoryContent(owner, repo, path, ref string) ([]interface{}, bool)
- func (gc *Client) GetFileContent(owner, repo, path, ref string) ([]byte, bool)
- func (gc *Client) GetHead(owner, repo, branch string) (string, error)
- func (gc *Client) GetRepository(owner, name string) (*scm.Repository, bool)
- func (gc *Client) HookExists(owner, repo, url string) bool
- func (gc *Client) ListRepositories(user string) (repos []*scm.Repository, err error)
- func (gc *Client) Name() string
- func (gc *Client) ParseHook(body []byte, event string) (*scm.Hook, error)
- func (gc *Client) SetAccessToken(token string)
- func (gc *Client) UpdateFile(owner, repo, path, blob, message, branch string, content []byte) (*scm.RepositoryContent, error)
- type PushHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used for making requests to GitHub
func (*Client) AccessToken ¶
AccessToken returns the client's access token
func (*Client) CreateBranch ¶
CreateBranch creates a new branch of the repository from a commit as baseRef
func (*Client) CreateFile ¶
func (gc *Client) CreateFile(owner, repo, path, message, branch string, content []byte) (*scm.RepositoryContent, error)
CreateFile commits a new file to a repository
func (*Client) CreateHook ¶
CreateHook creates a webhook
func (*Client) CreatePullRequest ¶
CreatePullRequest starts a pull request of the changes from headRef to baseRef
func (*Client) CreateStatus ¶
func (*Client) GetContents ¶
func (gc *Client) GetContents(owner, repo, path, ref string) (*scm.RepositoryContent, bool)
GetContents gets the metadata and content of a file from the given commit or branch
func (*Client) GetDirectoryContent ¶
GetDirectoryContents gets the metadata and the contents a directory
func (*Client) GetFileContent ¶
GetFileContent fetches a file from the given commit or branch
func (*Client) GetRepository ¶
func (gc *Client) GetRepository(owner, name string) (*scm.Repository, bool)
GetRepository fetches repository details from GitHub
func (*Client) HookExists ¶
HookExists checks whether a webhook with the given callback already exists
func (*Client) ListRepositories ¶
func (gc *Client) ListRepositories(user string) (repos []*scm.Repository, err error)
ListRepositories lists the repositories accessible by the current user
func (*Client) SetAccessToken ¶
SetAccessToken sets the client's access token
func (*Client) UpdateFile ¶
func (gc *Client) UpdateFile(owner, repo, path, blob, message, branch string, content []byte) (*scm.RepositoryContent, error)
UpdateFile commits diff of a file content from the given blob
type PushHook ¶
type PushHook struct { Ref string `json:"ref"` Deleted bool `json:"deleted"` Head struct { ID string `json:"id"` URL string `json:"url"` Message string `json:"message"` Timestamp string `json:"timestamp"` Author struct { Name string `json:"name"` Email string `json:"name"` Username string `json:"username"` } `json:"author"` Committer struct { Name string `json:"name"` Email string `json:"name"` Username string `json:"username"` } `json:"committer"` } `json:"head_commit"` Sender struct { Login string `json:"login"` Avatar string `json:"avatar_url"` } `json:"sender"` Repo struct { Owner struct { Login string `json:"login"` Name string `json:"name"` } `json:"owner"` Name string `json:"name"` FullName string `json:"full_name"` Language string `json:"language"` Private bool `json:"private"` HTMLURL string `json:"html_url"` CloneURL string `json:"clone_url"` DefaultBranch string `json:"default_branch"` } `json:"repository"` }
PushHook (taken from drone) is used to make github webhooks easily accessible