Documentation
¶
Overview ¶
package github implements the `whosonfirst/go-webhookd` interfaces for receiving and transforming webhooks originating from GitHub.
Index ¶
- func GenerateSignature(body string, secret string) (string, error)
- func NewGitHubCommitsTransformation(ctx context.Context, uri string) (webhookd.WebhookTransformation, error)
- func NewGitHubReceiver(ctx context.Context, uri string) (webhookd.WebhookReceiver, error)
- func NewGitHubRepoTransformation(ctx context.Context, uri string) (webhookd.WebhookTransformation, error)
- func UnmarshalEvent(event_type string, body []byte) (interface{}, error)
- type GitHubCommitsTransformation
- type GitHubReceiver
- type GitHubRepoTransformation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSignature ¶
GenerateSignature() generates a GitHub-compatiable signature derived from 'body' and 'secret'.
func NewGitHubCommitsTransformation ¶
func NewGitHubCommitsTransformation(ctx context.Context, uri string) (webhookd.WebhookTransformation, error)
NewGitHubCommitsTransformation() creates a new `GitHubCommitsTransformation` instance, configured by 'uri' which is expected to take the form of:
githubcommits://?{PARAMETERS}
Where {PARAMTERS} is: * `?exclude_additions` An optional boolean value to exclude newly added files from the final output. * `?exclude_modifications` An optional boolean value to exclude update (modified) files from the final output. * `?exclude_deletions` An optional boolean value to exclude deleted files from the final output. * `?prepend_message` An optional boolean value to prepend the commit message to the final output. This takes the form of '#message,{COMMIT_MESSAGE},' * `?prepend_author` An optional boolean value to prepend the name of the commit author to the final output. This takes the form of '#author,{COMMIT_AUTHOR},' * `?halt_on_message` An optional regular expression that will be compared to the commit message; if it matches the transformer will return an error with code `webhookd.HaltEvent` * `?halt_on_author` An optional regular expression that will be compared to the commit author; if it matches the transformer will return an error with code `webhookd.HaltEvent`
func NewGitHubReceiver ¶
NewGitHubReceiver instantiates a new `GitHubReceiver` for receiving webhook messages from GitHub, configured by 'uri' which is expected to take the form of:
github://?secret={SECRET}&ref={BRANCH}
Where {SECRET} is the shared secret used to generate signatures to validate messages and {BRANCH} is the optional branch (reference) name to limit message processing to.
func NewGitHubRepoTransformation ¶
func NewGitHubRepoTransformation(ctx context.Context, uri string) (webhookd.WebhookTransformation, error)
NewGitHubRepoTransformation() creates a new `GitHubRepoTransformation` instance, configured by 'uri' which is expected to take the form of:
githubrepo://?{PARAMETERS}
Where {PARAMTERS} is: * `?exclude_additions` An optional boolean value to exclude newly added files from consideration. * `?exclude_modifications` An optional boolean value to exclude update (modified) files from consideration. * `?exclude_deletions` An optional boolean value to exclude deleted files from consideration. * `?prepend_message` An optional boolean value to prepend the commit message to the final output. This takes the form of '#message {COMMIT_MESSAGE}' * `?prepend_author` An optional boolean value to prepend the name of the commit author to the final output. This takes the form of '#author {COMMIT_AUTHOR}' * `?halt_on_message` An optional regular expression that will be compared to the commit message; if it matches the transformer will return an error with code `webhookd.HaltEvent` * `?halt_on_author` An optional regular expression that will be compared to the commit author; if it matches the transformer will return an error with code `webhookd.HaltEvent`
func UnmarshalEvent ¶
UnmarshalEvent unmarshals a GitHub event message derived from 'body' in to an interface of type 'event_type'.
Types ¶
type GitHubCommitsTransformation ¶
type GitHubCommitsTransformation struct { webhookd.WebhookTransformation // ExcludeAdditions is a boolean flag to exclude newly added files from the final output. ExcludeAdditions bool // ExcludeModifications is a boolean flag to exclude updated (modified) files from the final output. ExcludeModifications bool // ExcludeDeletions is a boolean flag to exclude deleted files from the final output. ExcludeDeletions bool // contains filtered or unexported fields }
GitHubCommitsTransformation implements the `webhookd.WebhookTransformation` interface for transforming GitHub commit webhook messages in to CSV data containing: the commit hash, the name of the repository and the path to the file commited.
func (*GitHubCommitsTransformation) Transform ¶
func (p *GitHubCommitsTransformation) Transform(ctx context.Context, body []byte) ([]byte, *webhookd.WebhookError)
Transform() transforms 'body' (which is assumed to be a GitHub commit webhook message) in to CSV data containing: the commit hash, the name of the repository and the path to the file commited.
type GitHubReceiver ¶
type GitHubReceiver struct { webhookd.WebhookReceiver // contains filtered or unexported fields }
GitHubReceiver implements the `webhookd.WebhookReceiver` interface for receiving webhook messages from GitHub.
func (GitHubReceiver) Receive ¶
func (wh GitHubReceiver) Receive(ctx context.Context, req *http.Request) ([]byte, *webhookd.WebhookError)
Receive() returns the body of the message in 'req'. It ensures that messages are sent as HTTP `POST` requests, that both `X-GitHub-Event` and `X-Hub-Signature` headers are present, that message body produces a valid signature using the secret used to create 'wh' and, if necessary, that the message is associated with the branch used to create 'wh'.
type GitHubRepoTransformation ¶
type GitHubRepoTransformation struct { webhookd.WebhookTransformation // ExcludeAdditions is a boolean flag to exclude newly added files from consideration. ExcludeAdditions bool // ExcludeModifications is a boolean flag to exclude updated (modified) files from consideration. ExcludeModifications bool // ExcludeDeletions is a boolean flag to exclude updated (modified) files from consideration. ExcludeDeletions bool // contains filtered or unexported fields }
GitHubRepoTransformation implements the `webhookd.WebhookTransformation` interface for transforming GitHub commit webhook messages in to the name of the repository where the commit occurred.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
package cmd provides command line tools for working with go-webhookd-github services.
|
package cmd provides command line tools for working with go-webhookd-github services. |
webhookd-github
command
webhookd-github is a command line tool to start a go-webhookd daemon and serve requests over HTTP with support for whosonfirst/go-webhookd-github receivers and transformations.
|
webhookd-github is a command line tool to start a go-webhookd daemon and serve requests over HTTP with support for whosonfirst/go-webhookd-github receivers and transformations. |