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

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

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

              func Verify

              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

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

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

                  func ParseDocker

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

                    ParseDocker takes in a Docker webhook request and parses it

                    func (*DockerWebhook) GetName

                    func (d *DockerWebhook) GetName() string

                      GetName returns the namespace

                      func (*DockerWebhook) GetOwner

                      func (d *DockerWebhook) GetOwner() string

                        GetOwner returns the repository owner

                        func (*DockerWebhook) GetPusher

                        func (d *DockerWebhook) GetPusher() string

                          GetPusher returns the user that pushed to DockerHub

                          func (*DockerWebhook) GetRepoName

                          func (d *DockerWebhook) GetRepoName() string

                            GetRepoName returns the full repository name

                            func (*DockerWebhook) GetTag

                            func (d *DockerWebhook) GetTag() string

                              GetTag returns the tag that was pushed to DockerHub

                              type EventType

                              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