deploy_docus

package
v0.0.0-...-b111207 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2014 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitHubLoginRequired martini.Handler = func() martini.Handler {
	failedLogin := func(req *http.Request, writer http.ResponseWriter, s sessions.Session) {
		s.Delete("oauth2_token")
		s.Delete("isAllowed")
		next := url.QueryEscape(req.URL.RequestURI())
		http.Redirect(writer, req, oauth2.PathLogin+"?next="+next, 302)
	}

	return func(s sessions.Session, token oauth2.Tokens, c martini.Context, writer http.ResponseWriter, req *http.Request, rend render.Render) {
		isAllowed := s.Get("isAllowed")

		if token == nil || token.IsExpired() {
			failedLogin(req, writer, s)
		} else if isAllowed != true {
			hub := BuildGitHub()
			client := hub.GetClient(token.Access())
			user, _, _ := client.Users.Get("")

			if user == nil {
				failedLogin(req, writer, s)
			} else if int64(*user.ID) == hub.OauthAllowedId {
				s.Set("isAllowed", true)
			} else {
				orgs, _, _ := client.Organizations.List("", &github.ListOptions{})
				for _, org := range orgs {
					if int64(*org.ID) == hub.OauthAllowedId {
						return
					}
				}

				rend.HTML(401, "not_allowed", nil)
			}
		}
	}
}()

Functions

func BuildPrivateKey

func BuildPrivateKey(content []byte) (*rsa.PrivateKey, error)

func Query

func Query(query string, args ...interface{}) (*sql.Rows, error)

func QueryRow

func QueryRow(query string, args ...interface{}) (*sql.Row, error)

func RepositoriesCount

func RepositoriesCount() (int64, error)

Types

type Cloner

type Cloner struct {
	Repository *Repository
	Path       string
}

func NewCloner

func NewCloner(repository *Repository, path string) *Cloner

func (*Cloner) BuildCmd

func (c *Cloner) BuildCmd() *exec.Cmd

func (*Cloner) Fetch

func (c *Cloner) Fetch() ([]byte, error)

type Database

type Database struct {
	*sql.DB
}

func GetDbConnection

func GetDbConnection() (*Database, error)

type GitHub

type GitHub struct {
	OauthKey         string
	OauthSecret      string
	OauthRedirectUri string
	OauthAllowedId   int64
	SessionToken     []byte
}

func BuildGitHub

func BuildGitHub() *GitHub

func (*GitHub) GetClient

func (g *GitHub) GetClient(token string) *github.Client

type Message

type Message struct {
	Id         int    `form:"id"`
	Sha        string `form:"sha"`
	Repository *Repository
}

type Pusher

type Pusher struct {
	Message *Message
	Path    string
}

func NewPusher

func NewPusher(message *Message, path string) *Pusher

func (*Pusher) BuildCmd

func (p *Pusher) BuildCmd() *exec.Cmd

func (*Pusher) Push

func (p *Pusher) Push() ([]byte, error)

func (*Pusher) Ref

func (p *Pusher) Ref() string

type Repository

type Repository struct {
	Id          int64
	Origin      string
	Destination string

	Rsa *Rsa
}

func AllRepositories

func AllRepositories() ([]Repository, error)

func BuildRepository

func BuildRepository(id int64, origin string, destination string, rsa_key []byte) *Repository

func FindRepository

func FindRepository(id int64) (*Repository, error)

func (*Repository) IsNew

func (r *Repository) IsNew() bool

func (*Repository) LocalPath

func (r *Repository) LocalPath() string

func (*Repository) Name

func (r *Repository) Name() string

func (*Repository) Save

func (r *Repository) Save() error

func (*Repository) Token

func (r *Repository) Token() string

type Rsa

type Rsa struct {
	Repository *Repository
	Private    *rsa.PrivateKey
}

func BuildRsa

func BuildRsa(repository *Repository, ssh_key []byte) *Rsa

func (*Rsa) Encrypt

func (r *Rsa) Encrypt(value []byte) (string, error)

func (*Rsa) KeyPath

func (r *Rsa) KeyPath(rootPath string) string

func (*Rsa) PrivateKey

func (r *Rsa) PrivateKey() ([]byte, error)

func (*Rsa) PublicKey

func (r *Rsa) PublicKey() string

func (*Rsa) WriteKey

func (r *Rsa) WriteKey(rootPath string) error

type Server

type Server struct {
	Port    int64
	Deploys chan Message
	Path    string

	*martini.ClassicMartini
}

func NewServer

func NewServer(port int64, channel chan Message, path string) *Server

func (*Server) Start

func (c *Server) Start()

Jump to

Keyboard shortcuts

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