github

package
v0.0.0-...-28799ed Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

README

DOCUMENTATION DEPRECATION NOTICE: This file is deprecated. Please refer to the new migrated location. Please do not edit this file; instead, make changes to the new location!

The new location is served on the web at https://docs.prow.k8s.io/docs/.

This file will be deleted on 2023-02-28.

Documentation

Index

Constants

View Source
const (

	// MaxRequestTime aborts requests that don't return in 5 mins. Longest graphql
	// calls can take up to 2 minutes. This limit should ensure all successful calls
	// return but will prevent an indefinite stall if GitHub never responds.
	MaxRequestTime = 5 * time.Minute

	DefaultMaxRetries    = 8
	DefaultMax404Retries = 2
	DefaultMaxSleepTime  = 2 * time.Minute
	DefaultInitialDelay  = 2 * time.Second
)
View Source
const (
	// EventGUID is sent by GitHub in a header of every webhook request.
	// Used as a log field across prow.
	EventGUID = "event-GUID"
	// PrLogField is the number of a PR.
	// Used as a log field across prow.
	PrLogField = "pr"
	// OrgLogField is the organization of a PR.
	// Used as a log field across prow.
	OrgLogField = "org"
	// RepoLogField is the repository of a PR.
	// Used as a log field across prow.
	RepoLogField = "repo"

	// SearchTimeFormat is a time.Time format string for ISO8601 which is the
	// format that GitHub requires for times specified as part of a search query.
	SearchTimeFormat = "2006-01-02T15:04:05Z"

	// DefaultAPIEndpoint is the default GitHub API endpoint.
	DefaultAPIEndpoint = "https://api.github.com"

	// DefaultHost is the default GitHub base endpoint.
	DefaultHost = "github.com"

	// DefaultGraphQLEndpoint is the default GitHub GraphQL API endpoint.
	DefaultGraphQLEndpoint = "https://api.github.com/graphql"
)
View Source
const (
	StatusPending = "pending"
	StatusSuccess = "success"
	StatusError   = "error"
	StatusFailure = "failure"
)

These are possible State entries for a Status.

View Source
const (
	ReactionThumbsUp   = "+1"
	ReactionThumbsDown = "-1"
	ReactionLaugh      = "laugh"
	ReactionConfused   = "confused"
	ReactionHeart      = "heart"
	ReactionHooray     = "hooray"
)

Possible contents for reactions.

View Source
const (
	// UserTypeUser identifies an actual user account in the User.Type field
	UserTypeUser = "User"
	// UserTypeBot identifies a github app bot user in the User.Type field
	UserTypeBot = "Bot"
)
View Source
const (
	PullRequestStateOpen   = "open"
	PullRequestStateClosed = "closed"
)
View Source
const (
	// PullRequestFileModified means a file changed.
	PullRequestFileModified PullRequestFileStatus = "modified"
	// PullRequestFileAdded means a file was added.
	PullRequestFileAdded = "added"
	// PullRequestFileRemoved means a file was deleted.
	PullRequestFileRemoved = "removed"
	// PullRequestFileRenamed means a file moved.
	PullRequestFileRenamed = "renamed"
)
View Source
const (
	ReviewStateApproved         ReviewState = "APPROVED"
	ReviewStateChangesRequested             = "CHANGES_REQUESTED"
	ReviewStateCommented                    = "COMMENTED"
	ReviewStateDismissed                    = "DISMISSED"
	ReviewStatePending                      = "PENDING"
)

Possible review states.

View Source
const (
	// DiffSideLeft means left side of the diff.
	DiffSideLeft = "LEFT"
	// DiffSideRight means right side of the diff.
	DiffSideRight = "RIGHT"
)
View Source
const (
	Approve        ReviewAction = "APPROVE"
	RequestChanges              = "REQUEST_CHANGES"
	Comment                     = "COMMENT"
)

Possible review actions. Leave Action blank for a pending review.

View Source
const (
	// PrivacySecret memberships are only visible to other team members.
	PrivacySecret = "secret"
	// PrivacyClosed memberships are visible to org members.
	PrivacyClosed = "closed"
)
View Source
const (
	// RoleAll lists both members and admins
	RoleAll = "all"
	// RoleAdmin specifies the user is an org admin, or lists only admins
	RoleAdmin = "admin"
	// RoleMaintainer specifies the user is a team maintainer, or lists only maintainers
	RoleMaintainer = "maintainer"
	// RoleMember specifies the user is a regular user, or only lists regular users
	RoleMember = "member"
	// StatePending specifies the user has an invitation to the org/team.
	StatePending = "pending"
	// StateActive specifies the user's membership is active.
	StateActive = "active"
)
View Source
const ImageSizeLimit = 5242880

ImageSizeLimit is the maximum image size GitHub allows in bytes (5MB).

Variables

View Source
var AllHookEvents = []string{"*"}

AllHookEvents causes github to send all events. https://developer.github.com/v3/activity/events/types/

View Source
var (
	// FoundingYear is the year GitHub was founded. This is just used so that
	// we can lower bound dates related to PRs and issues.
	FoundingYear, _ = time.Parse(SearchTimeFormat, "2007-01-01T00:00:00Z")
)
View Source
var SecurityForkNameRE = regexp.MustCompile(`^[\w-]+-ghsa-[\w-]+$`)

SecurityForkNameRE is a regexp matching repos that are temporary security forks. https://help.github.com/en/github/managing-security-vulnerabilities/collaborating-in-a-temporary-private-fork-to-resolve-a-security-vulnerability

View Source
var TimeNow = func() time.Time {
	return time.Now().UTC()
}

TimeNow is exposed so that it can be mocked by unit test, to ensure that addAppAuth always return consistent token when needed. DO NOT use it in prod

Functions

func HasLabel

func HasLabel(label string, issueLabels []Label) bool

HasLabel checks if label is in the label set "issueLabels".

func HasLabels

func HasLabels(labels []string, issueLabels []Label) bool

HasLabels checks if all labels are in the github.label set "issueLabels".

func ImageTooBig

func ImageTooBig(url string) (bool, error)

ImageTooBig checks if image is bigger than github limits.

func IsNotFound

func IsNotFound(err error) bool

func NewAppsAuthClientWithFields

func NewAppsAuthClientWithFields(fields logrus.Fields, censor func([]byte) []byte, appID string, appPrivateKey func() *rsa.PrivateKey, graphqlEndpoint string, bases ...string) (TokenGenerator, UserGenerator, Client, error)

func NewAppsAuthDryRunClientWithFields

func NewAppsAuthDryRunClientWithFields(fields logrus.Fields, censor func([]byte) []byte, appId string, appPrivateKey func() *rsa.PrivateKey, graphqlEndpoint string, bases ...string) (TokenGenerator, UserGenerator, Client, error)

NewAppsAuthDryRunClientWithFields creates a new client that will not perform mutating actions such as setting statuses or commenting, but it will still query GitHub and use up API tokens. Additional fields are added to the logger.

func NewClientFromOptions

func NewClientFromOptions(fields logrus.Fields, options ClientOptions) (TokenGenerator, UserGenerator, Client, error)

NewClientFromOptions creates a new client from the options we expose. This method should be used over the more-specific ones.

func NewNotFound

func NewNotFound() error

NewNotFound returns a NotFound error which may be useful for tests

func NormLogin

func NormLogin(login string) string

NormLogin normalizes GitHub login strings

func PayloadSignature

func PayloadSignature(payload []byte, key []byte) string

PayloadSignature returns the signature that matches the payload.

func ValidatePayload

func ValidatePayload(payload []byte, sig string, tokenGenerator func() []byte) bool

ValidatePayload ensures that the request payload signature matches the key.

func ValidateWebhook

func ValidateWebhook(w http.ResponseWriter, r *http.Request, tokenGenerator func() []byte) (string, string, []byte, bool, int)

ValidateWebhook ensures that the provided request conforms to the format of a GitHub webhook and the payload can be validated with the provided hmac secret. It returns the event type, the event guid, the payload of the request, whether the webhook is valid or not, and finally the resultant HTTP status code

Types

type AllowDeletions

type AllowDeletions struct {
	Enabled bool `json:"enabled"`
}

AllowDeletions specifies whether to permit users with push access to delete matching branches.

type AllowForcePushes

type AllowForcePushes struct {
	Enabled bool `json:"enabled"`
}

AllowForcePushes specifies whether to permit force pushes for all users with push access.

type AlternativeClientError

type AlternativeClientError struct {
	Message          string   `json:"message"`
	Errors           []string `json:"errors,omitempty"`
	DocumentationURL string   `json:"documentation_url,omitempty"`
}

AlternativeClientError represents an alternative format for https://developer.github.com/v3/#client-errors This is probably a GitHub bug, as documentation_url should appear only in custom errors

func (AlternativeClientError) Error

func (r AlternativeClientError) Error() string

type App

type App struct {
	ID          int64                    `json:"id,omitempty"`
	Slug        string                   `json:"slug,omitempty"`
	NodeID      string                   `json:"node_id,omitempty"`
	Owner       User                     `json:"owner,omitempty"`
	Name        string                   `json:"name,omitempty"`
	Description string                   `json:"description,omitempty"`
	ExternalURL string                   `json:"external_url,omitempty"`
	HTMLURL     string                   `json:"html_url,omitempty"`
	CreatedAt   string                   `json:"created_at,omitempty"`
	UpdatedAt   string                   `json:"updated_at,omitempty"`
	Permissions *InstallationPermissions `json:"permissions,omitempty"`
	Events      []string                 `json:"events,omitempty"`
}

type AppInstallation

type AppInstallation struct {
	ID                  int64                   `json:"id,omitempty"`
	AppSlug             string                  `json:"app_slug,omitempty"`
	NodeID              string                  `json:"node_id,omitempty"`
	AppID               int64                   `json:"app_id,omitempty"`
	TargetID            int64                   `json:"target_id,omitempty"`
	Account             User                    `json:"account,omitempty"`
	AccessTokensURL     string                  `json:"access_tokens_url,omitempty"`
	RepositoriesURL     string                  `json:"repositories_url,omitempty"`
	HTMLURL             string                  `json:"html_url,omitempty"`
	TargetType          string                  `json:"target_type,omitempty"`
	SingleFileName      string                  `json:"single_file_name,omitempty"`
	RepositorySelection string                  `json:"repository_selection,omitempty"`
	Events              []string                `json:"events,omitempty"`
	Permissions         InstallationPermissions `json:"permissions,omitempty"`
	CreatedAt           string                  `json:"created_at,omitempty"`
	UpdatedAt           string                  `json:"updated_at,omitempty"`
}

