Documentation ¶
Index ¶
- Constants
- Variables
- type Branch
- type Commit
- type Error
- type Event
- type Events
- type GithubClient
- func (g *GithubClient) Branch(fullname, branch string) (sdk.VCSBranch, error)
- func (g *GithubClient) Branches(fullname string) ([]sdk.VCSBranch, error)
- func (g *GithubClient) Commit(repo, hash string) (sdk.VCSCommit, error)
- func (g *GithubClient) Commits(repo, theBranch, since, until string) ([]sdk.VCSCommit, error)
- func (g *GithubClient) CreateHook(repo, url string) error
- func (g *GithubClient) DeleteHook(repo, url string) error
- func (g *GithubClient) PushEvents(fullname string, dateRef time.Time) ([]sdk.VCSPushEvent, time.Duration, error)
- func (g *GithubClient) RateLimit() error
- func (g *GithubClient) RepoByFullname(fullname string) (sdk.VCSRepo, error)
- func (g *GithubClient) Repos() ([]sdk.VCSRepo, error)
- func (g *GithubClient) SetStatus(event sdk.Event) error
- func (g *GithubClient) User(username string) (User, error)
- type GithubConsumer
- func (g *GithubConsumer) AuthorizeRedirect() (string, string, error)
- func (g *GithubConsumer) AuthorizeToken(state, code string) (string, string, error)
- func (g *GithubConsumer) Data() string
- func (g *GithubConsumer) GetAuthorized(accessToken, accessTokenSecret string) (sdk.RepositoriesManagerClient, error)
- func (g *GithubConsumer) HooksSupported() bool
- func (g *GithubConsumer) PollingSupported() bool
- type Organization
- type Plan
- type Protection
- type RateLimit
- type Repository
- type Timestamp
- type Tree
- type TreeEntry
- type User
Constants ¶
const ( URL = "https://github.com" APIURL = "https://api.github.com" )
Github const
Variables ¶
var ( ErrorRateLimit = &Error{ ID: "rate_limit", Desc: "Rate Limit reached", URI: "https://developer.github.com/v3/#rate-limiting", } ID: "bad_credentials", Desc: "Bad credentials", URI: "https://developer.github.com/v3", } )
Github errors
var ( RateLimitRemaining = 5000 RateLimitReset int )
Github http var
var (
RequestedScope = []string{"user", "repo", "admin:repo_hook", "admin:org_hook"} //https://developer.github.com/v3/oauth/#scopes
)
Github const
Functions ¶
This section is empty.
Types ¶
type Branch ¶
type Branch struct { Name *string `json:"name,omitempty"` Commit *Commit `json:"commit,omitempty"` Protection *Protection `json:"protection,omitempty"` }
Branch represents a repository branch
type Commit ¶
type Commit struct { Sha string `json:"sha"` Commit struct { Author struct { Name string `json:"name"` Email string `json:"email"` Date Timestamp `json:"date"` } `json:"author"` Committer struct { Name string `json:"name"` Email string `json:"email"` Date Timestamp `json:"date"` } `json:"committer"` Message string `json:"message"` Tree struct { Sha string `json:"sha"` URL string `json:"url"` } `json:"tree"` URL string `json:"url"` CommentCount int `json:"comment_count"` } `json:"commit"` URL string `json:"url"` HTMLURL string `json:"html_url"` CommentsURL string `json:"comments_url"` Author struct { Login string `json:"login"` ID int `json:"id"` AvatarURL string `json:"avatar_url"` GravatarID string `json:"gravatar_id"` URL string `json:"url"` HTMLURL string `json:"html_url"` FollowersURL string `json:"followers_url"` FollowingURL string `json:"following_url"` GistsURL string `json:"gists_url"` StarredURL string `json:"starred_url"` SubscriptionsURL string `json:"subscriptions_url"` OrganizationsURL string `json:"organizations_url"` ReposURL string `json:"repos_url"` EventsURL string `json:"events_url"` ReceivedEventsURL string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` } `json:"author"` Committer struct { Login string `json:"login"` ID int `json:"id"` AvatarURL string `json:"avatar_url"` GravatarID string `json:"gravatar_id"` URL string `json:"url"` HTMLURL string `json:"html_url"` FollowersURL string `json:"followers_url"` FollowingURL string `json:"following_url"` GistsURL string `json:"gists_url"` StarredURL string `json:"starred_url"` SubscriptionsURL string `json:"subscriptions_url"` OrganizationsURL string `json:"organizations_url"` ReposURL string `json:"repos_url"` EventsURL string `json:"events_url"` ReceivedEventsURL string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` } `json:"committer"` Parents []struct { Sha string `json:"sha"` URL string `json:"url"` HTMLURL string `json:"html_url"` } `json:"parents"` Stats struct { Total int `json:"total"` Additions int `json:"additions"` Deletions int `json:"deletions"` } `json:"stats"` Files []struct { Sha string `json:"sha"` Filename string `json:"filename"` Status string `json:"status"` Additions int `json:"additions"` Deletions int `json:"deletions"` Changes int `json:"changes"` BlobURL string `json:"blob_url"` RawURL string `json:"raw_url"` ContentsURL string `json:"contents_url"` Patch string `json:"patch"` } `json:"files"` }
Commit represents a GitHub commit.
type Error ¶
type Error struct { ID string `json:"error"` Desc string `json:"error_description"` URI string `json:"error_uri"` }
Error wraps github error format
type Event ¶
type Event struct { ID string `json:"id"` Type string `json:"type"` Actor struct { ID int `json:"id"` Login string `json:"login"` DisplayLogin string `json:"display_login"` GravatarID string `json:"gravatar_id"` URL string `json:"url"` AvatarURL string `json:"avatar_url"` } `json:"actor"` Repo struct { ID int `json:"id"` Name string `json:"name"` URL string `json:"url"` } `json:"repo"` Payload struct { PushID int `json:"push_id"` Size int `json:"size"` DistinctSize int `json:"distinct_size"` Ref string `json:"ref"` Head string `json:"head"` Before string `json:"before"` Commits []struct { Sha string `json:"sha"` Author struct { Email string `json:"email"` Name string `json:"name"` } `json:"author"` Message string `json:"message"` Distinct bool `json:"distinct"` URL string `json:"url"` } `json:"commits"` } `json:"payload"` Public bool `json:"public"` CreatedAt Timestamp `json:"created_at"` Org struct { ID int `json:"id"` Login string `json:"login"` GravatarID string `json:"gravatar_id"` URL string `json:"url"` AvatarURL string `json:"avatar_url"` } `json:"org"` }
Event represent a repository event
type GithubClient ¶
GithubClient is a github.com wrapper for CDS RepositoriesManagerClient interface
func (*GithubClient) Branch ¶
func (g *GithubClient) Branch(fullname, branch string) (sdk.VCSBranch, error)
Branch returns only detail of a branch
func (*GithubClient) Branches ¶
func (g *GithubClient) Branches(fullname string) ([]sdk.VCSBranch, error)
Branches returns list of branches for a repo https://developer.github.com/v3/repos/branches/#list-branches
func (*GithubClient) Commit ¶
func (g *GithubClient) Commit(repo, hash string) (sdk.VCSCommit, error)
Commit Get a single commit https://developer.github.com/v3/repos/commits/#get-a-single-commit
func (*GithubClient) Commits ¶
func (g *GithubClient) Commits(repo, theBranch, since, until string) ([]sdk.VCSCommit, error)
Commits returns the commits list on a branch between a commit SHA (since) until anotger commit SHA (until). The branch is given by the branch of the first commit SHA (since)
func (*GithubClient) CreateHook ¶
func (g *GithubClient) CreateHook(repo, url string) error
CreateHook is not implemented
func (*GithubClient) DeleteHook ¶
func (g *GithubClient) DeleteHook(repo, url string) error
DeleteHook is not implemented
func (*GithubClient) PushEvents ¶
func (g *GithubClient) PushEvents(fullname string, dateRef time.Time) ([]sdk.VCSPushEvent, time.Duration, error)
PushEvents returns push events as commits
func (*GithubClient) RateLimit ¶
func (g *GithubClient) RateLimit() error
RateLimit Get your current rate limit status https://developer.github.com/v3/rate_limit/#get-your-current-rate-limit-status
func (*GithubClient) RepoByFullname ¶
func (g *GithubClient) RepoByFullname(fullname string) (sdk.VCSRepo, error)
RepoByFullname Get only one repo https://developer.github.com/v3/repos/#list-your-repositories
func (*GithubClient) Repos ¶
func (g *GithubClient) Repos() ([]sdk.VCSRepo, error)
Repos list repositories that are accessible to the authenticated user https://developer.github.com/v3/repos/#list-your-repositories
func (*GithubClient) SetStatus ¶ added in v0.4.0
func (g *GithubClient) SetStatus(event sdk.Event) error
SetStatus set build status on github
func (*GithubClient) User ¶
func (g *GithubClient) User(username string) (User, error)
User Get a single user https://developer.github.com/v3/users/#get-a-single-user
type GithubConsumer ¶
type GithubConsumer struct { ClientID string `json:"client-id"` ClientSecret string `json:"client-secret"` AuthorizationCallbackURL string `json:"-"` WithHooks bool `json:"with-hooks"` WithPolling bool `json:"with-polling"` }
GithubConsumer embeds a github oauth2 consumer
func New ¶
func New(ClientID, ClientSecret, AuthorizationCallbackURL string) *GithubConsumer
New creates a new GithubConsumer
func (*GithubConsumer) AuthorizeRedirect ¶
func (g *GithubConsumer) AuthorizeRedirect() (string, string, error)
AuthorizeRedirect returns the request token, the Authorize URL doc: https://developer.github.com/v3/oauth/#web-application-flow
func (*GithubConsumer) AuthorizeToken ¶
func (g *GithubConsumer) AuthorizeToken(state, code string) (string, string, error)
AuthorizeToken returns the authorized token (and its secret) from the request token and the verifier got on authorize url
func (*GithubConsumer) Data ¶
func (g *GithubConsumer) Data() string
Data returns a serilized version of specific data
func (*GithubConsumer) GetAuthorized ¶
func (g *GithubConsumer) GetAuthorized(accessToken, accessTokenSecret string) (sdk.RepositoriesManagerClient, error)
GetAuthorized returns an authorized client
func (*GithubConsumer) HooksSupported ¶
func (g *GithubConsumer) HooksSupported() bool
HooksSupported returns true if the driver technically support hook
func (*GithubConsumer) PollingSupported ¶
func (g *GithubConsumer) PollingSupported() bool
PollingSupported returns true if the driver technically support polling
type Organization ¶
type Organization struct { Login *string `json:"login,omitempty"` ID *int `json:"id,omitempty"` AvatarURL *string `json:"avatar_url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` Name *string `json:"name,omitempty"` Company *string `json:"company,omitempty"` Blog *string `json:"blog,omitempty"` Location *string `json:"location,omitempty"` Email *string `json:"email,omitempty"` Description *string `json:"description,omitempty"` PublicRepos *int `json:"public_repos,omitempty"` PublicGists *int `json:"public_gists,omitempty"` Followers *int `json:"followers,omitempty"` Following *int `json:"following,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` TotalPrivateRepos *int `json:"total_private_repos,omitempty"` OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"` PrivateGists *int `json:"private_gists,omitempty"` DiskUsage *int `json:"disk_usage,omitempty"` Collaborators *int `json:"collaborators,omitempty"` BillingEmail *string `json:"billing_email,omitempty"` Type *string `json:"type,omitempty"` Plan *Plan `json:"plan,omitempty"` URL *string `json:"url,omitempty"` EventsURL *string `json:"events_url,omitempty"` HooksURL *string `json:"hooks_url,omitempty"` IssuesURL *string `json:"issues_url,omitempty"` MembersURL *string `json:"members_url,omitempty"` PublicMembersURL *string `json:"public_members_url,omitempty"` ReposURL *string `json:"repos_url,omitempty"` }
Organization represents a GitHub organization account.
type Plan ¶
type Plan struct { Name *string `json:"name,omitempty"` Space *int `json:"space,omitempty"` Collaborators *int `json:"collaborators,omitempty"` PrivateRepos *int `json:"private_repos,omitempty"` }
Plan represents the payment plan for an account. See plans at https://github.com/plans.
type Protection ¶
type Protection struct {
Enabled *bool `json:"enabled,omitempty"`
}
Protection represents a repository branch's protection
type RateLimit ¶
type RateLimit struct { Resources struct { Core struct { Limit int `json:"limit"` Remaining int `json:"remaining"` Reset int `json:"reset"` } `json:"core"` Search struct { Limit int `json:"limit"` Remaining int `json:"remaining"` Reset int `json:"reset"` } `json:"search"` } `json:"resources"` Rate struct { Limit int `json:"limit"` Remaining int `json:"remaining"` Reset int `json:"reset"` } `json:"rate"` }
RateLimit represents Rate Limit API
type Repository ¶
type Repository struct { ID *int `json:"id,omitempty"` Owner *User `json:"owner,omitempty"` Name *string `json:"name,omitempty"` FullName *string `json:"full_name,omitempty"` Description *string `json:"description,omitempty"` Homepage *string `json:"homepage,omitempty"` DefaultBranch *string `json:"default_branch,omitempty"` MasterBranch *string `json:"master_branch,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` PushedAt *Timestamp `json:"pushed_at,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` HTMLURL *string `json:"html_url,omitempty"` CloneURL *string `json:"clone_url,omitempty"` GitURL *string `json:"git_url,omitempty"` MirrorURL *string `json:"mirror_url,omitempty"` SSHURL *string `json:"ssh_url,omitempty"` SVNURL *string `json:"svn_url,omitempty"` Language *string `json:"language,omitempty"` Fork *bool `json:"fork"` ForksCount *int `json:"forks_count,omitempty"` NetworkCount *int `json:"network_count,omitempty"` OpenIssuesCount *int `json:"open_issues_count,omitempty"` StargazersCount *int `json:"stargazers_count,omitempty"` SubscribersCount *int `json:"subscribers_count,omitempty"` WatchersCount *int `json:"watchers_count,omitempty"` Size *int `json:"size,omitempty"` AutoInit *bool `json:"auto_init,omitempty"` Parent *Repository `json:"parent,omitempty"` Source *Repository `json:"source,omitempty"` Organization *Organization `json:"organization,omitempty"` Permissions *map[string]bool `json:"permissions,omitempty"` URL *string `json:"url,omitempty"` ArchiveURL *string `json:"archive_url,omitempty"` AssigneesURL *string `json:"assignees_url,omitempty"` BlobsURL *string `json:"blobs_url,omitempty"` BranchesURL *string `json:"branches_url,omitempty"` CollaboratorsURL *string `json:"collaborators_url,omitempty"` CommentsURL *string `json:"comments_url,omitempty"` CommitsURL *string `json:"commits_url,omitempty"` CompareURL *string `json:"compare_url,omitempty"` ContentsURL *string `json:"contents_url,omitempty"` ContributorsURL *string `json:"contributors_url,omitempty"` DeploymentsURL *string `json:"deployments_url,omitempty"` DownloadsURL *string `json:"downloads_url,omitempty"` EventsURL *string `json:"events_url,omitempty"` ForksURL *string `json:"forks_url,omitempty"` GitCommitsURL *string `json:"git_commits_url,omitempty"` GitRefsURL *string `json:"git_refs_url,omitempty"` GitTagsURL *string `json:"git_tags_url,omitempty"` HooksURL *string `json:"hooks_url,omitempty"` IssueCommentURL *string `json:"issue_comment_url,omitempty"` IssueEventsURL *string `json:"issue_events_url,omitempty"` IssuesURL *string `json:"issues_url,omitempty"` KeysURL *string `json:"keys_url,omitempty"` LabelsURL *string `json:"labels_url,omitempty"` LanguagesURL *string `json:"languages_url,omitempty"` MergesURL *string `json:"merges_url,omitempty"` MilestonesURL *string `json:"milestones_url,omitempty"` NotificationsURL *string `json:"notifications_url,omitempty"` PullsURL *string `json:"pulls_url,omitempty"` ReleasesURL *string `json:"releases_url,omitempty"` StargazersURL *string `json:"stargazers_url,omitempty"` StatusesURL *string `json:"statuses_url,omitempty"` SubscribersURL *string `json:"subscribers_url,omitempty"` SubscriptionURL *string `json:"subscription_url,omitempty"` TagsURL *string `json:"tags_url,omitempty"` TreesURL *string `json:"trees_url,omitempty"` TeamsURL *string `json:"teams_url,omitempty"` }
Repository represents a GitHub repository.
type Timestamp ¶
Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. This is necessary for some fields since the GitHub API is inconsistent in how it represents times. All exported methods of time.Time can be called on Timestamp.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.
type TreeEntry ¶
type TreeEntry struct { SHA *string `json:"sha,omitempty"` Path *string `json:"path,omitempty"` Mode *string `json:"mode,omitempty"` Type *string `json:"type,omitempty"` Size *int `json:"size,omitempty"` Content *string `json:"content,omitempty"` }
TreeEntry represents the contents of a tree structure. TreeEntry can represent either a blob, a commit (in the case of a submodule), or another tree.
type User ¶
type User struct { Login *string `json:"login,omitempty"` ID *int `json:"id,omitempty"` AvatarURL *string `json:"avatar_url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` GravatarID *string `json:"gravatar_id,omitempty"` Name *string `json:"name,omitempty"` Company *string `json:"company,omitempty"` Blog *string `json:"blog,omitempty"` Location *string `json:"location,omitempty"` Email *string `json:"email,omitempty"` Hireable *bool `json:"hireable,omitempty"` Bio *string `json:"bio,omitempty"` PublicRepos *int `json:"public_repos,omitempty"` PublicGists *int `json:"public_gists,omitempty"` Followers *int `json:"followers,omitempty"` Following *int `json:"following,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` SuspendedAt *Timestamp `json:"suspended_at,omitempty"` Type *string `json:"type,omitempty"` SiteAdmin *bool `json:"site_admin,omitempty"` TotalPrivateRepos *int `json:"total_private_repos,omitempty"` OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"` PrivateGists *int `json:"private_gists,omitempty"` DiskUsage *int `json:"disk_usage,omitempty"` Collaborators *int `json:"collaborators,omitempty"` Plan *Plan `json:"plan,omitempty"` URL *string `json:"url,omitempty"` EventsURL *string `json:"events_url,omitempty"` FollowingURL *string `json:"following_url,omitempty"` FollowersURL *string `json:"followers_url,omitempty"` GistsURL *string `json:"gists_url,omitempty"` OrganizationsURL *string `json:"organizations_url,omitempty"` ReceivedEventsURL *string `json:"received_events_url,omitempty"` ReposURL *string `json:"repos_url,omitempty"` StarredURL *string `json:"starred_url,omitempty"` SubscriptionsURL *string `json:"subscriptions_url,omitempty"` }
User represents a GitHub user.