webhook

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package webhook contains Inertia's webhook parsing code

Index

Constants

View Source
const (
	PushEvent EventType = "push"
	PullEvent EventType = "pull"
	PingEvent EventType = "ping"

	// Hosts
	GitHub    = "github"
	GitLab    = "gitlab"
	BitBucket = "bitbucket"
)

Constants for the generic webhook interface

Variables

View Source
var (
	GithubPingHeader = "ping"
	GithubPushHeader = "push"
)

x-github-event header values

View Source
var (
	BitbucketPushHeader = "repo:push"
)

x-event-key header values

View Source
var (
	GitlabPushHeader = "Push Hook"
)

x-gitlab-event header values

Functions

func Type added in v0.5.0

func Type(h http.Header) (host string, eventHeader string)

Type returns the git host and event header of given webhook request

func Verify added in v0.5.0

func Verify(host, key string, h http.Header, body []byte) (err error)

Verify ensures the payload's integrity and returns and error if anything doesn't match up

Types

type DockerWebhook added in v0.4.2

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

DockerWebhook represents a push to DockerHub see https://docs.docker.com/docker-hub/webhooks/

func ParseDocker added in v0.4.2

func ParseDocker(r *http.Request) (*DockerWebhook, error)

ParseDocker takes in a Docker webhook request and parses it

func (*DockerWebhook) GetName added in v0.4.2

func (d *DockerWebhook) GetName() string

GetName returns the namespace

func (*DockerWebhook) GetOwner added in v0.4.2

func (d *DockerWebhook) GetOwner() string

GetOwner returns the repository owner

func (*DockerWebhook) GetPusher added in v0.4.2

func (d *DockerWebhook) GetPusher() string

GetPusher returns the user that pushed to DockerHub

func (*DockerWebhook) GetRepoName added in v0.4.2

func (d *DockerWebhook) GetRepoName() string

GetRepoName returns the full repository name

func (*DockerWebhook) GetTag added in v0.4.2

func (d *DockerWebhook) GetTag() string

GetTag returns the tag that was pushed to DockerHub

type EventType added in v0.5.2

type EventType string

EventType denotes types of webhook events

type Payload

type Payload interface {
	GetSource() string
	GetEventType() EventType
	GetRepoName() string
	GetRef() string
	GetGitURL() string
	GetSSHURL() string
}

Payload represents a generic webhook payload

func Parse

func Parse(host, eventHeader string, h http.Header, body []byte) (Payload, error)

Parse takes in a webhook request and parses it into one of the supported types

Jump to

Keyboard shortcuts

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