webhooks

package
v0.0.0-...-c208585 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package webhooks provides the data structures and utilities related to the hooks

Index

Constants

This section is empty.

Variables

View Source
var Hooks = make(chan Ref)

Hooks is a channel of incoming webhooks

View Source
var Providers = make(map[string]func())

Providers is a map of the git webhook providers

View Source
var Webhooks = make(map[string]func(chi.Router))

Webhooks is a map of routes

Functions

func AddProvider

func AddProvider(name string, initProvider func())

AddProvider registers a git webhook provider

func AddRouteHandler

func AddRouteHandler(name string, route func(router chi.Router))

AddRouteHandler registers a git webhook route

func Hook

func Hook(r Ref)

Hook will put a Git Ref on the queue

func MustRegisterAll

func MustRegisterAll()

MustRegisterAll registers all webhook route functions

func ParseSecrets

func ParseSecrets(providername, secretList, envname string) [][]byte

ParseSecrets grabs secrets from the ENV at runtime

func RouteHandlers

func RouteHandlers(r chi.Router)

RouteHandlers registers the webhook functions to the route

Types

type Ref

type Ref struct {
	RepoID    string    `json:"repo_id"`
	Timestamp time.Time `json:"timestamp"`
	HTTPSURL  string    `json:"https_url"`
	SSHURL    string    `json:"ssh_url"`
	Rev       string    `json:"rev"`
	Ref       string    `json:"ref"`      // refs/tags/v0.0.1, refs/heads/master
	RefType   string    `json:"ref_type"` // tag, branch
	RefName   string    `json:"ref_name"`
	Owner     string    `json:"repo_owner"`
	Repo      string    `json:"repo_name"`
}

Ref represents typical git webhook info such as:

HTTPSURL ex: https://git@git.example.com/example/example.git
SSHURL   ex: ssh://git@git.example.com/example/example.git
Rev      ex: 00000000
Ref      ex: /refs/heads/master
Branch   ex: master
Repo     ex: example
Org      ex: example

func Accept

func Accept() Ref

Accept will pop a Git Ref off the queue

func New

func New(r Ref) *Ref

New returns a normalized Ref (Git reference)

func (*Ref) GetRefID

func (h *Ref) GetRefID() RefID

GetRefID returns a unique reference like "github.com/org/project#branch"

func (*Ref) GetRevID

func (h *Ref) GetRevID() RevID

GetRevID returns a unique reference like "github.com/org/project#abcd7890"

func (*Ref) GetURLSafeRefID

func (h *Ref) GetURLSafeRefID() URLSafeRefID

GetURLSafeRefID returns the URL-safe Base64 encoding of the RefID

func (*Ref) GetURLSafeRevID

func (h *Ref) GetURLSafeRevID() URLSafeRevID

GetURLSafeRevID returns the URL-safe Base64 encoding of the RevID

func (*Ref) String

func (h *Ref) String() string

String prints object as git.example.com#branch@rev

type RefID

type RefID string

RefID is a newtype string

type RevID

type RevID string

RevID is a newtype string

type URLSafeGitID

type URLSafeGitID string

URLSafeGitID is a newtype string

type URLSafeRefID

type URLSafeRefID string

URLSafeRefID is a newtype string

type URLSafeRevID

type URLSafeRevID string

URLSafeRevID is a newtype string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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