Documentation
¶
Overview ¶
This package provides an interface to create, delete, and process webhook payloads.
Index ¶
- func Create(webhookName string, requireSecret bool, storeInRedis bool, timeZone string, ...) (string, string, string, error)
- func Delete(webhookID string, webhookName string, ...) error
- func GetSecret(webhookID string, webhookName string, ...) (string, error)
- func List(redisConfig redisTools.RedisConfiguration) ([]string, []string, []string, error)
- func MatchID(webhookName string, webhookID string, ...) (bool, error)
- type GitHubPayloadStruct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(webhookName string, requireSecret bool, storeInRedis bool, timeZone string, redisConfig redisTools.RedisConfiguration) (string, string, string, error)
Create creates a new webhook and returns the webhook ID, the (provided as input) webhook name, and webhook secret.
If you choose to not store the webhook in Redis, you will need to manage the webhook information yourself.
Note: webhookName is a string that identifies the webhook and should be unique
Note: requireSecret is a boolean that determines if a secret is required for the webhook and will be generated if true
Note: to use storeInRedis, you must have Redis configured. See the redisTools package for additional details on this
Note: timeZone can be any valid timezone string (e.g. "America/New_York")
func Delete ¶
func Delete(webhookID string, webhookName string, redisConfig redisTools.RedisConfiguration) error
Delete deletes a webhook by webhook ID or webhook name
Note: You can provide the webhook ID or webhook name, or both; It will match on either (First match wins)
Note: It is advised to provide the webhook ID over the webhook name for accuracy and performance
func GetSecret ¶
func GetSecret(webhookID string, webhookName string, redisConfig redisTools.RedisConfiguration) (string, error)
GetSecret returns the secret for a webhook by webhook ID or webhook name
func List ¶
func List(redisConfig redisTools.RedisConfiguration) ([]string, []string, []string, error)
List returns a list of all webhook IDs, names and keys stored in Redis
Note: If you did not store the webhooks in Redis initially, this function will return an empty list
func MatchID ¶
func MatchID(webhookName string, webhookID string, redisConfig redisTools.RedisConfiguration) (bool, error)
Matches webhook name and ID
Types ¶
type GitHubPayloadStruct ¶
type GitHubPayloadStruct struct {
Ref string `json:"ref"`
Before string `json:"before"`
After string `json:"after"`
Repository struct {
ID int `json:"id"`
NodeID string `json:"node_id"`
Name string `json:"name"`
FullName string `json:"full_name"`
Private bool `json:"private"`
} `json:"repository"`
Owner struct {
Name string `json:"name"`
Email string `json:"email"`
Login string `json:"login"`
ID int `json:"id"`
} `json:"owner"`
HTMLURL string `json:"html_url"`
PushedAt string `json:"pushed_at"`
GitURL string `json:"git_url"`
SSHURL string `json:"ssh_url"`
CloneURL string `json:"clone_url"`
Pusher struct {
Name string `json:"name"`
Email string `json:"email"`
} `json:"pusher"`
Organization struct {
Login string `json:"login"`
ID int `json:"id"`
NodeID string `json:"node_id"`
URL string `json:"url"`
} `json:"organization"`
Sender struct {
Login string `json:"login"`
ID int `json:"id"`
NodeID string `json:"node_id"`
} `json:"sender"`
Created bool `json:"created"`
Deleted bool `json:"deleted"`
Forced bool `json:"forced"`
Compare string `json:"compare"`
Commits []struct {
ID string `json:"id"`
TreeID string `json:"tree_id"`
Distinct bool `json:"distinct"`
Message string `json:"message"`
Timestamp string `json:"timestamp"`
URL string `json:"url"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
} `json:"author"`
Committer struct {
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
} `json:"committer"`
Added []string `json:"added"`
Removed []string `json:"removed"`
Modified []string `json:"modified"`
} `json:"commits"`
HeadCommit struct {
ID string `json:"id"`
TreeID string `json:"tree_id"`
Distinct bool `json:"distinct"`
Message string `json:"message"`
Timestamp string `json:"timestamp"`
URL string `json:"url"`
Author struct {
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
} `json:"author"`
Committer struct {
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
} `json:"committer"`
Added []string `json:"added"`
Removed []string `json:"removed"`
Modified []string `json:"modified"`
} `json:"head_commit"`
}
GitHubPayloadStruct struct for GitHub payload
var GHPS GitHubPayloadStruct
func (*GitHubPayloadStruct) GetGitHubPayload ¶
func (payloadItem *GitHubPayloadStruct) GetGitHubPayload(payloadFilePath string) *GitHubPayloadStruct
GetGitHubPayload simply returns the GitHubPayloadStruct given a file path
func (*GitHubPayloadStruct) GitHubPayload ¶
func (payloadItem *GitHubPayloadStruct) GitHubPayload(w http.ResponseWriter, r *http.Request, redisConfig redisTools.RedisConfiguration) *GitHubPayloadStruct
GitHubPayload is a function which processes a GitHub webhook payload and returns the payload as a GitHubPayloadStruct