whreceiver

package
v0.0.0-...-f3ec421 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthNotSupported = errors.New("authorization header is not supported for this receiver, use secret signature instead")
View Source
var ErrSignNotSupported = errors.New("request signature is not supported for this receiver, use authorization header instead")

Functions

func GetPayloadSignature

func GetPayloadSignature(secret string, payload []byte) []byte

Types

type AuthorizationError

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

func (AuthorizationError) Error

func (err AuthorizationError) Error() string

type CommonWebhookPayload

type CommonWebhookPayload struct {
	Ref        string            `json:"ref"`
	After      string            `json:"after"`
	Repository CommonWebhookRepo `json:"repository"`
}

Common significant payload for push events for Gitea and Github

type CommonWebhookRepo

type CommonWebhookRepo struct {
	FullName string `json:"full_name"`
}

type GiteaReceiver

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

func (GiteaReceiver) Authorize

func (rcvr GiteaReceiver) Authorize(req WebhookPostRequest, auth string) (bool, error)

func (GiteaReceiver) GetCapabilities

func (rcvr GiteaReceiver) GetCapabilities() ReceiverCapabilities

func (GiteaReceiver) GetWebhookInfo

func (rcvr GiteaReceiver) GetWebhookInfo(req WebhookPostRequest) (*WebhookPostInfo, error)

func (GiteaReceiver) IsPingRequest

func (rcvr GiteaReceiver) IsPingRequest(req WebhookPostRequest) bool

func (GiteaReceiver) VerifySignature

func (rcvr GiteaReceiver) VerifySignature(req WebhookPostRequest, secret string) (bool, error)

type GithubReceiver

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

func (GithubReceiver) Authorize

func (rcvr GithubReceiver) Authorize(req WebhookPostRequest, auth string) (bool, error)

func (GithubReceiver) GetCapabilities

func (rcvr GithubReceiver) GetCapabilities() ReceiverCapabilities

func (GithubReceiver) GetWebhookInfo

func (rcvr GithubReceiver) GetWebhookInfo(req WebhookPostRequest) (*WebhookPostInfo, error)

func (GithubReceiver) IsPingRequest

func (rcvr GithubReceiver) IsPingRequest(req WebhookPostRequest) bool

func (GithubReceiver) VerifySignature

func (rcvr GithubReceiver) VerifySignature(req WebhookPostRequest, secret string) (bool, error)

type GitlabReceiver

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

func (GitlabReceiver) Authorize

func (rcvr GitlabReceiver) Authorize(req WebhookPostRequest, auth string) (bool, error)

func (GitlabReceiver) GetCapabilities

func (rcvr GitlabReceiver) GetCapabilities() ReceiverCapabilities

func (GitlabReceiver) GetWebhookInfo

func (rcvr GitlabReceiver) GetWebhookInfo(req WebhookPostRequest) (*WebhookPostInfo, error)

func (GitlabReceiver) IsPingRequest

func (rcvr GitlabReceiver) IsPingRequest(req WebhookPostRequest) bool

type IncorrectRepoError

type IncorrectRepoError struct {
	Expected string
	Actual   string
}

func (IncorrectRepoError) Error

func (err IncorrectRepoError) Error() string

type Receiver

type Receiver interface {
	Authorize(req WebhookPostRequest, auth string) (bool, error)
	VerifySignature(req WebhookPostRequest, secret string) (bool, error)
	IsPingRequest(req WebhookPostRequest) bool
	GetWebhookInfo(req WebhookPostRequest) (*WebhookPostInfo, error)
	GetCapabilities() ReceiverCapabilities
}

func New

func New(project config.Project) Receiver

type ReceiverCapabilities

type ReceiverCapabilities struct {
	CanAuthorize       bool
	CanVerifySignature bool
	HasPing            bool
}

type WebhookPostInfo

type WebhookPostInfo struct {
	DeliveryID string
	Branch     string
	Event      string
	// commit hash-id after applying the event ("after" field of payload)
	Hash string
}

type WebhookPostRequest

type WebhookPostRequest struct {
	Payload []byte
	Headers http.Header
}

Jump to

Keyboard shortcuts

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