AppInstallation represents a GitHub Apps installation.

type AppInstallationList

type AppInstallationList struct {
	Total         int               `json:"total_count,omitempty"`
	Installations []AppInstallation `json:"installations,omitempty"`
}

AppInstallationList represents the result of an AppInstallationList search.

type AppInstallationToken

type AppInstallationToken struct {
	Token        string                  `json:"token,omitempty"`
	ExpiresAt    time.Time               `json:"expires_at,omitempty"`
	Permissions  InstallationPermissions `json:"permissions,omitempty"`
	Repositories []Repo                  `json:"repositories,omitempty"`
}

AppInstallationToken is the response when retrieving an app installation token.

type Branch

type Branch struct {
	Name      string `json:"name"`
	Protected bool   `json:"protected"` // only included for ?protection=true requests

}

Branch contains general branch information.

type BranchProtection

type BranchProtection struct {
	RequiredStatusChecks       *RequiredStatusChecks       `json:"required_status_checks"`
	EnforceAdmins              EnforceAdmins               `json:"enforce_admins"`
	RequiredPullRequestReviews *RequiredPullRequestReviews `json:"required_pull_request_reviews"`
	Restrictions               *Restrictions               `json:"restrictions"`
	AllowForcePushes           AllowForcePushes            `json:"allow_force_pushes"`
	RequiredLinearHistory      RequiredLinearHistory       `json:"required_linear_history"`
	AllowDeletions             AllowDeletions              `json:"allow_deletions"`
}

BranchProtection represents protections currently in place for a branch See also: https://developer.github.com/v3/repos/branches/#get-branch-protection

type BranchProtectionRequest

type BranchProtectionRequest struct {
	RequiredStatusChecks       *RequiredStatusChecks              `json:"required_status_checks"`
	EnforceAdmins              *bool                              `json:"enforce_admins"`
	RequiredPullRequestReviews *RequiredPullRequestReviewsRequest `json:"required_pull_request_reviews"`
	Restrictions               *RestrictionsRequest               `json:"restrictions"`
	RequiredLinearHistory      bool                               `json:"required_linear_history"`
	AllowForcePushes           bool                               `json:"allow_force_pushes"`
	AllowDeletions             bool                               `json:"allow_deletions"`
}

BranchProtectionRequest represents protections to put in place for a branch. See also: https://developer.github.com/v3/repos/branches/#update-branch-protection

func (BranchProtectionRequest) String

func (r BranchProtectionRequest) String() string

type BypassRestrictions

type BypassRestrictions struct {
	Users []User `json:"users,omitempty"`
	Teams []Team `json:"teams,omitempty"`
}

BypassRestrictions exposes bypass option in github for a pull request to people/teams.

type BypassRestrictionsRequest

type BypassRestrictionsRequest struct {
	// Users is a list of user logins
	Users *[]string `json:"users,omitempty"`
	// Teams is a list of team slugs
	Teams *[]string `json:"teams,omitempty"`
}

BypassRestrictionsRequest tells github to restrict PR bypass activity to people/teams.

Use *[]string in order to distinguish unset and empty list. This is needed by bypass_pull_request_allowances to distinguish do not restrict (empty object) and restrict everyone (nil user/teams list)

type CheckRun

type CheckRun struct {
	ID           int64          `json:"id,omitempty"`
	NodeID       string         `json:"node_id,omitempty"`
	HeadSHA      string         `json:"head_sha,omitempty"`
	ExternalID   string         `json:"external_id,omitempty"`
	URL          string         `json:"url,omitempty"`
	HTMLURL      string         `json:"html_url,omitempty"`
	DetailsURL   string         `json:"details_url,omitempty"`
	Status       string         `json:"status,omitempty"`
	Conclusion   string         `json:"conclusion,omitempty"`
	StartedAt    string         `json:"started_at,omitempty"`
	CompletedAt  string         `json:"completed_at,omitempty"`
	Output       CheckRunOutput `json:"output,omitempty"`
	Name         string         `json:"name,omitempty"`
	CheckSuite   CheckSuite     `json:"check_suite,omitempty"`
	App          App            `json:"app,omitempty"`
	PullRequests []PullRequest  `json:"pull_requests,omitempty"`
}

type CheckRunAnnotation

type CheckRunAnnotation struct {
	Path            string `json:"path,omitempty"`
	StartLine       int    `json:"start_line,omitempty"`
	EndLine         int    `json:"end_line,omitempty"`
	StartColumn     int    `json:"start_column,omitempty"`
	EndColumn       int    `json:"end_column,omitempty"`
	AnnotationLevel string `json:"annotation_level,omitempty"`
	Message         string `json:"message,omitempty"`
	Title           string `json:"title,omitempty"`
	RawDetails      string `json:"raw_details,omitempty"`
}

type CheckRunImage

type CheckRunImage struct {
	Alt      string `json:"alt,omitempty"`
	ImageURL string `json:"image_url,omitempty"`
	Caption  string `json:"caption,omitempty"`
}

type CheckRunList

type CheckRunList struct {
	Total     int        `json:"total_count,omitempty"`
	CheckRuns []CheckRun `json:"check_runs,omitempty"`
}

type CheckRunOutput

type CheckRunOutput struct {
	Title            string               `json:"title,omitempty"`
	Summary          string               `json:"summary,omitempty"`
	Text             string               `json:"text,omitempty"`
	AnnotationsCount int                  `json:"annotations_count,omitempty"`
	AnnotationsURL   string               `json:"annotations_url,omitempty"`
	Annotations      []CheckRunAnnotation `json:"annotations,omitempty"`
	Images           []CheckRunImage      `json:"images,omitempty"`
}

type CheckSuite

type CheckSuite struct {
	ID           int64         `json:"id,omitempty"`
	NodeID       string        `json:"node_id,omitempty"`
	HeadBranch   string        `json:"head_branch,omitempty"`
	HeadSHA      string        `json:"head_sha,omitempty"`
	URL          string        `json:"url,omitempty"`
	BeforeSHA    string        `json:"before,omitempty"`
	AfterSHA     string        `json:"after,omitempty"`
	Status       string        `json:"status,omitempty"`
	Conclusion   string        `json:"conclusion,omitempty"`
	App          *App          `json:"app,omitempty"`
	Repository   *Repo         `json:"repository,omitempty"`
	PullRequests []PullRequest `json:"pull_requests,omitempty"`

	// The following fields are only populated by Webhook events.
	HeadCommit *Commit `json:"head_commit,omitempty"`
}

type Client

type Client interface {
	PullRequestClient
	RepositoryClient
	CommitClient
	IssueClient
	CommentClient
	OrganizationClient
	TeamClient
	ProjectClient
	MilestoneClient
	UserClient
	HookClient
	ListAppInstallations() ([]AppInstallation, error)
	IsAppInstalled(org, repo string) (bool, error)
	UsesAppAuth() bool
	ListAppInstallationsForOrg(org string) ([]AppInstallation, error)
	GetApp() (*App, error)
	GetAppWithContext(ctx context.Context) (*App, error)
	GetFailedActionRunsByHeadBranch(org, repo, branchName, headSHA string) ([]WorkflowRun, error)

	Throttle(hourlyTokens, burst int, org ...string) error
	QueryWithGitHubAppsSupport(ctx context.Context, q interface{}, vars map[string]interface{}, org string) error
	MutateWithGitHubAppsSupport(ctx context.Context, m interface{}, input githubql.Input, vars map[string]interface{}, org string) error

	SetMax404Retries(int)

	WithFields(fields logrus.Fields) Client
	ForPlugin(plugin string) Client
	ForSubcomponent(subcomponent string) Client
	Used() bool
	TriggerGitHubWorkflow(org, repo string, id int) error
}

Client interface for GitHub API

func NewClient

func NewClient(getToken func() []byte, censor func([]byte) []byte, graphqlEndpoint string, bases ...string) (Client, error)

NewClient creates a new fully operational GitHub client.

func NewClientWithFields

func NewClientWithFields(fields logrus.Fields, getToken func() []byte, censor func([]byte) []byte, graphqlEndpoint string, bases ...string) (Client, error)

NewClientWithFields creates a new fully operational GitHub client. With added logging fields. 'getToken' is a generator for the GitHub access token to use. 'bases' is a variadic slice of endpoints to use in order of preference.

An endpoint is used when all preceding endpoints have returned a conn err.
This should be used when using the ghproxy GitHub proxy cache to allow
this client to bypass the cache if it is temporarily unavailable.

func NewDryRunClient

func NewDryRunClient(getToken func() []byte, censor func([]byte) []byte, graphqlEndpoint string, bases ...string) (Client, error)

NewDryRunClient creates a new client that will not perform mutating actions such as setting statuses or commenting, but it will still query GitHub and use up API tokens. 'getToken' is a generator the GitHub access token to use. 'bases' is a variadic slice of endpoints to use in order of preference.

An endpoint is used when all preceding endpoints have returned a conn err.
This should be used when using the ghproxy GitHub proxy cache to allow
this client to bypass the cache if it is temporarily unavailable.

func NewDryRunClientWithFields

func NewDryRunClientWithFields(fields logrus.Fields, getToken func() []byte, censor func([]byte) []byte, graphqlEndpoint string, bases ...string) (Client, error)

NewDryRunClientWithFields creates a new client that will not perform mutating actions such as setting statuses or commenting, but it will still query GitHub and use up API tokens. Additional fields are added to the logger. 'getToken' is a generator the GitHub access token to use. 'bases' is a variadic slice of endpoints to use in order of preference.

An endpoint is used when all preceding endpoints have returned a conn err.
This should be used when using the ghproxy GitHub proxy cache to allow
this client to bypass the cache if it is temporarily unavailable.

func NewFakeClient

func NewFakeClient() Client

NewFakeClient creates a new client that will not perform any actions at all.

type ClientError

type ClientError struct {
	Message string                `json:"message"`
	Errors  []clientErrorSubError `json:"errors,omitempty"`
}

ClientError represents https://developer.github.com/v3/#client-errors

func (ClientError) Error

func (r ClientError) Error() string

type ClientOptions

