{"modulePath":"github.com/cmwright/drone","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\n## Constants\n\n```go\nconst (\n\tDefaultURL   = \"https://github.com\"\n\tDefaultAPI   = \"https://api.github.com\"\n\tDefaultScope = \"repo,repo:status,user:email\"\n)\n```\n\n```go\nconst (\n\tStatusPending = \"pending\"\n\tStatusSuccess = \"success\"\n\tStatusFailure = \"failure\"\n\tStatusError   = \"error\"\n)\n```\n\n```go\nconst (\n\tDescPending = \"this build is pending\"\n\tDescSuccess = \"the build was successful\"\n\tDescFailure = \"the build failed\"\n\tDescError   = \"oops, something went wrong\"\n)\n```\n\n## Functions\n\n```go\nfunc CreateHook(client *github.Client, owner, name, url string) (*github.Hook, error)\n```\nCreateHook is a heper function that creates a post-commit hook for the specified repository.\n\n```go\nfunc CreateKey(client *github.Client, owner, name, title, key string) (*github.Key, error)\n```\nCreateKey is a helper function that creates a deploy key for the specified repository.\n\n```go\nfunc CreateUpdateHook(client *github.Client, owner, name, url string) (*github.Hook, error)\n```\nCreateUpdateHook 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\n\n```go\nfunc CreateUpdateKey(client *github.Client, owner, name, title, key string) (*github.Key, error)\n```\nCreateUpdateKey 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\n\n```go\nfunc DeleteHook(client *github.Client, owner, name, url string) error\n```\n\n```go\nfunc DeleteKey(client *github.Client, owner, name, title string) error\n```\nDeleteKey is a helper function that deletes a deploy key for the specified repository.\n\n```go\nfunc GetAllRepos(client *github.Client) ([]github.Repository, error)\n```\nGetAllRepos is a helper function that returns an aggregated list of all user and organization repositories.\n\n```go\nfunc GetFile(client *github.Client, owner, name, path, ref string) ([]byte, error)\n```\nGetFile is a heper function that retrieves a file from GitHub and returns its contents in byte array format.\n\n```go\nfunc GetHook(client *github.Client, owner, name, url string) (*github.Hook, error)\n```\nGetHook 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.\n\n```go\nfunc GetKey(client *github.Client, owner, name, title string) (*github.Key, error)\n```\nGetKey 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.\n\n```go\nfunc GetKeyTitle(rawurl string) (string, error)\n```\nGetKeyTitle is a helper function that generates a title for the RSA public key based on the username and domain name.\n\n```go\nfunc GetOrgRepos(client *github.Client, org string) ([]github.Repository, error)\n```\nGetOrgRepos is a helper function that returns a list of all org repositories. Paginated results are aggregated into a single list.\n\n```go\nfunc GetOrgs(client *github.Client) ([]github.Organization, error)\n```\nGetOrgs is a helper function that returns a list of all orgs that a user belongs to.\n\n```go\nfunc GetPayload(req *http.Request) []byte\n```\nGetPayload 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.\n\n```go\nfunc GetRandom() string\n```\nGetRandom is a helper function that generates a 32-bit random key, base32 encoded as a string value.\n\n```go\nfunc GetRepo(client *github.Client, owner, repo string) (*github.Repository, error)\n```\nGetRepo is a helper function that returns a named repo\n\n```go\nfunc GetUserEmail(client *github.Client) (*github.User, error)\n```\nGetUserEmail is a heper function that retrieves the currently authenticated user from GitHub + Email address.\n\n```go\nfunc GetUserRepos(client *github.Client) ([]github.Repository, error)\n```\nGetUserRepos is a helper function that returns a list of all user repositories. Paginated results are aggregated into a single list.\n\n```go\nfunc NewClient(uri, token string, skipVerify bool) *github.Client\n```\nNewClient is a helper function that returns a new GitHub client using the provided OAuth token.\n\n```go\nfunc UserBelongsToOrg(client *github.Client, permittedOrgs []string) (bool, error)\n```\nUserBelongsToOrg returns true if the currently authenticated user is a member of any of the organizations provided.\n\n## Types\n\n```go\ntype Github struct {\n\tURL         string\n\tAPI         string\n\tClient      string\n\tSecret      string\n\tOrgs        []string\n\tOpen        bool\n\tPrivateMode bool\n\tSkipVerify  bool\n\tGitSSH      bool\n}\n```\n\n```go\nfunc Load(env envconfig.Env) *Github\n```\n\n```go\nfunc (g *Github) Activate(u *model.User, r *model.Repo, k *model.Key, link string) error\n```\nActivate activates a repository by creating the post-commit hook and adding the SSH deploy key, if applicable.\n\n```go\nfunc (g *Github) Auth(token, secret string) (string, error)\n```\nAuth authenticates the session and returns the remote user login for the given token and secret\n\n```go\nfunc (g *Github) Deactivate(u *model.User, r *model.Repo, link string) error\n```\nDeactivate removes a repository by removing all the post-commit hooks which are equal to link and removing the SSH deploy key.\n\n```go\nfunc (g *Github) Hook(r *http.Request) (*model.Repo, *model.Build, error)\n```\nHook parses the post-commit hook from the Request body and returns the required data in a standard format.\n\n```go\nfunc (g *Github) Login(res http.ResponseWriter, req *http.Request) (*model.User, bool, error)\n```\nLogin authenticates the session and returns the remote user details.\n\n```go\nfunc (g *Github) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error)\n```\nNetrc returns a .netrc file that can be used to clone private repositories from a remote system.\n\n```go\nfunc (g *Github) Perm(u *model.User, owner, name string) (*model.Perm, error)\n```\nPerm fetches the named repository permissions from the remote system for the specified user.\n\n```go\nfunc (g *Github) Repo(u *model.User, owner, name string) (*model.Repo, error)\n```\nRepo fetches the named repository from the remote system.\n\n```go\nfunc (g *Github) Repos(u *model.User) ([]*model.RepoLite, error)\n```\nRepos fetches a list of repos from the remote system.\n\n```go\nfunc (g *Github) Script(u *model.User, r *model.Repo, b *model.Build) ([]byte, []byte, error)\n```\nScript fetches the build script (.drone.yml) from the remote repository and returns in string format.\n\n```go\nfunc (g *Github) Status(u *model.User, r *model.Repo, b *model.Build, link string) error\n```\nStatus sends the commit status to the remote system. An example would be the GitHub pull request status.\n\n","path":"github.com/cmwright/drone/remote/github","name":"github","synopsis":"","isRedistributable":true}
