webhook

package
v0.0.0-...-0542aae Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const StatusContext = "brigade"

StatusContext names the context for a particular status message.

Variables

View Source
var (
	StatePending = "pending"
	StateFailure = "failure"
	StateError   = "error"
	StateSuccess = "success"
)

State names for GitHub status

View Source
var ErrAuthFailed = errors.New("Auth Failed")

ErrAuthFailed indicates some part of the auth handshake failed

This is usually indicative of an auth failure between the client library and GitHub

Functions

func GetFileContents

func GetFileContents(proj *brigade.Project, ref, path string) ([]byte, error)

GetFileContents returns the contents for a particular file in the project.

func GetLastCommit

func GetLastCommit(proj *brigade.Project, ref string) (string, error)

GetLastCommit gets the last commit on the give reference (branch name or tag).

func GetRepoStatus

func GetRepoStatus(proj *brigade.Project, ref string) (*github.RepoStatus, error)

GetRepoStatus gets the Brigade repository status. The ref can be a SHA or a branch or tag.

func GhClient

func GhClient(gh brigade.Github) (*github.Client, error)

GhClient gets a new GitHub client object.

It authenticates with an OAUTH2 token.

If an enterpriseHost base URL is provided, this will attempt to connect to that instead of the hosted GitHub API server.

func InstallationTokenClient

func InstallationTokenClient(instToken, baseURL, uploadURL string) (*github.Client, error)

InstallationTokenClient uses an installation token to authenticate to the Github API.

func JWT

func JWT(appID string, keyPEM []byte) (string, error)

func NewGithubHookHandler

func NewGithubHookHandler(s storage.Store, authors []string, x509Key []byte, opts GithubOpts) gin.HandlerFunc

NewGithubHookHandler creates a GitHub webhook handler.

func SHA1HMAC

func SHA1HMAC(salt, message []byte) string

SHA1HMAC computes the GitHub SHA1 HMAC.

Types

type GithubOpts

type GithubOpts struct {
	AppID               int
	DefaultSharedSecret string
	EmittedEvents       []string
}

GithubOpts provides options for configuring a GitHub hook

type Payload

type Payload struct {
	Type         string      `json:"type"`
	Token        string      `json:"token"`
	TokenExpires time.Time   `json:"tokenExpires"`
	Body         interface{} `json:"body"`
	AppID        int         `json:"-"`
	InstID       int         `json:"-"`
	Commit       string      `json:"commit"`
	Branch       string      `json:"branch"`
}

Payload represents the data sent as the payload of an event.

Jump to

Keyboard shortcuts

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