type ClientOptions struct {
	// censor knows how to censor output
	Censor func([]byte) []byte

	// the following fields handle auth
	GetToken      func() []byte
	AppID         string
	AppPrivateKey func() *rsa.PrivateKey

	// the following fields determine which server we talk to
	GraphqlEndpoint string
	Bases           []string

	// the following fields determine client retry behavior
	MaxRequestTime, InitialDelay, MaxSleepTime time.Duration
	MaxRetries, Max404Retries                  int

	DryRun bool
	// BaseRoundTripper is the last RoundTripper to be called. Used for testing, gets defaulted to http.DefaultTransport
	BaseRoundTripper http.RoundTripper
}

ClientOptions holds options for creating a new client

func (ClientOptions) Default

func (o ClientOptions) Default() ClientOptions

type CombinedStatus

type CombinedStatus struct {
	SHA      string   `json:"sha"`
	Statuses []Status `json:"statuses"`
	State    string   `json:"state"`
}

CombinedStatus is the latest statuses for a ref.

type CommentClient

type CommentClient interface {
	CreateComment(org, repo string, number int, comment string) error
	CreateCommentWithContext(ctx context.Context, org, repo string, number int, comment string) error
	DeleteComment(org, repo string, id int) error
	DeleteCommentWithContext(ctx context.Context, org, repo string, id int) error
	EditComment(org, repo string, id int, comment string) error
	EditCommentWithContext(ctx context.Context, org, repo string, id int, comment string) error
	CreateCommentReaction(org, repo string, id int, reaction string) error
	DeleteStaleComments(org, repo string, number int, comments []IssueComment, isStale func(IssueComment) bool) error
	DeleteStaleCommentsWithContext(ctx context.Context, org, repo string, number int, comments []IssueComment, isStale func(IssueComment) bool) error
}

CommentClient interface for comment related API actions

type CommentLikeEventTypes

type CommentLikeEventTypes interface {
	IssueEvent | IssueCommentEvent | PullRequestEvent | ReviewEvent | ReviewCommentEvent
}

CommentLikeEventTypes are various event types that can be coerced into a GenericCommentEvent.

type Commit

type Commit struct {
	ID       string   `json:"id"`
	Message  string   `json:"message"`
	Added    []string `json:"added"`
	Removed  []string `json:"removed"`
	Modified []string `json:"modified"`
}

Commit represents general info about a commit.

type CommitAuthor

type CommitAuthor struct {
	Date  time.Time `json:"date,omitempty"`
	Name  string    `json:"name,omitempty"`
	Email string    `json:"email,omitempty"`

	// The following fields are only populated by Webhook events.
	Login *string `json:"username,omitempty"`
}

CommitAuthor represents the author or committer of a commit. The commit author may not correspond to a GitHub User.

type CommitClient

type CommitClient interface {
	CreateStatus(org, repo, SHA string, s Status) error
	CreateStatusWithContext(ctx context.Context, org, repo, SHA string, s Status) error
	ListStatuses(org, repo, ref string) ([]Status, error)
	GetSingleCommit(org, repo, SHA string) (RepositoryCommit, error)
	GetCombinedStatus(org, repo, ref string) (*CombinedStatus, error)
	ListCheckRuns(org, repo, ref string) (*CheckRunList, error)
	GetRef(org, repo, ref string) (string, error)
	DeleteRef(org, repo, ref string) error
	ListFileCommits(org, repo, path string) ([]RepositoryCommit, error)
	CreateCheckRun(org, repo string, checkRun CheckRun) error
}

CommitClient interface for commit related API actions

type CommitFile

type CommitFile struct {
	SHA              string `json:"sha,omitempty"`
	Filename         string `json:"filename,omitempty"`
	Additions        int    `json:"additions,omitempty"`
	Deletions        int    `json:"deletions,omitempty"`
	Changes          int    `json:"changes,omitempty"`
	Status           string `json:"status,omitempty"`
	Patch            string `json:"patch,omitempty"`
	BlobURL          string `json:"blob_url,omitempty"`
	RawURL           string `json:"raw_url,omitempty"`
	ContentsURL      string `json:"contents_url,omitempty"`
	PreviousFilename string `json:"previous_filename,omitempty"`
}

CommitFile represents a file modified in a commit.

type CommitStats

type CommitStats struct {
	Additions int `json:"additions,omitempty"`
	Deletions int `json:"deletions,omitempty"`
	Total     int `json:"total,omitempty"`
}

CommitStats represents the number of additions / deletions from a file in a given RepositoryCommit or GistCommit.

type Content

type Content struct {
	Content string `json:"content"`
	SHA     string `json:"sha"`
}

Content is some base64 encoded github file content It include selected fields available in content record returned by GH "GET" method. See also: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-content

type DiffSide

type DiffSide string

DiffSide enumerates the sides of the diff that the PR's changes appear on. See also: https://docs.github.com/en/rest/reference/pulls#create-a-review-comment-for-a-pull-request

type DirectoryContent

type DirectoryContent struct {
	SHA  string `json:"sha"`
	Type string `json:"type"`
	Name string `json:"name"`
	Path string `json:"path"`
}

DirectoryContent contains information about a github directory. It include selected fields available in content records returned by GH "GET" method. See also: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-content

type DismissalRestrictions

type DismissalRestrictions struct {
	Users []User `json:"users,omitempty"`
	Teams []Team `json:"teams,omitempty"`
}

DismissalRestrictions exposes restrictions in github for an activity to people/teams.

type DismissalRestrictionsRequest

type DismissalRestrictionsRequest struct {
	// Users is a list of user logins
	Users *[]string `json:"users,omitempty"`
	// Teams is a list of team slugs
	Teams *[]string `json:"teams,omitempty"`
}

DismissalRestrictionsRequest tells github to restrict an activity to people/teams.

Use *[]string in order to distinguish unset and empty list. This is needed by dismissal_restrictions to distinguish do not restrict (empty object) and restrict everyone (nil user/teams list)

type DismissedReview

type DismissedReview struct {
	// State represents the state of the dismissed review.DismissedReview
	// Possible values are: "commented", "approved", and "changes_requested".
	State             string `json:"state,omitempty"`
	ReviewID          int64  `json:"review_id,omitempty"`
	DismissalMessage  string `json:"dismissal_message,omitempty"`
	DismissalCommitID string `json:"dismissal_commit_id,omitempty"`
}

DismissedReview represents details for 'dismissed_review' events.

type DraftReview

type DraftReview struct {
	// If unspecified, defaults to the most recent commit in the PR.
	CommitSHA string `json:"commit_id,omitempty"`
	Body      string `json:"body"`
	// If unspecified, defaults to PENDING.
	Action   ReviewAction         `json:"event,omitempty"`
	Comments []DraftReviewComment `json:"comments,omitempty"`
}

DraftReview is what we give GitHub when we want to make a PR Review. This is different than what we receive when we ask for a Review.

type DraftReviewComment

type DraftReviewComment struct {
	Path string `json:"path"`
	// Position in the patch, not the line number in the file.
	Position int    `json:"position"`
	Body     string `json:"body"`
}

DraftReviewComment is a comment in a draft review.

type EnforceAdmins

type EnforceAdmins struct {
	Enabled bool `json:"enabled"`
}

EnforceAdmins specifies whether to enforce the configured branch restrictions for administrators.

type ExtraUsers

type ExtraUsers struct {
	Users []string
	// contains filtered or unexported fields
}

ExtraUsers is an error specifying the users that could not be unassigned.

func (ExtraUsers) Error

func (e ExtraUsers) Error() string

type FileNotFound

type FileNotFound struct {
	// contains filtered or unexported fields
}

FileNotFound happens when github cannot find the file requested by GetFile().

func (*FileNotFound) Error

func (e *FileNotFound) Error() string

type FullRepo

type FullRepo struct {
	Repo

	AllowSquashMerge         bool   `json:"allow_squash_merge,omitempty"`
	AllowMergeCommit         bool   `json:"allow_merge_commit,omitempty"`
	AllowRebaseMerge         bool   `json:"allow_rebase_merge,omitempty"`
	SquashMergeCommitTitle   string `json:"squash_merge_commit_title,omitempty"`
	SquashMergeCommitMessage string `json:"squash_merge_commit_message,omitempty"`
}

Repo contains detailed repository information, including items that are not available in repo records returned by GH "List" methods but are in those returned by GH "Get" method. See https://developer.github.com/v3/repos/#list-organization-repositories See https://developer.github.com/v3/repos/#get

type GenericCommentEvent

type GenericCommentEvent struct {
	ID           int    `json:"id"`
	NodeID       string `json:"node_id"`
	CommentID    *int
	IsPR         bool
	Action       GenericCommentEventAction
	Body         string
	HTMLURL      string
	Number       int
	Repo         Repo
	User         User
	IssueAuthor  User
	Assignees    []User
	IssueState   string
	IssueTitle   string
	IssueBody    string
	IssueHTMLURL string
	GUID         string
}

GenericCommentEvent is a fake event type that is instantiated for any github event that contains comment like content. The specific events that are also handled as GenericCommentEvents are: - issue_comment events - pull_request_review events - pull_request_review_comment events - pull_request events with action in ["opened", "edited"] - issue events with action in ["opened", "edited"]

Issue and PR "closed" events are not coerced to the "deleted" Action and do not trigger a GenericCommentEvent because these events don't actually remove the comment content from GH.

func GeneralizeComment

func GeneralizeComment[E CommentLikeEventTypes](event E) (*GenericCommentEvent, error)

GeneralizeComment takes an event that can be coerced into a GenericCommentEvent and returns a populated GenericCommentEvent.

type GenericCommentEventAction

type GenericCommentEventAction string

GenericCommentEventAction coerces multiple actions into its generic equivalent.

const (
	// GenericCommentActionCreated means something was created/opened/submitted
	GenericCommentActionCreated GenericCommentEventAction = "created" // "opened", "submitted"
	// GenericCommentActionEdited means something was edited.
	GenericCommentActionEdited GenericCommentEventAction = "edited"
	// GenericCommentActionDeleted means something was deleted/dismissed.
	GenericCommentActionDeleted GenericCommentEventAction = "deleted" // "dismissed"
)

Comments indicate values that are coerced to the specified value.

func GeneralizeCommentAction

func GeneralizeCommentAction(action string) GenericCommentEventAction

GeneralizeCommentAction normalizes the action string to a GenericCommentEventAction or returns "" if the action is unrelated to the comment text. (For example a PR 'label' action.)

type GenericEvent

type GenericEvent struct {
	Sender User         `json:"sender"`
	Org    Organization `json:"organization"`
	Repo   Repo         `json:"repository"`
}

