|
| 1 | +package github |
| 2 | + |
| 3 | +import "github.com/joeybloggs/webhooks" |
| 4 | + |
| 5 | +// Webhook instance contains all methods needed to process events |
| 6 | +type Webhook struct { |
| 7 | + provider webhooks.Provider |
| 8 | +} |
| 9 | + |
| 10 | +// Config defines the configuration to create a new GitHubWebhook instance |
| 11 | +type Config struct { |
| 12 | + Provider webhooks.Provider |
| 13 | +} |
| 14 | + |
| 15 | +// Event defines a GitHub hook event type |
| 16 | +type Event string |
| 17 | + |
| 18 | +// GitHub hook types |
| 19 | +const ( |
| 20 | + // AnyEvent Event = "*" |
| 21 | + CommitCommentEvent Event = "commit_comment" |
| 22 | + CreateEvent Event = "create" |
| 23 | + DeleteEvent Event = "delete" |
| 24 | + DeploymentEvent Event = "deployment" |
| 25 | + DeploymentStatusEvent Event = "deployment_status" |
| 26 | + ForkEvent Event = "fork" |
| 27 | + GollumEvent Event = "gollum" |
| 28 | + IssueCommentEvent Event = "issue_comment" |
| 29 | + IssuesEvent Event = "issues" |
| 30 | + MemberEvent Event = "member" |
| 31 | + MembershipEvent Event = "membership" |
| 32 | + PageBuildEvent Event = "page_build" |
| 33 | + PublicEvent Event = "public" |
| 34 | + PullRequestReviewCommentEvent Event = "pull_request_review_comment" |
| 35 | + PullRequestEvent Event = "pull_request" |
| 36 | + PushEvent Event = "push" |
| 37 | + RepositoryEvent Event = "repository" |
| 38 | + ReleaseEvent Event = "release" |
| 39 | + StatusEvent Event = "status" |
| 40 | + TeamAddEvent Event = "team_add" |
| 41 | + WatchEvent Event = "watch" |
| 42 | +) |
| 43 | + |
| 44 | +// EventSubtype defines a GitHub Hook Event subtype |
| 45 | +type EventSubtype string |
| 46 | + |
| 47 | +// GitHub hook event subtypes |
| 48 | +const ( |
| 49 | + NoSubtype EventSubtype = "" |
| 50 | + BranchSubtype EventSubtype = "branch" |
| 51 | + TagSubtype EventSubtype = "tag" |
| 52 | + PullSubtype EventSubtype = "pull" |
| 53 | + IssueSubtype EventSubtype = "issues" |
| 54 | +) |
| 55 | + |
| 56 | +// Provider returns the Webhook's provider |
| 57 | +func (w Webhook) Provider() webhooks.Provider { |
| 58 | + return w.provider |
| 59 | +} |
| 60 | + |
| 61 | +// UnderlyingProvider returns the Config's Provider |
| 62 | +func (c Config) UnderlyingProvider() webhooks.Provider { |
| 63 | + return c.Provider |
| 64 | +} |
| 65 | + |
| 66 | +// New creates and returns a WebHook instance denoted by the Provider type |
| 67 | +func New(config *Config) *Webhook { |
| 68 | + return &Webhook{ |
| 69 | + provider: config.Provider, |
| 70 | + } |
| 71 | +} |
0 commit comments