Documentation ¶
Index ¶
- Constants
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func GetOAuth2ClientForToken(token string) *http.Client
- func MustAsset(name string) []byte
- func NewTemplate() *template.Template
- func RandomString(len int) string
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type App
- func (app *App) CreateContext(r *http.Request) *Context
- func (app *App) GetAccessToken(code string, state string) (string, error)
- func (app *App) GetAssetHash() error
- func (app *App) GetJavaScriptPath() string
- func (app *App) GetOAuth2Config() *oauth2.Config
- func (app *App) GetSession(r *http.Request) *sessions.Session
- func (app *App) HandleAsset(w http.ResponseWriter, r *http.Request)
- func (app *App) HandleAuthenticate(w http.ResponseWriter, r *http.Request)
- func (app *App) HandleFavicon(w http.ResponseWriter, r *http.Request)
- func (app *App) HandleIndex(w http.ResponseWriter, r *http.Request)
- func (app *App) HandleListRepos(w http.ResponseWriter, r *http.Request)
- func (app *App) HandleLockRepo(w http.ResponseWriter, r *http.Request)
- func (app *App) HandleOAuthCallback(w http.ResponseWriter, r *http.Request)
- func (app *App) HandlePullRequest(payload PullRequestPayload) error
- func (app *App) HandleUnauthenticate(w http.ResponseWriter, r *http.Request)
- func (app *App) HandleUnlockRepo(w http.ResponseWriter, r *http.Request)
- func (app *App) HandleWebhook(w http.ResponseWriter, r *http.Request)
- func (app *App) ReconnectRedisIfNeeeded()
- func (app *App) SetupRedis() error
- func (app *App) SetupRouter() *mux.Router
- func (app *App) SetupSessionStore()
- type Context
- func (context *Context) GetAccessToken() string
- func (context *Context) GetHookURL() string
- func (context *Context) GetOAuth2Client() *http.Client
- func (context *Context) GetRepos() ([]Repository, error)
- func (context *Context) GetReposJson() ([]byte, error)
- func (context *Context) LockRepo(org string, repo string) error
- func (context *Context) SetAccessToken(token string, w http.ResponseWriter) error
- func (context *Context) UnlockRepo(org string, repo string) error
- type Head
- type Owner
- type PullRequest
- type PullRequestPayload
- type Repository
- type User
Constants ¶
const SiteDescription = "A tiny app that protects mistakenly merging pull requests in progress"
const SiteTitle = "Wiplock"
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
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 ¶
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 ¶
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 GetOAuth2ClientForToken ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func NewTemplate ¶
func RandomString ¶
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
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 (*App) GetAccessToken ¶
func (*App) GetAssetHash ¶
func (*App) GetJavaScriptPath ¶
func (*App) GetOAuth2Config ¶
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) SetupRouter ¶
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) GetHookURL ¶
func (*Context) GetOAuth2Client ¶
func (*Context) GetRepos ¶
func (context *Context) GetRepos() ([]Repository, error)
func (*Context) GetReposJson ¶
func (*Context) SetAccessToken ¶
func (context *Context) SetAccessToken(token string, w http.ResponseWriter) error
type Head ¶
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 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