github

package
v0.2.2-0...-a3a537b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPI   = "https://api.github.com/"
	DefaultURL   = "https://github.com"
	DefaultScope = "repo,repo:status,user:email"
)

Variables

This section is empty.

Functions

func CreateHook

func CreateHook(client *github.Client, owner, name, url string) (*github.Hook, error)

CreateHook is a heper function that creates a post-commit hook for the specified repository.

func CreateKey

func CreateKey(client *github.Client, owner, name, title, key string) (*github.Key, error)

CreateKey is a heper function that creates a deploy key for the specified repository.

func CreateUpdateHook

func CreateUpdateHook(client *github.Client, owner, name, url string) (*github.Hook, error)

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

func CreateUpdateKey(client *github.Client, owner, name, title, key string) (*github.Key, error)

CreateUpdateKey is a heper function that creates a deployment key for the specified repository if it does not already exist, otherwise it updates the existing key

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

func GetFile(client *github.Client, owner, name, path, ref string) ([]byte, error)

GetFile is a heper function that retrieves a file from GitHub and returns its contents in byte array format.

func GetHook

func GetHook(client *github.Client, owner, name, url string) (*github.Hook, error)

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

func GetKey(client *github.Client, owner, name, title string) (*github.Key, error)

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

func GetKeyTitle(rawurl string) (string, error)

GetKeyTitle is a helper function that generates a title for the RSA public key based on the username and domain name.

func GetOrgRepos

func GetOrgRepos(client *github.Client, org string) ([]github.Repository, error)

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

func GetPayload(req *http.Request) []byte

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

func GetUserEmail(client *github.Client) (*github.User, error)

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.

func NewClient

func NewClient(uri, token string, skipVerify bool) *github.Client

NewClient is a helper function that returns a new GitHub client using the provided OAuth token.

func Register

func Register()

Registers the GitHub plugins using the default settings from the config file or environment variables.

func UserBelongsToOrg

func UserBelongsToOrg(client *github.Client, permittedOrgs []string) (bool, error)

UserBelongsToOrg returns true if the currently authenticated user is a member of any of the organizations provided.

Types

type GitHub

type GitHub struct {
	URL        string
	API        string
	Client     string
	Secret     string
	Private    bool
	SkipVerify bool
	Orgs       []string
	Open       bool
}

func New

func New(url, api, client, secret string, private, skipVerify bool, orgs []string, open bool) *GitHub

func NewDefault

func NewDefault(client, secret string, orgs []string, open bool) *GitHub

func (*GitHub) Activate

func (r *GitHub) Activate(user *model.User, repo *model.Repo, link string) error

Activate activates a repository by adding a Post-commit hook and a Public Deploy key, if applicable.

func (*GitHub) Authorize

func (r *GitHub) Authorize(res http.ResponseWriter, req *http.Request) (*model.Login, error)

Authorize handles GitHub API Authorization.

func (*GitHub) GetHost

func (r *GitHub) GetHost() string

GetHost returns the hostname of this remote GitHub instance.

func (*GitHub) GetKind

func (r *GitHub) GetKind() string

GetKind returns the internal identifier of this remote GitHub instane.

func (*GitHub) GetRepos

func (r *GitHub) GetRepos(user *model.User) ([]*model.Repo, error)

GetRepos fetches all repositories that the specified user has access to in the remote system.

func (*GitHub) GetScript

func (r *GitHub) GetScript(user *model.User, repo *model.Repo, hook *model.Hook) ([]byte, error)

GetScript fetches the build script (.drone.yml) from the remote repository and returns in string format.

func (*GitHub) IsEnterprise

func (r *GitHub) IsEnterprise() bool

IsEnterprise returns true if the remote system is an instance of GitHub Enterprise Edition.

func (*GitHub) OpenRegistration

func (r *GitHub) OpenRegistration() bool

func (*GitHub) ParseHook

func (r *GitHub) ParseHook(req *http.Request) (*model.Hook, error)

ParseHook parses the post-commit hook from the Request body and returns the required data in a standard format.

func (*GitHub) ParsePullRequestHook

func (r *GitHub) ParsePullRequestHook(req *http.Request) (*model.Hook, error)

ParsePullRequestHook parses the pull request hook from the Request body and returns the required data in a standard format.

Directories

Path Synopsis
Package oauth supports making OAuth2-authenticated HTTP requests.
Package oauth supports making OAuth2-authenticated HTTP requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL