Documentation ¶
Index ¶
- Constants
- func CreateHook(client *github.Client, owner, name, url string) (*github.Hook, error)
- func CreateKey(client *github.Client, owner, name, title, key string) (*github.Key, error)
- func CreateUpdateHook(client *github.Client, owner, name, url string) (*github.Hook, error)
- func CreateUpdateKey(client *github.Client, owner, name, title, key string) (*github.Key, error)
- func DeleteHook(client *github.Client, owner, name, url string) error
- func DeleteKey(client *github.Client, owner, name, title, key string) error
- func GetAllRepos(client *github.Client) ([]github.Repository, error)
- func GetFile(client *github.Client, owner, name, path, ref string) ([]byte, error)
- func GetHook(client *github.Client, owner, name, url string) (*github.Hook, error)
- func GetKey(client *github.Client, owner, name, title string) (*github.Key, error)
- func GetKeyTitle(rawurl string) (string, error)
- func GetOrgRepos(client *github.Client, org string) ([]github.Repository, error)
- func GetOrgs(client *github.Client) ([]github.Organization, error)
- func GetPayload(req *http.Request) []byte
- func GetRandom() string
- func GetUserEmail(client *github.Client) (*github.User, error)
- func GetUserRepos(client *github.Client) ([]github.Repository, error)
- func NewClient(uri, token string, skipVerify bool) *github.Client
- func Register()
- func UserBelongsToOrg(client *github.Client, permittedOrgs []string) (bool, error)
- type GitHub
- func (r *GitHub) Activate(user *model.User, repo *model.Repo, link string) error
- func (r *GitHub) Authorize(res http.ResponseWriter, req *http.Request) (*model.Login, error)
- func (r *GitHub) Deactivate(user *model.User, repo *model.Repo, link string) error
- func (r *GitHub) GetHost() string
- func (r *GitHub) GetKind() string
- func (r *GitHub) GetRepos(user *model.User) ([]*model.Repo, error)
- func (r *GitHub) GetScript(user *model.User, repo *model.Repo, hook *model.Hook) ([]byte, error)
- func (r *GitHub) GetToken(user *model.User) (*model.Token, error)
- func (r *GitHub) IsEnterprise() bool
- func (r *GitHub) OpenRegistration() bool
- func (r *GitHub) ParseHook(req *http.Request) (*model.Hook, error)
- func (r *GitHub) ParsePullRequestHook(req *http.Request) (*model.Hook, error)
Constants ¶
const ( DefaultAPI = "https://api.github.com/" DefaultURL = "https://github.com" DefaultScope = "repo,repo:status,user:email" )
Variables ¶
This section is empty.
Functions ¶
func CreateHook ¶
CreateHook is a helper function that creates a post-commit hook for the specified repository.
func CreateKey ¶
CreateKey is a helper function that creates a deploy key for the specified repository.
func CreateUpdateHook ¶
CreateUpdateHook is a helper function that creates a post-commit hook for the specified repository if it does not already exist, otherwise it updates the existing hook
func CreateUpdateKey ¶
CreateUpdateKey is a helper function that creates a deployment key for the specified repository if it does not already exist, otherwise it updates the existing key
func DeleteKey ¶
DeleteKey is a helper function that deletes a deploy key for the specified repository.
func GetAllRepos ¶
func GetAllRepos(client *github.Client) ([]github.Repository, error)
GetAllRepos is a helper function that returns an aggregated list of all user and organization repositories.
func GetFile ¶
GetFile is a helper function that retrieves a file from GitHub and returns its contents in byte array format.
func GetHook ¶
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 GetKey ¶
GetKey is a helper function that retrieves a public Key by title. To do this, it will retrieve a list of all keys and iterate through the list.
func GetKeyTitle ¶
GetKeyTitle is a helper function that generates a title for the RSA public key based on the username and domain name.
func GetOrgRepos ¶
GetOrgRepos is a helper function that returns a list of all org repositories. Paginated results are aggregated into a single list.
func GetOrgs ¶
func GetOrgs(client *github.Client) ([]github.Organization, error)
GetOrgs is a helper function that returns a list of all orgs that a user belongs to.
func GetPayload ¶
GetPayload is a helper function that will parse the JSON payload. It will first check for a `payload` parameter in a POST, but can fallback to a raw JSON body as well.
func GetRandom ¶
func GetRandom() string
GetRandom is a helper function that generates a 32-bit random key, base32 encoded as a string value.
func GetUserEmail ¶
GetUserEmail is a helper function that retrieves the currently authenticated user from GitHub + Email address.
func GetUserRepos ¶
func GetUserRepos(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.
func NewClient ¶
NewClient is a helper function that returns a new GitHub client using the provided OAuth token.
Types ¶
type GitHub ¶
type GitHub struct { URL string API string Client string Secret string Private bool SkipVerify bool Orgs []string Open bool }
func (*GitHub) Activate ¶
Activate activates a repository by adding a Post-commit hook and a Public Deploy key, if applicable.
func (*GitHub) Deactivate ¶
Deactivate removes a repository by removing all the post-commit hooks which are equal to link and removing the SSH deploy key.
func (*GitHub) GetRepos ¶
GetRepos fetches all repositories that the specified user has access to in the remote system.
func (*GitHub) GetScript ¶
GetScript fetches the build script (.drone.yml) from the remote repository and returns in string format.
func (*GitHub) IsEnterprise ¶
IsEnterprise returns true if the remote system is an instance of GitHub Enterprise Edition.