GenericEvent is a lightweight struct containing just Sender, Organization and Repo as they are allWebhook payload object common properties: https://developer.github.com/webhooks/event-payloads/#webhook-payload-object-common-properties

type GetRefResponse

type GetRefResponse []GetRefResult

func (*GetRefResponse) RefNames

func (grr *GetRefResponse) RefNames() []string

func (*GetRefResponse) UnmarshalJSON

func (grr *GetRefResponse) UnmarshalJSON(data []byte) error

We need a custom unmarshaler because the GetRefResult may either be a single GetRefResponse or multiple

type GetRefResult

type GetRefResult struct {
	Ref    string `json:"ref,omitempty"`
	NodeID string `json:"node_id,omitempty"`
	URL    string `json:"url,omitempty"`
	Object struct {
		Type string `json:"type,omitempty"`
		SHA  string `json:"sha,omitempty"`
		URL  string `json:"url,omitempty"`
	} `json:"object,omitempty"`
}

type GetRefTooManyResultsError

type GetRefTooManyResultsError struct {
	// contains filtered or unexported fields
}

func (GetRefTooManyResultsError) Error

func (GetRefTooManyResultsError) Is

type GitCommit

type GitCommit struct {
	SHA          string                 `json:"sha,omitempty"`
	Author       CommitAuthor           `json:"author,omitempty"`
	Committer    CommitAuthor           `json:"committer,omitempty"`
	Message      string                 `json:"message,omitempty"`
	Tree         Tree                   `json:"tree,omitempty"`
	Parents      []GitCommit            `json:"parents,omitempty"`
	Stats        *CommitStats           `json:"stats,omitempty"`
	HTMLURL      string                 `json:"html_url,omitempty"`
	URL          string                 `json:"url,omitempty"`
	Verification *SignatureVerification `json:"verification,omitempty"`
	NodeID       string                 `json:"node_id,omitempty"`

	// CommentCount is the number of GitHub comments on the commit. This
	// is only populated for requests that fetch GitHub data like
	// Pulls.ListCommits, Repositories.ListCommits, etc.
	CommentCount *int `json:"comment_count,omitempty"`
}

GitCommit represents a GitHub commit.

type HMACToken

type HMACToken struct {
	Value     string    `json:"value"`
	CreatedAt time.Time `json:"created_at"`
}

HMACToken contains a hmac token and the time when it's created.

type HMACsForRepo

type HMACsForRepo []HMACToken

HMACsForRepo contains all hmac tokens configured for a repo, org or globally.

type Hook

type Hook struct {
	ID     int        `json:"id"`
	Name   string     `json:"name"`
	Events []string   `json:"events"`
	Active bool       `json:"active"`
	Config HookConfig `json:"config"`
}

Hook holds info about the webhook configuration.

type HookClient

type HookClient interface {
	ListOrgHooks(org string) ([]Hook, error)
	ListRepoHooks(org, repo string) ([]Hook, error)
	EditRepoHook(org, repo string, id int, req HookRequest) error
	EditOrgHook(org string, id int, req HookRequest) error
	CreateOrgHook(org string, req HookRequest) (int, error)
	CreateRepoHook(org, repo string, req HookRequest) (int, error)
	DeleteOrgHook(org string, id int, req HookRequest) error
	DeleteRepoHook(org, repo string, id int, req HookRequest) error
	ListCurrentUserRepoInvitations() ([]UserRepoInvitation, error)
	AcceptUserRepoInvitation(invitationID int) error
	ListCurrentUserOrgInvitations() ([]UserOrgInvitation, error)
	AcceptUserOrgInvitation(org string) error
}

HookClient interface for hook related API actions

type HookConfig

type HookConfig struct {
	URL         string  `json:"url"`
	ContentType *string `json:"content_type,omitempty"`
	Secret      *string `json:"secret,omitempty"`
}

HookConfig holds the endpoint and its secret.

type HookRequest

type HookRequest struct {
	Name         string      `json:"name,omitempty"` // must be web or "", only create
	Active       *bool       `json:"active,omitempty"`
	AddEvents    []string    `json:"add_events,omitempty"` // only repo edit
	Config       *HookConfig `json:"config,omitempty"`
	Events       []string    `json:"events,omitempty"`
	RemoveEvents []string    `json:"remove_events,omitempty"` // only repo edit
}

HookRequest can create and/or edit a webhook.

AddEvents and RemoveEvents are only valid during an edit, and only for a repo

type InstallationPermissions

type InstallationPermissions struct {
	Administration              string `json:"administration,omitempty"`
	Blocking                    string `json:"blocking,omitempty"`
	Checks                      string `json:"checks,omitempty"`
	Contents                    string `json:"contents,omitempty"`
	ContentReferences           string `json:"content_references,omitempty"`
	Deployments                 string `json:"deployments,omitempty"`
	Emails                      string `json:"emails,omitempty"`
	Followers                   string `json:"followers,omitempty"`
	Issues                      string `json:"issues,omitempty"`
	Metadata                    string `json:"metadata,omitempty"`
	Members                     string `json:"members,omitempty"`
	OrganizationAdministration  string `json:"organization_administration,omitempty"`
	OrganizationHooks           string `json:"organization_hooks,omitempty"`
	OrganizationPlan            string `json:"organization_plan,omitempty"`
	OrganizationPreReceiveHooks string `json:"organization_pre_receive_hooks,omitempty"`
	OrganizationProjects        string `json:"organization_projects,omitempty"`
	OrganizationUserBlocking    string `json:"organization_user_blocking,omitempty"`
	Packages                    string `json:"packages,omitempty"`
	Pages                       string `json:"pages,omitempty"`
	PullRequests                string `json:"pull_requests,omitempty"`
	RepositoryHooks             string `json:"repository_hooks,omitempty"`
	RepositoryProjects          string `json:"repository_projects,omitempty"`
	RepositoryPreReceiveHooks   string `json:"repository_pre_receive_hooks,omitempty"`
	SingleFile                  string `json:"single_file,omitempty"`
	Statuses                    string `json:"statuses,omitempty"`
	TeamDiscussions             string `json:"team_discussions,omitempty"`
	VulnerabilityAlerts         string `json:"vulnerability_alerts,omitempty"`
}

type Issue

