{"modulePath":"github.com/nsigarora/drone","version":"v0.3.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\n## Constants\n\n```go\nconst (\n\tDefaultAPI   = \"https://api.github.com/\"\n\tDefaultURL   = \"https://github.com\"\n\tDefaultScope = \"repo,repo:status,user:email\"\n)\n```\n\n## Functions\n\n```go\nfunc CreateHook(client *github.Client, owner, name, url string) (*github.Hook, error)\n```\nCreateHook is a helper 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 helper 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, key 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 helper 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 helper 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 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.\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 GetUserEmail(client *github.Client) (*github.User, error)\n```\nGetUserEmail is a helper 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 Register()\n```\nRegisters the GitHub plugins using the default settings from the config file or environment variables.\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\tPrivate    bool\n\tSkipVerify bool\n\tOrgs       []string\n\tOpen       bool\n}\n```\n\n```go\nfunc New(url, api, client, secret string, private, skipVerify bool, orgs []string, open bool) *GitHub\n```\n\n```go\nfunc NewDefault(client, secret string, orgs []string, open bool) *GitHub\n```\n\n```go\nfunc (r *GitHub) Activate(user *model.User, repo *model.Repo, link string) error\n```\nActivate activates a repository by adding a Post-commit hook and a Public Deploy key, if applicable.\n\n```go\nfunc (r *GitHub) Authorize(res http.ResponseWriter, req *http.Request) (*model.Login, error)\n```\nAuthorize handles GitHub API Authorization.\n\n```go\nfunc (r *GitHub) Deactivate(user *model.User, repo *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 (r *GitHub) GetHost() string\n```\nGetHost returns the hostname of this remote GitHub instance.\n\n```go\nfunc (r *GitHub) GetKind() string\n```\nGetKind returns the internal identifier of this remote GitHub instane.\n\n```go\nfunc (r *GitHub) GetRepos(user *model.User) ([]*model.Repo, error)\n```\nGetRepos fetches all repositories that the specified user has access to in the remote system.\n\n```go\nfunc (r *GitHub) GetScript(user *model.User, repo *model.Repo, hook *model.Hook) ([]byte, error)\n```\nGetScript fetches the build script (.drone.yml) from the remote repository and returns in string format.\n\n```go\nfunc (r *GitHub) GetToken(user *model.User) (*model.Token, error)\n```\n\n```go\nfunc (r *GitHub) IsEnterprise() bool\n```\nIsEnterprise returns true if the remote system is an instance of GitHub Enterprise Edition.\n\n```go\nfunc (r *GitHub) OpenRegistration() bool\n```\n\n```go\nfunc (r *GitHub) ParseHook(req *http.Request) (*model.Hook, error)\n```\nParseHook parses the post-commit hook from the Request body and returns the required data in a standard format.\n\n```go\nfunc (r *GitHub) ParsePullRequestHook(req *http.Request) (*model.Hook, error)\n```\nParsePullRequestHook parses the pull request hook from the Request body and returns the required data in a standard format.\n\n","path":"github.com/nsigarora/drone/plugin/remote/github","name":"github","synopsis":"","isRedistributable":true}
