Documentation
¶
Index ¶
- Constants
- func Github(cfg interface{}) (force.Action, error)
- func Scope() (force.Group, error)
- type Approval
- type Branch
- type BranchEvent
- type BranchWatcher
- type CommentObject
- type CommitGetter
- type CommitObject
- type Config
- type GithubClient
- func (m *GithubClient) GetBranches(ctx context.Context, repo Repository, path string) ([]Branch, error)
- func (m *GithubClient) GetOpenPullRequests(ctx context.Context, repo Repository) ([]PullRequest, error)
- func (m *GithubClient) GetPullRequestComments(ctx context.Context, repo Repository, prNumber int) ([]CommentObject, error)
- func (m *GithubClient) GetTeamMembers(ctx context.Context, org, slug string) ([]UserObject, error)
- func (m *GithubClient) ListModifiedFiles(repo Repository, prNumber int) ([]string, error)
- func (m *GithubClient) PostComment(repo Repository, prNumber, comment string) error
- func (m *GithubClient) UpdateCommitStatus(repo Repository, ...) error
- type Namespace
- type NewBranchWatch
- type NewPostStatus
- type NewPostStatusOf
- type NewPullRequestWatch
- type Plugin
- type PostStatusAction
- type PostStatusOfAction
- type PullRequest
- type PullRequestEvent
- type PullRequestObject
- type PullRequestWatcher
- func (r *PullRequestWatcher) Done() <-chan struct{}
- func (r *PullRequestWatcher) Events() <-chan force.Event
- func (r *PullRequestWatcher) MarshalCode(ctx force.ExecutionContext) ([]byte, error)
- func (r *PullRequestWatcher) Start(pctx context.Context) error
- func (r *PullRequestWatcher) String() string
- type RefObject
- type Repository
- type Setup
- type Source
- type Status
- type Trigger
- type UserObject
Constants ¶
const ( // Key is a name of the github plugin variable Key = Namespace("github") KeyWatchPullRequests = "PullRequests" KeyWatchBranches = "Branches" KeySetup = "Setup" KeyPostStatusOf = "PostStatusOf" KeyPostStatus = "PostStatusOf" )
const ( // KeyCommit is a commit used in logs KeyCommit = "commit" // KeyBranch KeyBranch = "branch" // KeyPR is a pull request key used in logs KeyPR = "pr" )
const ( StateSuccess = "success" StatePending = "pending" StateFailure = "failure" StateError = "error" DefaultContext = "Force CI" )
const (
// MasterBranch is a default github master branch to watch
MasterBranch = "master"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Branch ¶
type Branch struct {
RefObject
CommitObject
}
Branch represents a branch that was updated
type BranchEvent ¶
type BranchEvent struct {
Commit force.String
Branch force.String
Source Source
// contains filtered or unexported fields
}
BranchEvent is a commit event
func (*BranchEvent) AddMetadata ¶
func (r *BranchEvent) AddMetadata(ctx force.ExecutionContext)
AddMetadata adds metadata to the logger and the context, such as commit id and PR number
func (*BranchEvent) Created ¶
func (r *BranchEvent) Created() time.Time
Created returns a time when the event was originated
func (*BranchEvent) GetCommit ¶
func (r *BranchEvent) GetCommit() string
GetCommit returns commit associated with the event
func (*BranchEvent) GetSource ¶
func (r *BranchEvent) GetSource() Source
GetSource returns source associated with the event
func (*BranchEvent) String ¶
func (r *BranchEvent) String() string
type BranchWatcher ¶
type BranchWatcher struct {
// contains filtered or unexported fields
}
BranchWatcher is a repository watcher
func (*BranchWatcher) Done ¶
func (r *BranchWatcher) Done() <-chan struct{}
Done returns channel closed when repository watcher is closed
func (*BranchWatcher) Events ¶
func (r *BranchWatcher) Events() <-chan force.Event
Events returns events stream on a repository
func (*BranchWatcher) MarshalCode ¶
func (r *BranchWatcher) MarshalCode(ctx force.ExecutionContext) ([]byte, error)
MarshalCode marshals things to code
func (*BranchWatcher) Start ¶
func (r *BranchWatcher) Start(pctx context.Context) error
Start starts watch on a repo
func (*BranchWatcher) String ¶
func (r *BranchWatcher) String() string
String returns user friendly representation of the watcher
type CommentObject ¶
type CommentObject struct {
ID string
CreatedAt githubv4.DateTime
UpdatedAt githubv4.DateTime
Body string
Author struct {
Login string
}
}
CommentObject represents the GraphQL commit node. https://developer.github.com/v4/object/commit/
type CommitGetter ¶
type CommitObject ¶
type CommitObject struct {
ID string
OID string
CommittedDate githubv4.DateTime
Message string
Author struct {
User struct {
Login string
}
}
}
CommitObject represents the GraphQL commit node. https://developer.github.com/v4/object/commit/
type Config ¶
type Config struct {
// Token is an access token
Token string
// TokenFile is a path to access token
TokenFile string
}
Config is a github plugin config
func (*Config) CheckAndSetDefaults ¶
CheckAndSetDefaults checks and sets default values
type GithubClient ¶
GithubClient for handling requests to the Github V3 and V4 APIs.
func (*GithubClient) GetBranches ¶
func (m *GithubClient) GetBranches(ctx context.Context, repo Repository, path string) ([]Branch, error)
GetBranches gets the last commit on branches with changes matching the path
func (*GithubClient) GetOpenPullRequests ¶
func (m *GithubClient) GetOpenPullRequests(ctx context.Context, repo Repository) ([]PullRequest, error)
GetOpenPullRequests gets the last commit on all open pull requests.
func (*GithubClient) GetPullRequestComments ¶
func (m *GithubClient) GetPullRequestComments(ctx context.Context, repo Repository, prNumber int) ([]CommentObject, error)
GetPullRequestComments returns PR comments
func (*GithubClient) GetTeamMembers ¶
func (m *GithubClient) GetTeamMembers(ctx context.Context, org, slug string) ([]UserObject, error)
GetTeamMembers returns all team members for a given org
func (*GithubClient) ListModifiedFiles ¶
func (m *GithubClient) ListModifiedFiles(repo Repository, prNumber int) ([]string, error)
ListModifiedFiles in a pull request (not supported by V4 API).
func (*GithubClient) PostComment ¶
func (m *GithubClient) PostComment(repo Repository, prNumber, comment string) error
PostComment to a pull request or issue.
func (*GithubClient) UpdateCommitStatus ¶
func (m *GithubClient) UpdateCommitStatus(repo Repository, commitRef, baseContext, statusContext, status, targetURL, description string) error
UpdateCommitStatus for a given commit (not supported by V4 API).
type Namespace ¶
type Namespace string
Namespace is a wrapper around string to namespace a variable in the context
type NewBranchWatch ¶
type NewBranchWatch struct {
}
NewBranchWatch finds the initialized github plugin and returns a new commit watch
func (*NewBranchWatch) NewInstance ¶
func (n *NewBranchWatch) NewInstance(group force.Group) (force.Group, interface{})
NewInstance returns a function creating new watchers
type NewPostStatus ¶
type NewPostStatus struct {
}
NewPostStatus creates actions that posts new status
func (*NewPostStatus) NewInstance ¶
func (n *NewPostStatus) NewInstance(group force.Group) (force.Group, interface{})
NewInstance returns a function that creates new post status actions
type NewPostStatusOf ¶
type NewPostStatusOf struct {
}
NewPostStatusOf returns a function that wraps underlying action and tracks the result, posting the result back
func (*NewPostStatusOf) NewInstance ¶
func (n *NewPostStatusOf) NewInstance(group force.Group) (force.Group, interface{})
NewInstance returns a function creating new post status actions
type NewPullRequestWatch ¶
type NewPullRequestWatch struct {
}
NewPullRequestWatch finds the initialized github plugin and returns a new watch
func (*NewPullRequestWatch) NewInstance ¶
func (n *NewPullRequestWatch) NewInstance(group force.Group) (force.Group, interface{})
NewInstance returns a function creating new watchers
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin is a new plugin
type PostStatusAction ¶
type PostStatusAction struct {
// contains filtered or unexported fields
}
PostStatusAction posts github status
func (*PostStatusAction) Eval ¶
func (p *PostStatusAction) Eval(ctx force.ExecutionContext) (interface{}, error)
Run posts github status
func (*PostStatusAction) MarshalCode ¶
func (p *PostStatusAction) MarshalCode(ctx force.ExecutionContext) ([]byte, error)
MarshalCode marshals the action into code representation
func (*PostStatusAction) Type ¶
func (p *PostStatusAction) Type() interface{}
type PostStatusOfAction ¶
type PostStatusOfAction struct {
// contains filtered or unexported fields
}
PostStatusOfAction executes an action and posts its status to the github
func (*PostStatusOfAction) Eval ¶
func (p *PostStatusOfAction) Eval(ctx force.ExecutionContext) (interface{}, error)
func (*PostStatusOfAction) MarshalCode ¶
func (p *PostStatusOfAction) MarshalCode(ctx force.ExecutionContext) ([]byte, error)
MarshalCode marshals the action into code representation
func (*PostStatusOfAction) Type ¶
func (p *PostStatusOfAction) Type() interface{}
type PullRequest ¶
type PullRequest struct {
PullRequestObject
LastCommit CommitObject
LastComment CommentObject
}
PullRequest represents a pull request and includes the last commit and the last comment
func (*PullRequest) LastUpdated ¶
func (p *PullRequest) LastUpdated() time.Time
LastUpdated returns either the last commit date or the last comment date whatever happened later
type PullRequestEvent ¶
type PullRequestEvent struct {
PR force.Int
Commit force.String
Source Source
PullRequest PullRequest
// contains filtered or unexported fields
}
PullRequestEvent is a pull request event
func (*PullRequestEvent) AddMetadata ¶
func (r *PullRequestEvent) AddMetadata(ctx force.ExecutionContext)
AddMetadata adds metadata to the logger and the context, such as commit id and PR number
func (*PullRequestEvent) Created ¶
func (r *PullRequestEvent) Created() time.Time
Created returns a time when the event was originated
func (*PullRequestEvent) GetCommit ¶
func (r *PullRequestEvent) GetCommit() string
GetCommit returns commit associated with the event
func (*PullRequestEvent) GetSource ¶
func (r *PullRequestEvent) GetSource() Source
GetSource returns source associated with the event
func (*PullRequestEvent) String ¶
func (r *PullRequestEvent) String() string
type PullRequestObject ¶
type PullRequestObject struct {
ID string
Number int
Title string
URL string
BaseRefName string
HeadRefName string
Repository struct {
URL string
}
IsCrossRepository bool
}
PullRequestObject represents the GraphQL commit node. https://developer.github.com/v4/object/pullrequest/
type PullRequestWatcher ¶
type PullRequestWatcher struct {
// contains filtered or unexported fields
}
PullRequestWatcher is a repository watcher
func (*PullRequestWatcher) Done ¶
func (r *PullRequestWatcher) Done() <-chan struct{}
Done returns channel closed when repository watcher is closed
func (*PullRequestWatcher) Events ¶
func (r *PullRequestWatcher) Events() <-chan force.Event
Events returns events stream on a repository
func (*PullRequestWatcher) MarshalCode ¶
func (r *PullRequestWatcher) MarshalCode(ctx force.ExecutionContext) ([]byte, error)
MarshalCode marshals things to code
func (*PullRequestWatcher) Start ¶
func (r *PullRequestWatcher) Start(pctx context.Context) error
Start starts watch on a repo
func (*PullRequestWatcher) String ¶
func (r *PullRequestWatcher) String() string
String returns user friendly representation of the watcher
type RefObject ¶
RefObject represents the GraphQL ref node https://developer.github.com/v4/object/ref/
type Repository ¶
type Repository struct {
// Owner is a repository owner
Owner string
// Name is a repository name
Name string
}
Repository is a github repository
type Setup ¶
type Setup struct {
// contains filtered or unexported fields
}
Setup creates new instances of plugins
func (*Setup) MarshalCode ¶
func (n *Setup) MarshalCode(ctx force.ExecutionContext) ([]byte, error)
MarshalCode marshals plugin setup to code representation
func (*Setup) NewInstance ¶
NewInstance returns a new instance
type Source ¶
type Source struct {
// Repo is a repository name to watch
Repo string
// BranchPattern is a branch regexp pattern to watch PRs against
BranchPattern string
// Approval sets up approval process
Approval Approval
// Trigger configures trigger
Trigger Trigger
// Path filters out commits without changes matching the path (directory)
Path string
}
Source is a source repository to watch
func (*Source) BranchRegexp ¶
BranchRegexp returns branch match regexp
func (*Source) CheckAndSetDefaults ¶
CheckAndSetDefaults checks and sets default values
func (Source) Repository ¶
func (s Source) Repository() (*Repository, error)
Repository returns repository address
type Status ¶
type Status struct {
// State is a PR state
State string
// URL is a url of this web app, force should provide a web interface
URL string
// Description is an optional description
Description string
// Context is a special label that differentiates this application
Context string
}