type Issue struct {
	ID          int       `json:"id"`
	NodeID      string    `json:"node_id"`
	User        User      `json:"user"`
	Number      int       `json:"number"`
	Title       string    `json:"title"`
	State       string    `json:"state"`
	HTMLURL     string    `json:"html_url"`
	Labels      []Label   `json:"labels"`
	Assignees   []User    `json:"assignees"`
	Body        string    `json:"body"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Milestone   Milestone `json:"milestone"`
	StateReason string    `json:"state_reason"`

	// This will be non-nil if it is a pull request.
	PullRequest *struct{} `json:"pull_request,omitempty"`
}

Issue represents general info about an issue.

func (Issue) HasLabel

func (i Issue) HasLabel(labelToFind string) bool

HasLabel checks if an issue has a given label.

func (Issue) IsAssignee

func (i Issue) IsAssignee(login string) bool

IsAssignee checks if a user is assigned to the issue.

func (Issue) IsAuthor

func (i Issue) IsAuthor(login string) bool

IsAuthor checks if a user is the author of the issue.

func (Issue) IsPullRequest

func (i Issue) IsPullRequest() bool

IsPullRequest checks if an issue is a pull request.

type IssueClient

type IssueClient interface {
	CreateIssue(org, repo, title, body string, milestone int, labels, assignees []string) (int, error)
	CreateIssueReaction(org, repo string, id int, reaction string) error
	ListIssueComments(org, repo string, number int) ([]IssueComment, error)
	ListIssueCommentsWithContext(ctx context.Context, org, repo string, number int) ([]IssueComment, error)
	GetIssueLabels(org, repo string, number int) ([]Label, error)
	ListIssueEvents(org, repo string, num int) ([]ListedIssueEvent, error)
	AssignIssue(org, repo string, number int, logins []string) error
	UnassignIssue(org, repo string, number int, logins []string) error
	CloseIssue(org, repo string, number int) error
	CloseIssueAsNotPlanned(org, repo string, number int) error
	ReopenIssue(org, repo string, number int) error
	FindIssues(query, sort string, asc bool) ([]Issue, error)
	FindIssuesWithOrg(org, query, sort string, asc bool) ([]Issue, error)
	ListOpenIssues(org, repo string) ([]Issue, error)
	GetIssue(org, repo string, number int) (*Issue, error)
	EditIssue(org, repo string, number int, issue *Issue) (*Issue, error)
}

IssueClient interface for issue related API actions

type IssueComment

type IssueComment struct {
	ID        int       `json:"id,omitempty"`
	Body      string    `json:"body"`
	User      User      `json:"user,omitempty"`
	HTMLURL   string    `json:"html_url,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

IssueComment represents general info about an issue comment.

type IssueCommentEvent

type IssueCommentEvent struct {
	Action  IssueCommentEventAction `json:"action"`
	Issue   Issue                   `json:"issue"`
	Comment IssueComment            `json:"comment"`
	Repo    Repo                    `json:"repository"`

	// GUID is included in the header of the request received by GitHub.
	GUID string
}

IssueCommentEvent is what GitHub sends us when an issue comment is changed.

type IssueCommentEventAction

type IssueCommentEventAction string

IssueCommentEventAction enumerates the triggers for this webhook payload type. See also: https://developer.github.com/v3/activity/events/types/#issuecommentevent

const (
	// IssueCommentActionCreated means the comment was created.
	IssueCommentActionCreated IssueCommentEventAction = "created"
	// IssueCommentActionEdited means the comment was edited.
	IssueCommentActionEdited IssueCommentEventAction = "edited"
	// IssueCommentActionDeleted means the comment was deleted.
	IssueCommentActionDeleted IssueCommentEventAction = "deleted"
)

type IssueEvent

type IssueEvent struct {
	Action IssueEventAction `json:"action"`
	Issue  Issue            `json:"issue"`
	Repo   Repo             `json:"repository"`
	// Label is specified for IssueActionLabeled and IssueActionUnlabeled events.
	Label  Label `json:"label"`
	Sender User  `json:"sender"`

	// GUID is included in the header of the request received by GitHub.
	GUID string
}

IssueEvent represents an issue event from a webhook payload (not from the events API).

type IssueEventAction

type IssueEventAction string

IssueEventAction enumerates the triggers for this webhook payload type. See also: https://developer.github.com/v3/activity/events/types/#issuesevent

const (
	// IssueActionAssigned means assignees were added.
	IssueActionAssigned IssueEventAction = "assigned"
	// IssueActionUnassigned means assignees were added.
	IssueActionUnassigned IssueEventAction = "unassigned"
	// IssueActionLabeled means labels were added.
	IssueActionLabeled IssueEventAction = "labeled"
	// IssueActionUnlabeled means labels were removed.
	IssueActionUnlabeled IssueEventAction = "unlabeled"
	// IssueActionOpened means issue was opened/created.
	IssueActionOpened IssueEventAction = "opened"
	// IssueActionEdited means issue body was edited.
	IssueActionEdited IssueEventAction = "edited"
	// IssueActionDeleted means the issue was deleted.
	IssueActionDeleted IssueEventAction = "deleted"
	// IssueActionMilestoned means the milestone was added/changed.
	IssueActionMilestoned IssueEventAction = "milestoned"
	// IssueActionDemilestoned means a milestone was removed.
	IssueActionDemilestoned IssueEventAction = "demilestoned"
	// IssueActionClosed means issue was closed.
	IssueActionClosed IssueEventAction = "closed"
	// IssueActionReopened means issue was reopened.
	IssueActionReopened IssueEventAction = "reopened"
	// IssueActionPinned means the issue was pinned.
	IssueActionPinned IssueEventAction = "pinned"
	// IssueActionUnpinned means the issue was unpinned.
	IssueActionUnpinned IssueEventAction = "unpinned"
	// IssueActionTransferred means the issue was transferred to another repo.
	IssueActionTransferred IssueEventAction = "transferred"
	// IssueActionLocked means the issue was locked.
	IssueActionLocked IssueEventAction = "locked"
	// IssueActionUnlocked means the issue was unlocked.
	IssueActionUnlocked IssueEventAction = "unlocked"
)

type IssuesSearchResult

type IssuesSearchResult struct {
	Total  int     `json:"total_count,omitempty"`
	Issues []Issue `json:"items,omitempty"`
}

IssuesSearchResult represents the result of an issues search.

type Label

type Label struct {
	URL         string `json:"url"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Color       string `json:"color"`
}

Label describes a GitHub label.

type ListedIssueEvent

type ListedIssueEvent struct {
	ID  int64  `json:"id,omitempty"`
	URL string `json:"url,omitempty"`

	// The User that generated this event.
	Actor User `json:"actor"`

	// This is the same as IssueEvent.Action
	Event IssueEventAction `json:"event"`

	CreatedAt time.Time `json:"created_at"`
	Issue     Issue     `json:"issue,omitempty"`

	// Only present on certain events.
	Assignee          User            `json:"assignee,omitempty"`
	Assigner          User            `json:"assigner,omitempty"`
	CommitID          string          `json:"commit_id,omitempty"`
	Milestone         Milestone       `json:"milestone,omitempty"`
	Label             Label           `json:"label"`
	Rename            Rename          `json:"rename,omitempty"`
	LockReason        string          `json:"lock_reason,omitempty"`
	ProjectCard       ProjectCard     `json:"project_card,omitempty"`
	DismissedReview   DismissedReview `json:"dismissed_review,omitempty"`
	RequestedReviewer User            `json:"requested_reviewer,omitempty"`
	ReviewRequester   User            `json:"review_requester,omitempty"`
}

ListedIssueEvent represents an issue event from the events API (not from a webhook payload). https://developer.github.com/v3/issues/events/

type Membership

type Membership struct {
	// admin or member
	Role string `json:"role"`
	// pending or active
	State string `json:"state,omitempty"`
}

Membership specifies the role and state details for an org and/or team.

type MergeCommitsForbiddenError

type MergeCommitsForbiddenError string

MergeCommitsForbiddenError happens when the repo disallows the merge strategy configured for the repo in Tide.

func (MergeCommitsForbiddenError) Error

type MergeDetails

type MergeDetails struct {
	// CommitTitle defaults to the automatic message.
	CommitTitle string `json:"commit_title,omitempty"`
	// CommitMessage defaults to the automatic message.
	CommitMessage string `json:"commit_message,omitempty"`
	// The PR HEAD must match this to prevent races.
	SHA string `json:"sha,omitempty"`
	// Can be "merge", "squash", or "rebase". Defaults to merge.
	MergeMethod string `json:"merge_method,omitempty"`
}

MergeDetails contains desired properties of the merge.

See https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button

type Milestone

type Milestone struct {
	Title  string `json:"title"`
	Number int    `json:"number"`
	State  string `json:"state"`
}

Milestone is a milestone defined on a github repository

type MilestoneClient

type MilestoneClient interface {
	ClearMilestone(org, repo string, num int) error
	SetMilestone(org, repo string, issueNum, milestoneNum int) error
	ListMilestones(org, repo string) ([]Milestone, error)
}

MilestoneClient interface for milestone related API actions

type MissingUsers

type MissingUsers struct {
	Users []string
	// contains filtered or unexported fields
}

MissingUsers is an error specifying the users that could not be unassigned.

func (MissingUsers) Error

func (m MissingUsers) Error() string

type ModifiedHeadError

type ModifiedHeadError string

ModifiedHeadError happens when github refuses to merge a PR because the PR changed.

func (ModifiedHeadError) Error

func (e ModifiedHeadError) Error() string

type OrgInvitation

type OrgInvitation struct {
	TeamMember
	Email   string     `json:"email"`
	Inviter TeamMember `json:"inviter"`
}

OrgInvitation contains Login and other details about the invitation.

type OrgMembership

type OrgMembership struct {
	Membership
}

OrgMembership contains Membership fields for user membership in an org.

type OrgPermissionLevel

type OrgPermissionLevel string

OrgPermissionLevel is admin, and member

See https://docs.github.com/en/rest/reference/orgs#set-organization-membership-for-a-user

const (
	// OrgMember is the member
	OrgMember OrgPermissionLevel = "member"
	// OrgAdmin manages the org
	OrgAdmin OrgPermissionLevel = "admin"
	// OrgUnaffiliated probably means user not a member yet, this was returned
	// from an org invitation, had to add it so unmarshal doesn't crash
	OrgUnaffiliated OrgPermissionLevel = "unaffiliated"
	// OrgReinstate means the user was removed and the invited again before n months have passed.
	// More info here: https://docs.github.com/en/github-ae@latest/organizations/managing-membership-in-your-organization/reinstating-a-former-member-of-your-organization
	OrgReinstate OrgPermissionLevel = "reinstate"
)

func (OrgPermissionLevel) MarshalText

func (l OrgPermissionLevel) MarshalText() ([]byte, error)

MarshalText returns the byte representation of the permission

func (*OrgPermissionLevel) UnmarshalText

func (l *OrgPermissionLevel) UnmarshalText(text []byte) error

UnmarshalText validates the text is a valid string

type Organization

type Organization struct {
	// Login has the same meaning as Name, but it's more reliable to use as Name can sometimes be empty,
	// see https://developer.github.com/v3/orgs/#list-organizations
	Login  string `json:"login"`
	Id     int    `json:"id"`
	NodeId string `json:"node_id"`
	// BillingEmail holds private billing address
	BillingEmail string `json:"billing_email"`
	Company      string `json:"company"`
	// Email is publicly visible
	Email                        string `json:"email"`
	Location                     string `json:"location"`
	Name                         string `json:"name"`
	Description                  string `json:"description"`
	HasOrganizationProjects      bool   `json:"has_organization_projects"`
	HasRepositoryProjects        bool   `json:"has_repository_projects"`
	DefaultRepositoryPermission  string `json:"default_repository_permission"`
	MembersCanCreateRepositories bool   `json:"members_can_create_repositories"`
}

Organization stores metadata information about an organization

type OrganizationClient

type OrganizationClient interface {
	IsMember(org, user string) (bool, error)
	GetOrg(name string) (*Organization, error)
	EditOrg(name string, config Organization) (*Organization, error)
	ListOrgInvitations(org string) ([]OrgInvitation, error)
	ListOrgMembers(org, role string) ([]TeamMember, error)
	HasPermission(org, repo, user string, roles ...string) (bool, error)
	GetUserPermission(org, repo, user string) (string, error)
	UpdateOrgMembership(org, user string, admin bool) (*OrgMembership, error)
	RemoveOrgMembership(org, user string) error
}

OrganizationClient interface for organisation related API actions

type ParentRepo

type ParentRepo struct {
	Owner    User   `json:"owner"`
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	HTMLURL  string `json:"html_url"`
}

ParentRepo contains a small subsection of general repository information: it just includes the information needed to confirm that a parent repo exists and what the name of that repo is.

type Project

type Project struct {
	Name string `json:"name"`
	ID   int    `json:"id"`
}

Project is a github project

type ProjectCard

type ProjectCard struct {
	ID          int    `json:"id"`
	ContentID   int    `json:"content_id"`
	ContentType string `json:"content_type"`
	ContentURL  string `json:"content_url"`
}

ProjectCard is a github project card

type ProjectClient

type ProjectClient interface {
	GetRepoProjects(owner, repo string) ([]Project, error)
	GetOrgProjects(org string) ([]Project, error)
	GetProjectColumns(org string, projectID int) ([]ProjectColumn, error)
	CreateProjectCard(org string, columnID int, projectCard ProjectCard) (*ProjectCard, error)
	GetColumnProjectCards(org string, columnID int) ([]ProjectCard, error)
	GetColumnProjectCard(org string, columnID int, issueURL string) (*ProjectCard, error)
	MoveProjectCard(org string, projectCardID int, newColumnID int) error
	DeleteProjectCard(org string, projectCardID int) error
}

ProjectClient interface for project related API actions

type ProjectColumn

type ProjectColumn struct {
	Name string `json:"name"`
	ID   int    `json:"id"`
}

ProjectColumn is a colunm in a github project

type PullRequest

type PullRequest struct {
	ID                 int               `json:"id"`
	NodeID             string            `json:"node_id"`
	Number             int               `json:"number"`
	HTMLURL            string            `json:"html_url"`
	User               User              `json:"user"`
	Labels             []Label           `json:"labels"`
	Base               PullRequestBranch `json:"base"`
	Head               PullRequestBranch `json:"head"`
	Title              string            `json:"title"`
	Body               string            `json:"body"`
	RequestedReviewers []User            `json:"requested_reviewers"`
	RequestedTeams     []Team            `json:"requested_teams"`
	Assignees          []User            `json:"assignees"`
	State              string            `json:"state"`
	Draft              bool              `json:"draft"`
	Merged             bool              `json:"merged"`
	CreatedAt          time.Time         `json:"created_at,omitempty"`
	UpdatedAt          time.Time         `json:"updated_at,omitempty"`
	// ref https://developer.github.com/v3/pulls/#get-a-single-pull-request
	// If Merged is true, MergeSHA is the SHA of the merge commit, or squashed commit
	// If Merged is false, MergeSHA is a commit SHA that github created to test if
	// the PR can be merged automatically.
	MergeSHA *string `json:"merge_commit_sha"`
	// ref https://developer.github.com/v3/pulls/#response-1
	// The value of the mergeable attribute can be true, false, or null. If the value
	// is null, this means that the mergeability hasn't been computed yet, and a
	// background job was started to compute it. When the job is complete, the response
	// will include a non-null value for the mergeable attribute.
	Mergable *bool `json:"mergeable,omitempty"`
	// If the PR doesn't have any milestone, `milestone` is null and is unmarshaled to nil.
	Milestone         *Milestone `json:"milestone,omitempty"`
	Commits           int        `json:"commits"`
	AuthorAssociation string     `json:"author_association,omitempty"`
}

PullRequest contains information about a PullRequest.

type PullRequestBranch

type PullRequestBranch struct {
	Ref  string `json:"ref"`
	SHA  string `json:"sha"`
	Repo Repo   `json:"repo"`
}

PullRequestBranch contains information about a particular branch in a PR.

type PullRequestChange

type PullRequestChange 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"`
	Patch            string `json:"patch"`
	BlobURL          string `json:"blob_url"`
	PreviousFilename string `json:"previous_filename"`
}

PullRequestChange contains information about what a PR changed.

type PullRequestClient

type PullRequestClient interface {
	GetPullRequests(org, repo string) ([]PullRequest, error)
	GetPullRequest(org, repo string, number int) (*PullRequest, error)
	EditPullRequest(org, repo string, number int, pr *PullRequest) (*PullRequest, error)
	GetPullRequestDiff(org, repo string, number int) ([]byte, error)
	GetPullRequestPatch(org, repo string, number int) ([]byte, error)
	CreatePullRequest(org, repo, title, body, head, base string, canModify bool) (int, error)
	UpdatePullRequest(org, repo string, number int, title, body *string, open *bool, branch *string, canModify *bool) error
	GetPullRequestChanges(org, repo string, number int) ([]PullRequestChange, error)
	ListPullRequestComments(org, repo string, number int) ([]ReviewComment, error)
	CreatePullRequestReviewComment(org, repo string, number int, rc ReviewComment) error
	ListReviews(org, repo string, number int) ([]Review, error)
	ClosePullRequest(org, repo string, number int) error
	ReopenPullRequest(org, repo string, number int) error
	CreateReview(org, repo string, number int, r DraftReview) error
	RequestReview(org, repo string, number int, logins []string) error
	UnrequestReview(org, repo string, number int, logins []string) error
	Merge(org, repo string, pr int, details MergeDetails) error
	IsMergeable(org, repo string, number int, SHA string) (bool, error)
	ListPullRequestCommits(org, repo string, number int) ([]RepositoryCommit, error)
	UpdatePullRequestBranch(org, repo string, number int, expectedHeadSha *string) error
}

PullRequestClient interface for pull request related API actions

type PullRequestEvent

type PullRequestEvent struct {
	Action      PullRequestEventAction `json:"action"`
	Number      int                    `json:"number"`
	PullRequest PullRequest            `json:"pull_request"`
	Repo        Repo                   `json:"repository"`
	Label       Label                  `json:"label"`
	Sender      User                   `json:"sender"`

	// Changes holds raw change data, which we must inspect
	// and deserialize later as this is a polymorphic field
	Changes json.RawMessage `json:"changes"`

	// GUID is included in the header of the request received by GitHub.
	GUID string
}

PullRequestEvent is what GitHub sends us when a PR is changed.

type PullRequestEventAction

type PullRequestEventAction string

PullRequestEventAction enumerates the triggers for this webhook payload type. See also: https://developer.github.com/v3/activity/events/types/#pullrequestevent

const (
	// PullRequestActionAssigned means assignees were added.
	PullRequestActionAssigned PullRequestEventAction = "assigned"
	// PullRequestActionUnassigned means assignees were removed.
	PullRequestActionUnassigned PullRequestEventAction = "unassigned"
	// PullRequestActionReviewRequested means review requests were added.
	PullRequestActionReviewRequested PullRequestEventAction = "review_requested"
	// PullRequestActionReviewRequestRemoved means review requests were removed.
	PullRequestActionReviewRequestRemoved PullRequestEventAction = "review_request_removed"
	// PullRequestActionLabeled means labels were added.
	PullRequestActionLabeled PullRequestEventAction = "labeled"
	// PullRequestActionUnlabeled means labels were removed
	PullRequestActionUnlabeled PullRequestEventAction = "unlabeled"
	// PullRequestActionOpened means the PR was created
	PullRequestActionOpened PullRequestEventAction = "opened"
	// PullRequestActionEdited means the PR body changed.
	PullRequestActionEdited PullRequestEventAction = "edited"
	// PullRequestActionClosed means the PR was closed (or was merged).
	PullRequestActionClosed PullRequestEventAction = "closed"
	// PullRequestActionReopened means the PR was reopened.
	PullRequestActionReopened PullRequestEventAction = "reopened"
	// PullRequestActionSynchronize means the git state changed.
	PullRequestActionSynchronize PullRequestEventAction = "synchronize"
	// PullRequestActionReadyForReview means the PR is no longer a draft PR.
	PullRequestActionReadyForReview PullRequestEventAction = "ready_for_review"
	// PullRequestActionConvertedToDraft means the PR is now a draft PR.
	PullRequestActionConvertedToDraft PullRequestEventAction = "converted_to_draft"
	// PullRequestActionLocked means labels were added.
	PullRequestActionLocked PullRequestEventAction = "locked"
	// PullRequestActionUnlocked means labels were removed
	PullRequestActionUnlocked PullRequestEventAction = "unlocked"
	// PullRequestActionAutoMergeEnabled means auto merge was enabled
	PullRequestActionAutoMergeEnabled PullRequestEventAction = "auto_merge_enabled"
	// PullRequestActionAutoMergeDisabled means auto merge was disabled
	PullRequestActionAutoMergeDisabled PullRequestEventAction = "auto_merge_disabled"
)

type PullRequestFileStatus

type PullRequestFileStatus string

PullRequestFileStatus enumerates the statuses for this webhook payload type.

type PushEvent

type PushEvent struct {
	Ref     string   `json:"ref"`
	Before  string   `json:"before"`
	After   string   `json:"after"`
	Created bool     `json:"created"`
	Deleted bool     `json:"deleted"`
	Forced  bool     `json:"forced"`
	Compare string   `json:"compare"`
	Commits []Commit `json:"commits"`
	// Pusher is the user that pushed the commit, valid in a webhook event.
	Pusher User `json:"pusher"`
	// Sender contains more information that Pusher about the user.
	Sender User `json:"sender"`
	Repo   Repo `json:"repository"`

	// GUID is included in the header of the request received by GitHub.
	GUID string
}

PushEvent is what GitHub sends us when a user pushes to a repo.

func (PushEvent) Branch

func (pe PushEvent) Branch() string

Branch returns the name of the branch to which the user pushed.

type Reaction

type Reaction struct {
	Content string `json:"content"`
}

Reaction holds the type of emotional reaction.

type Rename

type Rename struct {
	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
}

Rename contains details for 'renamed' events.

type Repo

type Repo struct {
	Owner         User   `json:"owner"`
	Name          string `json:"name"`
	FullName      string `json:"full_name"`
	HTMLURL       string `json:"html_url"`
	Fork          bool   `json:"fork"`
	DefaultBranch string `json:"default_branch"`
	Archived      bool   `json:"archived"`
	Private       bool   `json:"private"`
	Description   string `json:"description"`
	Homepage      string `json:"homepage"`
	HasIssues     bool   `json:"has_issues"`
	HasProjects   bool   `json:"has_projects"`
	HasWiki       bool   `json:"has_wiki"`
	NodeID        string `json:"node_id"`
	// Permissions reflect the permission level for the requester, so
	// on a repository GET call this will be for the user whose token
	// is being used, if listing a team's repos this will be for the
	// team's privilege level in the repo
	Permissions RepoPermissions `json:"permissions"`
	Parent      ParentRepo      `json:"parent"`
}

Repo contains general repository information: it includes fields available in repo records returned by GH "List" methods but not those returned by GH "Get" method. Use FullRepo struct for "Get" method. See also https://developer.github.com/v3/repos/#list-organization-repositories

type RepoCreateRequest

type RepoCreateRequest struct {
	RepoRequest `json:",omitempty"`

	AutoInit          *bool   `json:"auto_init,omitempty"`
	GitignoreTemplate *string `json:"gitignore_template,omitempty"`
	LicenseTemplate   *string `json:"license_template,omitempty"`
}

RepoCreateRequest contains metadata used in requests to create a repo. See also: https://developer.github.com/v3/repos/#create

type RepoPermissionLevel

type RepoPermissionLevel string

RepoPermissionLevel is admin, write, read or none.

See https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level

const (
	// Read allows pull but not push
	Read RepoPermissionLevel = "read"
	// Triage allows Read and managing issues
	// pull requests but not push
	Triage RepoPermissionLevel = "triage"
	// Write allows Read plus push
	Write RepoPermissionLevel = "write"
	// Maintain allows Write along with managing
	// repository without access to sensitive or
	// destructive instructions.
	Maintain RepoPermissionLevel = "maintain"
	// Admin allows Write plus change others' rights.
	Admin RepoPermissionLevel = "admin"
	// None disallows everything
	None RepoPermissionLevel = "none"
)

For more information on access levels, see: https://docs.github.com/en/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization

func LevelFromPermissions

func LevelFromPermissions(permissions RepoPermissions) RepoPermissionLevel

LevelFromPermissions adapts a repo permissions struct to the appropriate permission level used elsewhere.

func (RepoPermissionLevel) MarshalText

func (l RepoPermissionLevel) MarshalText() ([]byte, error)

MarshalText returns the byte representation of the permission

func (*RepoPermissionLevel) UnmarshalText

func (l *RepoPermissionLevel) UnmarshalText(text []byte) error

UnmarshalText validates the text is a valid string

type RepoPermissions

type RepoPermissions struct {
	// Pull is equivalent to "Read" permissions in the web UI
	Pull   bool `json:"pull"`
	Triage bool `json:"triage"`
	// Push is equivalent to "Edit" permissions in the web UI
	Push     bool `json:"push"`
	Maintain bool `json:"maintain"`
	Admin    bool `json:"admin"`
}

RepoPermissions describes which permission level an entity has in a repo. At most one of the booleans here should be true.

func PermissionsFromTeamPermission

func PermissionsFromTeamPermission(permission TeamPermission) RepoPermissions

PermissionsFromTeamPermissions

type RepoRequest

type RepoRequest struct {
	Name                     *string `json:"name,omitempty"`
	Description              *string `json:"description,omitempty"`
	Homepage                 *string `json:"homepage,omitempty"`
	Private                  *bool   `json:"private,omitempty"`
	HasIssues                *bool   `json:"has_issues,omitempty"`
	HasProjects              *bool   `json:"has_projects,omitempty"`
	HasWiki                  *bool   `json:"has_wiki,omitempty"`
	AllowSquashMerge         *bool   `json:"allow_squash_merge,omitempty"`
	AllowMergeCommit         *bool   `json:"allow_merge_commit,omitempty"`
	AllowRebaseMerge         *bool   `json:"allow_rebase_merge,omitempty"`
	SquashMergeCommitTitle   *string `json:"squash_merge_commit_title,omitempty"`
	SquashMergeCommitMessage *string `json:"squash_merge_commit_message,omitempty"`
}

RepoRequest contains metadata used in requests to create or update a Repo. Compared to `Repo`, its members are pointers to allow the "not set/use default semantics. See also: - https://developer.github.com/v3/repos/#create - https://developer.github.com/v3/repos/#edit

func (RepoRequest) Defined

func (r RepoRequest) Defined() bool

Defined returns true if at least one of the pointer fields are not nil

func (RepoRequest) ToRepo

func (r RepoRequest) ToRepo() *FullRepo

type RepoUpdateRequest

type RepoUpdateRequest struct {
	RepoRequest `json:",omitempty"`

	DefaultBranch *string `json:"default_branch,omitempty"`
	Archived      *bool   `json:"archived,omitempty"`
}

RepoUpdateRequest contains metadata used for updating a repository See also: https://developer.github.com/v3/repos/#edit

func (RepoUpdateRequest) Defined

func (r RepoUpdateRequest) Defined() bool

func (RepoUpdateRequest) ToRepo

func (r RepoUpdateRequest) ToRepo() *FullRepo

type RepositoryClient

type RepositoryClient interface {
	GetRepo(owner, name string) (FullRepo, error)
	GetRepos(org string, isUser bool) ([]Repo, error)
	GetBranches(org, repo string, onlyProtected bool) ([]Branch, error)
	GetBranchProtection(org, repo, branch string) (*BranchProtection, error)
	RemoveBranchProtection(org, repo, branch string) error
	UpdateBranchProtection(org, repo, branch string, config BranchProtectionRequest) error
	AddRepoLabel(org, repo, label, description, color string) error
	UpdateRepoLabel(org, repo, label, newName, description, color string) error
	DeleteRepoLabel(org, repo, label string) error
	GetRepoLabels(org, repo string) ([]Label, error)
	AddLabel(org, repo string, number int, label string) error
	AddLabelWithContext(ctx context.Context, org, repo string, number int, label string) error
	AddLabels(org, repo string, number int, labels ...string) error
	AddLabelsWithContext(ctx context.Context, org, repo string, number int, labels ...string) error
	RemoveLabel(org, repo string, number int, label string) error
	RemoveLabelWithContext(ctx context.Context, org, repo string, number int, label string) error
	WasLabelAddedByHuman(org, repo string, number int, label string) (bool, error)
	GetFile(org, repo, filepath, commit string) ([]byte, error)
	GetDirectory(org, repo, dirpath, commit string) ([]DirectoryContent, error)
	IsCollaborator(org, repo, user string) (bool, error)
	ListCollaborators(org, repo string) ([]User, error)
	CreateFork(owner, repo string) (string, error)
	EnsureFork(forkingUser, org, repo string) (string, error)
	ListRepoTeams(org, repo string) ([]Team, error)
	CreateRepo(owner string, isUser bool, repo RepoCreateRequest) (*FullRepo, error)
	UpdateRepo(owner, name string, repo RepoUpdateRequest) (*FullRepo, error)
}

RepositoryClient interface for repository related API actions

type RepositoryCommit

type RepositoryCommit struct {
	NodeID      string      `json:"node_id,omitempty"`
	SHA         string      `json:"sha,omitempty"`
	Commit      GitCommit   `json:"commit,omitempty"`
	Author      User        `json:"author,omitempty"`
	Committer   User        `json:"committer,omitempty"`
	Parents     []GitCommit `json:"parents,omitempty"`
	HTMLURL     string      `json:"html_url,omitempty"`
	URL         string      `json:"url,omitempty"`
	CommentsURL string      `json:"comments_url,omitempty"`

	// Details about how many changes were made in this commit. Only filled in during GetCommit!
	Stats *CommitStats `json:"stats,omitempty"`
	// Details about which files, and how this commit touched. Only filled in during GetCommit!
	Files []CommitFile `json:"files,omitempty"`
}

RepositoryCommit represents a commit in a repo. Note that it's wrapping a GitCommit, so author/committer information is in two places, but contain different details about them: in RepositoryCommit "github details", in GitCommit - "git details". Get single commit also use it, see: https://developer.github.com/v3/repos/commits/#get-a-single-commit.

type RequiredLinearHistory

type RequiredLinearHistory struct {
	Enabled bool `json:"enabled"`
}

RequiredLinearHistory specifies whether to prevent merge commits from being pushed to matching branches.

type RequiredPullRequestReviews

type RequiredPullRequestReviews struct {
	DismissalRestrictions        *DismissalRestrictions `json:"dismissal_restrictions"`
	DismissStaleReviews          bool                   `json:"dismiss_stale_reviews"`
	RequireCodeOwnerReviews      bool                   `json:"require_code_owner_reviews"`
	RequiredApprovingReviewCount int                    `json:"required_approving_review_count"`
	BypassRestrictions           *BypassRestrictions    `json:"bypass_pull_request_allowances"`
}

RequiredPullRequestReviews exposes the state of review rights.

type RequiredPullRequestReviewsRequest

type RequiredPullRequestReviewsRequest struct {
	DismissalRestrictions        DismissalRestrictionsRequest `json:"dismissal_restrictions"`
	DismissStaleReviews          bool                         `json:"dismiss_stale_reviews"`
	RequireCodeOwnerReviews      bool                         `json:"require_code_owner_reviews"`
	RequiredApprovingReviewCount int                          `json:"required_approving_review_count"`
	BypassRestrictions           BypassRestrictionsRequest    `json:"bypass_pull_request_allowances"`
}

RequiredPullRequestReviewsRequest controls a request for review rights.

type RequiredStatusChecks

type RequiredStatusChecks struct {
	Strict   bool     `json:"strict"` // PR must be up to date (include latest base branch commit).
	Contexts []string `json:"contexts"`
}

RequiredStatusChecks specifies which contexts must pass to merge.

type RerunClient

type RerunClient interface {
	TeamBySlugHasMember(org string, teamSlug string, memberLogin string) (bool, error)
	TeamHasMember(org string, teamID int, memberLogin string) (bool, error)
	IsCollaborator(org, repo, user string) (bool, error)
	IsMember(org, user string) (bool, error)
	GetIssueLabels(org, repo string, number int) ([]Label, error)
}

RerunClient interface for job rerun access check related API actions

type Restrictions

type Restrictions struct {
	Apps  []App  `json:"apps,omitempty"`
	Users []User `json:"users,omitempty"`
	Teams []Team `json:"teams,omitempty"`
}

Restrictions exposes restrictions in github for an activity to apps/people/teams.

type RestrictionsRequest

type RestrictionsRequest struct {
	// Apps is a list of app names
	Apps *[]string `json:"apps,omitempty"`
	// Users is a list of user logins
	Users *[]string `json:"users,omitempty"`
	// Teams is a list of team slugs
	Teams *[]string `json:"teams,omitempty"`
}

RestrictionsRequest tells github to restrict an activity to apps/people/teams.

Use *[]string in order to distinguish unset and empty list. do not restrict (empty object) and restrict everyone (nil apps/user/teams list)

type Review

type Review struct {
	ID          int         `json:"id"`
	NodeID      string      `json:"node_id"`
	User        User        `json:"user"`
	Body        string      `json:"body"`
	State       ReviewState `json:"state"`
	HTMLURL     string      `json:"html_url"`
	SubmittedAt time.Time   `json:"submitted_at"`
}

Review describes a Pull Request review.

type ReviewAction

type ReviewAction string

ReviewAction is the action that a review can be made with.

type ReviewComment

type ReviewComment struct {
	ID        int       `json:"id"`
	NodeID    string    `json:"node_id"`
	ReviewID  int       `json:"pull_request_review_id"`
	User      User      `json:"user"`
	Body      string    `json:"body"`
	Path      string    `json:"path"`
	HTMLURL   string    `json:"html_url"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	// Position will be nil if the code has changed such that the comment is no
	// longer relevant.
	Position  *int     `json:"position,omitempty"`
	Side      DiffSide `json:"side,omitempty"`
	StartSide DiffSide `json:"start_side,omitempty"`
	Line      int      `json:"line,omitempty"`
	StartLine int      `json:"start_line,omitempty"`
}

ReviewComment describes a Pull Request review.

type ReviewCommentEvent

type ReviewCommentEvent struct {
	Action      ReviewCommentEventAction `json:"action"`
	PullRequest PullRequest              `json:"pull_request"`
	Repo        Repo                     `json:"repository"`
	Comment     ReviewComment            `json:"comment"`

	// GUID is included in the header of the request received by GitHub.
	GUID string
}

ReviewCommentEvent is what GitHub sends us when a PR review comment is changed.

type ReviewCommentEventAction

type ReviewCommentEventAction string

ReviewCommentEventAction enumerates the triggers for this webhook payload type. See also: https://developer.github.com/v3/activity/events/types/#pullrequestreviewcommentevent

const (
	// ReviewCommentActionCreated means the comment was created.
	ReviewCommentActionCreated ReviewCommentEventAction = "created"
	// ReviewCommentActionEdited means the comment was edited.
	ReviewCommentActionEdited ReviewCommentEventAction = "edited"
	// ReviewCommentActionDeleted means the comment was deleted.
	ReviewCommentActionDeleted ReviewCommentEventAction = "deleted"
)

type ReviewEvent

type ReviewEvent struct {
	Action      ReviewEventAction `json:"action"`
	PullRequest PullRequest       `json:"pull_request"`
	Repo        Repo              `json:"repository"`
	Review      Review            `json:"review"`

	// GUID is included in the header of the request received by GitHub.
	GUID string
}

ReviewEvent is what GitHub sends us when a PR review is changed.

type ReviewEventAction

type ReviewEventAction string

ReviewEventAction enumerates the triggers for this webhook payload type. See also: https://developer.github.com/v3/activity/events/types/#pullrequestreviewevent

const (
	// ReviewActionSubmitted means the review was submitted.
	ReviewActionSubmitted ReviewEventAction = "submitted"
	// ReviewActionEdited means the review was edited.
	ReviewActionEdited ReviewEventAction = "edited"
	// ReviewActionDismissed means the review was dismissed.
	ReviewActionDismissed ReviewEventAction = "dismissed"
)

type ReviewState

type ReviewState string

ReviewState is the state a review can be in.

type SignatureVerification

type SignatureVerification struct {
	Verified  bool   `json:"verified,omitempty"`
	Reason    string `json:"reason,omitempty"`
	Signature string `json:"signature,omitempty"`
	Payload   string `json:"payload,omitempty"`
}

SignatureVerification represents GPG signature verification.

type StateCannotBeChanged

type StateCannotBeChanged struct {
	Message string
}

StateCannotBeChanged represents the "custom" GitHub API error that occurs when a resource cannot be changed

func (StateCannotBeChanged) Error

func (s StateCannotBeChanged) Error() string

type Status

type Status struct {
	State       string `json:"state"`
	TargetURL   string `json:"target_url,omitempty"`
	Description string `json:"description,omitempty"`
	Context     string `json:"context,omitempty"`
}

Status is used to set a commit status line.

type StatusEvent

type StatusEvent struct {
	SHA         string `json:"sha,omitempty"`
	State       string `json:"state,omitempty"`
	Description string `json:"description,omitempty"`
	TargetURL   string `json:"target_url,omitempty"`
	ID          int    `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Context     string `json:"context,omitempty"`
	Sender      User   `json:"sender,omitempty"`
	Repo        Repo   `json:"repository,omitempty"`

	// GUID is included in the header of the request received by GitHub.
	GUID string
}

StatusEvent fires whenever a git commit changes.

See https://developer.github.com/v3/activity/events/types/#statusevent

type Team

type Team struct {
	ID           int            `json:"id,omitempty"`
	Name         string         `json:"name"`
	Slug         string         `json:"slug"`
	Description  string         `json:"description,omitempty"`
	Privacy      string         `json:"privacy,omitempty"`
	Parent       *Team          `json:"parent,omitempty"`         // Only present in responses
	ParentTeamID *int           `json:"parent_team_id,omitempty"` // Only valid in creates/edits
	Permission   TeamPermission `json:"permission,omitempty"`
}

Team is a github organizational team

type TeamClient

type TeamClient interface {
	CreateTeam(org string, team Team) (*Team, error)
	EditTeam(org string, t Team) (*Team, error)
	DeleteTeam(org string, id int) error
	DeleteTeamBySlug(org, teamSlug string) error
	ListTeams(org string) ([]Team, error)
	UpdateTeamMembership(org string, id int, user string, maintainer bool) (*TeamMembership, error)
	UpdateTeamMembershipBySlug(org, teamSlug, user string, maintainer bool) (*TeamMembership, error)
	RemoveTeamMembership(org string, id int, user string) error
	RemoveTeamMembershipBySlug(org, teamSlug, user string) error
	ListTeamMembers(org string, id int, role string) ([]TeamMember, error)
	ListTeamMembersBySlug(org, teamSlug, role string) ([]TeamMember, error)
	ListTeamRepos(org string, id int) ([]Repo, error)
	ListTeamReposBySlug(org, teamSlug string) ([]Repo, error)
	UpdateTeamRepo(id int, org, repo string, permission TeamPermission) error
	UpdateTeamRepoBySlug(org, teamSlug, repo string, permission TeamPermission) error
	RemoveTeamRepo(id int, org, repo string) error
	RemoveTeamRepoBySlug(org, teamSlug, repo string) error
	ListTeamInvitations(org string, id int) ([]OrgInvitation, error)
	ListTeamInvitationsBySlug(org, teamSlug string) ([]OrgInvitation, error)
	TeamHasMember(org string, teamID int, memberLogin string) (bool, error)
	TeamBySlugHasMember(org string, teamSlug string, memberLogin string) (bool, error)
	GetTeamBySlug(slug string, org string) (*Team, error)
}

TeamClient interface for team related API actions

type TeamMember

type TeamMember struct {
	Login string `json:"login"`
}

TeamMember is a member of an organizational team

type TeamMembership

type TeamMembership struct {
	Membership
}

TeamMembership contains Membership fields for user membership on a team.

type TeamPermission

type TeamPermission string
const (
	RepoPull     TeamPermission = "pull"
	RepoTriage   TeamPermission = "triage"
	RepoMaintain TeamPermission = "maintain"
	RepoPush     TeamPermission = "push"
	RepoAdmin    TeamPermission = "admin"
)

type TokenGenerator

type TokenGenerator func(org string) (string, error)

TokenGenerator knows how to generate a token for use in git client calls

type Tree

type Tree struct {
	SHA string `json:"sha,omitempty"`
}

Tree represents a GitHub tree.

type UnauthorizedToPushError

type UnauthorizedToPushError string

UnauthorizedToPushError happens when client is not allowed to push to github.

func (UnauthorizedToPushError) Error

func (e UnauthorizedToPushError) Error() string

type UnmergablePRBaseChangedError

type UnmergablePRBaseChangedError string

UnmergablePRBaseChangedError happens when github refuses merging a PR because the base changed.

func (UnmergablePRBaseChangedError) Error

type UnmergablePRError

type UnmergablePRError string

UnmergablePRError happens when github refuses to merge a PR for other reasons (merge confclit).

func (UnmergablePRError) Error

func (e UnmergablePRError) Error() string

type User

type User struct {
	Login       string          `json:"login"`
	Name        string          `json:"name"`
	Email       string          `json:"email"`
	ID          int             `json:"id"`
	HTMLURL     string          `json:"html_url"`
	Permissions RepoPermissions `json:"permissions"`
	Type        string          `json:"type"`
}

User is a GitHub user account.

type UserClient

type UserClient interface {
	// BotUser will return details about the user the client runs as. Use BotUserChecker()
	// instead when checking for comment authorship, as the Username in comments might have
	// a [bot] suffix when using github apps authentication.
	BotUser() (*UserData, error)
	// BotUserChecker can be used to check if a comment was authored by the bot user.
	BotUserChecker() (func(candidate string) bool, error)
	BotUserCheckerWithContext(ctx context.Context) (func(candidate string) bool, error)
	Email() (string, error)
}

UserClient interface for user related API actions

type UserData

type UserData struct {
	Name  string
	Login string
	Email string
}

type UserGenerator

type UserGenerator func() (string, error)

UserGenerator knows how to identify this user for use in git client calls

type UserOrgInvitation

type UserOrgInvitation struct {
	State string             `json:"state"`
	Role  OrgPermissionLevel `json:"role"`
	Org   UserOrganization   `json:"organization"`
}

UserOrgInvitation is returned by org invitation obtained by user.

type UserOrganization

type UserOrganization struct {
	// Login is the name of org
	Login string `json:"login"`
}

UserOrganization contains info consumed by UserOrgInvitation.

type UserRepoInvitation

type UserRepoInvitation struct {
	InvitationID int                 `json:"id"`
	Repository   *Repo               `json:"repository,omitempty"`
	Permission   RepoPermissionLevel `json:"permissions"`
}

UserRepoInvitation is returned by repo invitation obtained by user.

type Workflow

type Workflow struct {
	ID        int       `json:"id"`
	NodeID    string    `json:"node_id"`
	Name      string    `json:"name"`
	Path      string    `json:"path"`
	State     string    `json:"state"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type WorkflowRun

type WorkflowRun struct {
	ID               int           `json:"id"`
	Name             string        `json:"name"`
	NodeID           string        `json:"node_id"`
	HeadBranch       string        `json:"head_branch"`
	HeadSha          string        `json:"head_sha"`
	RunNumber        int           `json:"run_number"`
	Event            string        `json:"event"`
	Status           string        `json:"status"`
	Conclusion       string        `json:"conclusion"`
	WorkflowID       int           `json:"workflow_id"`
	CheckSuiteID     int64         `json:"check_suite_id"`
	CheckSuiteNodeID string        `json:"check_suite_node_id"`
	URL              string        `json:"url"`
	PullRequests     []PullRequest `json:"pull_requests"`
	CreatedAt        time.Time     `json:"created_at"`
	UpdatedAt        time.Time     `json:"updated_at"`
	RunAttempt       int           `json:"run_attempt"`
	RunStartedAt     time.Time     `json:"run_started_at"`
	HeadCommit       *Commit       `json:"head_commit"`
	Repository       *Repo         `json:"repository"`
}

type WorkflowRunEvent

type WorkflowRunEvent struct {
	Action       string       `json:"action"`
	WorkflowRun  WorkflowRun  `json:"workflow_run"`
	Workflow     Workflow     `json:"workflow"`
	Repo         *Repo        `json:"repository"`
	Organization Organization `json:"organization"`
	Sender       User         `json:"sender"`

	// GUID is included in the header of the request received by GitHub.
	GUID string
}

WorkflowRunEvent holds information about an `workflow_run` GitHub webhook event. see // https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#workflow_run

type WorkflowRuns

type WorkflowRuns struct {
	Count       int           `json:"total_count,omitempty"`
	WorflowRuns []WorkflowRun `json:"workflow_runs"`
}

Directories

Path Synopsis
Package report contains helpers for writing comments and updating statuses in GitHub.
Package report contains helpers for writing comments and updating statuses in GitHub.

Jump to

Keyboard shortcuts

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