app

package
v0.0.0-...-977da3d Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2016 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const SiteDescription = "A tiny app that protects mistakenly merging pull requests in progress"
View Source
const SiteTitle = "Wiplock"

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func GetOAuth2ClientForToken

func GetOAuth2ClientForToken(token string) *http.Client

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NewTemplate

func NewTemplate() *template.Template

func RandomString

func RandomString(len int) string

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type App

type App struct {
	HTMLTemplate *template.Template
	Port         int
	SessionStore *sessions.CookieStore
	AssetHash    string
	Secret       string
	ClientSecret string
	ClientID     string
	LockStoreKey string
	RedisConn    redis.Conn
}

func New

func New() (*App, error)

func Run

func Run() (*App, error)

func (*App) CreateContext

func (app *App) CreateContext(r *http.Request) *Context

func (*App) GetAccessToken

func (app *App) GetAccessToken(code string, state string) (string, error)

func (*App) GetAssetHash

func (app *App) GetAssetHash() error

func (*App) GetJavaScriptPath

func (app *App) GetJavaScriptPath() string

func (*App) GetOAuth2Config

func (app *App) GetOAuth2Config() *oauth2.Config

func (*App) GetSession

func (app *App) GetSession(r *http.Request) *sessions.Session

func (*App) HandleAsset

func (app *App) HandleAsset(w http.ResponseWriter, r *http.Request)

func (*App) HandleAuthenticate

func (app *App) HandleAuthenticate(w http.ResponseWriter, r *http.Request)

func (*App) HandleFavicon

func (app *App) HandleFavicon(w http.ResponseWriter, r *http.Request)

func (*App) HandleIndex

func (app *App) HandleIndex(w http.ResponseWriter, r *http.Request)

func (*App) HandleListRepos

func (app *App) HandleListRepos(w http.ResponseWriter, r *http.Request)

func (*App) HandleLockRepo

func (app *App) HandleLockRepo(w http.ResponseWriter, r *http.Request)

func (*App) HandleOAuthCallback

func (app *App) HandleOAuthCallback(w http.ResponseWriter, r *http.Request)

func (*App) HandlePullRequest

func (app *App) HandlePullRequest(payload PullRequestPayload) error

func (*App) HandleUnauthenticate

func (app *App) HandleUnauthenticate(w http.ResponseWriter, r *http.Request)

func (*App) HandleUnlockRepo

func (app *App) HandleUnlockRepo(w http.ResponseWriter, r *http.Request)

func (*App) HandleWebhook

func (app *App) HandleWebhook(w http.ResponseWriter, r *http.Request)

func (*App) ReconnectRedisIfNeeeded

func (app *App) ReconnectRedisIfNeeeded()

func (*App) SetupRedis

func (app *App) SetupRedis() error

func (*App) SetupRouter

func (app *App) SetupRouter() *mux.Router

func (*App) SetupSessionStore

func (app *App) SetupSessionStore()

type Context

type Context struct {
	AccessToken     string
	BodyClassName   string
	JavaScriptPath  string
	LockStoreKey    string
	RedisConn       redis.Conn
	Request         *http.Request
	Secret          string
	Session         *sessions.Session
	SiteDescription string
	SiteTitle       string
}

func (*Context) GetAccessToken

func (context *Context) GetAccessToken() string

func (*Context) GetHookURL

func (context *Context) GetHookURL() string

func (*Context) GetOAuth2Client

func (context *Context) GetOAuth2Client() *http.Client

func (*Context) GetRepos

func (context *Context) GetRepos() ([]Repository, error)

func (*Context) GetReposJson

func (context *Context) GetReposJson() ([]byte, error)

func (*Context) LockRepo

func (context *Context) LockRepo(org string, repo string) error

func (*Context) SetAccessToken

func (context *Context) SetAccessToken(token string, w http.ResponseWriter) error

func (*Context) UnlockRepo

func (context *Context) UnlockRepo(org string, repo string) error
type Head struct {
	Label string     `json:"label"`
	Ref   string     `json:"ref"`
	SHA   string     `json:"sha"`
	User  User       `json:"user"`
	Repo  Repository `json:"repo"`
}

Head contains GitHub's head information

type Owner

type Owner struct {
	User
}

Owner contains GitHub's owner information

type PullRequest

type PullRequest struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
	Body  string `json:"body"`
	Head  Head   `json:"head"`
}

PullRequest contains GitHub's pull_request information

type PullRequestPayload

type PullRequestPayload struct {
	PullRequest PullRequest `json:"pull_request"`
	Repository  Repository  `json:"repository"`
}

PullRequestPayload contains the information for GitHub's pull_request hook event

type Repository

type Repository struct {
	ID       *int         `json:"id,omitempty"`
	Owner    *github.User `json:"owner,omitempty"`
	Name     *string      `json:"name,omitempty"`
	HTMLURL  *string      `json:"html_url,omitempty"`
	Private  *bool        `json:"private"`
	Locked   bool         `json:"locked"`
	FullName string       `json:"full_name"`
}

func RepositoryFromGitHub

func RepositoryFromGitHub(repo *github.Repository) Repository

type User

type User struct {
	Login string `json:"login"`
}

User contains GitHub's user information

Jump to

Keyboard shortcuts

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