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 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 GetRepo(client *github.Client, owner, repo string) (*github.Repository, error)
- 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 UserBelongsToOrg(client *github.Client, permittedOrgs []string) (bool, error)
- type Github
- func (g *Github) Activate(u *model.User, r *model.Repo, k *model.Key, link string) error
- func (g *Github) Auth(token, secret string) (string, error)
- func (g *Github) Deactivate(u *model.User, r *model.Repo, link string) error
- func (g *Github) File(u *model.User, r *model.Repo, b *model.Build, f string) ([]byte, error)
- func (g *Github) Hook(r *http.Request) (*model.Repo, *model.Build, error)
- func (g *Github) Login(res http.ResponseWriter, req *http.Request) (*model.User, bool, error)
- func (g *Github) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error)
- func (g *Github) Perm(u *model.User, owner, name string) (*model.Perm, error)
- func (g *Github) Repo(u *model.User, owner, name string) (*model.Repo, error)
- func (g *Github) Repos(u *model.User) ([]*model.RepoLite, error)
- func (g *Github) Status(u *model.User, r *model.Repo, b *model.Build, link string) error
- func (g *Github) String() string
Constants ¶
const ( DefaultURL = "https://github.com" DefaultAPI = "https://api.github.com" DefaultScope = "repo,repo:status,user:email" DefaultMergeRef = "merge" )
const ( StatusPending = "pending" StatusSuccess = "success" StatusFailure = "failure" StatusError = "error" )
const ( DescPending = "this build is pending" DescSuccess = "the build was successful" DescFailure = "the build failed" DescError = "oops, something went wrong" )
Variables ¶
This section is empty.
Functions ¶
func CreateHook ¶
CreateHook is a heper 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 heper 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 heper function that retrieves a file from GitHub and returns its contents in byte array format.
func GetHook ¶
GetHook is a heper 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 heper 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 heper 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.
Types ¶
type Github ¶
type Github struct { URL string API string Client string Secret string Scope string MergeRef string Orgs []string Open bool PrivateMode bool SkipVerify bool GitSSH bool }
func (*Github) Activate ¶
Activate activates a repository by creating the post-commit hook and adding the SSH deploy key, if applicable.
func (*Github) Auth ¶
Auth authenticates the session and returns the remote user login for the given token and secret
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) File ¶ added in v0.4.2
File fetches a file from the remote repository and returns in string format.
func (*Github) Hook ¶
Hook parses the post-commit hook from the Request body and returns the required data in a standard format.
func (*Github) Netrc ¶
Netrc returns a .netrc file that can be used to clone private repositories from a remote system.
func (*Github) Perm ¶
Perm fetches the named repository permissions from the remote system for the specified user.