webhook

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2017 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	StatusPending = "pending"
	StatusSuccess = "success"
	StatusError   = "error"
	StatusFailure = "failure"
)

Status codes, as defined by GitHub API v3 https://developer.github.com/v3/repos/statuses/

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 GitHubBaseURL = "https://api.github.com"

GitHubBaseURL is the base URL to the GitHub APIv3.

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 NewDockerPushHook

func NewDockerPushHook(s storage.Store) *dockerPushHook

NewDockerPushHook creates a new Docker Push handler for webhooks.

func NewGithubHook

func NewGithubHook(s storage.Store) *githubHook

NewGithubHook creates a GitHub webhook handler.

func SHA1HMAC

func SHA1HMAC(salt, message []byte) string

SHA1HMAC computes the GitHub SHA1 HMAC.

Types

type GitHubNotifier

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

GitHubNotifier sets GitHub status messages via the GitHub APIv3.

func NewGitHubNotifier

func NewGitHubNotifier(token string) *GitHubNotifier

NewGitHubNotifier creates a new GitHubNotifier

It requires a valid GitHub access token.

func (*GitHubNotifier) SetStatus

func (g *GitHubNotifier) SetStatus(status StatusCode, ctx, desc, target string) error

SetStatus sets the status code for a request.

func (*GitHubNotifier) SetTarget

func (g *GitHubNotifier) SetTarget(owner, repo, sha string) error

SetTarget sets the target of a GitHub notification.

type GitHubStatus

type GitHubStatus struct {
	State       StatusCode `json:"state"`
	TargetURL   string     `json:"target_url"`
	Description string     `json:"description"`
	Context     string     `json:"context"`
}

GitHubStatus defines the status format that GitHub expects

type StatusCode

type StatusCode string

StatusCode a GitHub status code

type StatusSetter

type StatusSetter interface {
	// SetTarget indicates the target that this status applies to
	//
	// owner and repo are the GitHub repository owner and repo names
	// (e.g. github.com/OWNER/REPO)
	//
	// sha is the commit shaw that this status applies to.
	SetTarget(owner, repo, sha string) error
	// SetStatus indicates the status.
	//
	// ctx is a context string that the remote system uses to distinguish multiple
	// status messages. A sane default is "brigade"
	//
	// desc is a human-oriented string that explains the status code
	//
	// targetURL is a callback that displays more information. It may be set to
	// ""
	SetStatus(status StatusCode, ctx, desc string, targetURL string) error
}

StatusSetter sets the status of a particular build.

Jump to

Keyboard shortcuts

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