Merge pull request #167 from benmanns/formatting-vetting

Formatting and Vetting
This commit is contained in:
Brad Rydzewski 2014-03-06 15:46:40 -08:00
commit ef908ebb94
6 changed files with 37 additions and 40 deletions

View file

@ -121,8 +121,6 @@ func (b *Builder) Run() error {
b.BuildState.Finished = time.Now().UTC().Unix() b.BuildState.Finished = time.Now().UTC().Unix()
return nil return nil
} }
return nil
} }
func (b *Builder) setup() error { func (b *Builder) setup() error {
@ -514,7 +512,7 @@ func (b *Builder) writeProxyScript(dir string) error {
// map ip address to localhost // map ip address to localhost
for _, container := range b.services { for _, container := range b.services {
// create an entry for each port // create an entry for each port
for port, _ := range container.NetworkSettings.Ports { for port := range container.NetworkSettings.Ports {
proxyfile.Set(port.Port(), container.NetworkSettings.IPAddress) proxyfile.Set(port.Port(), container.NetworkSettings.IPAddress)
} }
} }

View file

@ -60,8 +60,8 @@ func RepoAdd(w http.ResponseWriter, r *http.Request, u *User) error {
return err return err
} }
data := struct { data := struct {
User *User User *User
Teams []*Team Teams []*Team
Settings *Settings Settings *Settings
}{u, teams, settings} }{u, teams, settings}
// if the user hasn't linked their GitHub account // if the user hasn't linked their GitHub account

View file

@ -1,9 +1,9 @@
package notify package notify
import ( import (
"fmt" "fmt"
irc "github.com/fluffle/goirc/client" irc "github.com/fluffle/goirc/client"
) )
const ( const (
@ -13,29 +13,30 @@ const (
) )
type IRC struct { type IRC struct {
Channel string `yaml:"channel,omitempty"` Channel string `yaml:"channel,omitempty"`
Nick string `yaml:"nick,omitempty"` Nick string `yaml:"nick,omitempty"`
Server string `yaml:"server,omitempty"` Server string `yaml:"server,omitempty"`
Started bool `yaml:"on_started,omitempty"` Started bool `yaml:"on_started,omitempty"`
Success bool `yaml:"on_success,omitempty"` Success bool `yaml:"on_success,omitempty"`
Failure bool `yaml:"on_failure,omitempty"` Failure bool `yaml:"on_failure,omitempty"`
SSL bool `yaml:"ssl,omitempty"` SSL bool `yaml:"ssl,omitempty"`
ClientStarted bool ClientStarted bool
Client *irc.Conn Client *irc.Conn
} }
func (i *IRC) Connect() { func (i *IRC) Connect() {
c := irc.SimpleClient(i.Nick) c := irc.SimpleClient(i.Nick)
c.SSL = i.SSL c.SSL = i.SSL
connected := make(chan bool) connected := make(chan bool)
c.AddHandler(irc.CONNECTED, c.AddHandler(irc.CONNECTED,
func(conn *irc.Conn, line *irc.Line) { func(conn *irc.Conn, line *irc.Line) {
conn.Join(i.Channel) conn.Join(i.Channel)
connected <- true}) connected <- true
c.Connect(i.Server) })
<-connected c.Connect(i.Server)
i.ClientStarted = true <-connected
i.Client = c i.ClientStarted = true
i.Client = c
} }
func (i *IRC) Send(context *Context) error { func (i *IRC) Send(context *Context) error {
@ -53,7 +54,7 @@ func (i *IRC) Send(context *Context) error {
func (i *IRC) sendStarted(context *Context) error { func (i *IRC) sendStarted(context *Context) error {
msg := fmt.Sprintf(ircStartedMessage, context.Repo.Name, context.Commit.HashShort(), context.Commit.Author) msg := fmt.Sprintf(ircStartedMessage, context.Repo.Name, context.Commit.HashShort(), context.Commit.Author)
i.send(i.Channel, msg) i.send(i.Channel, msg)
return nil return nil
} }
func (i *IRC) sendFailure(context *Context) error { func (i *IRC) sendFailure(context *Context) error {
@ -62,23 +63,22 @@ func (i *IRC) sendFailure(context *Context) error {
if i.ClientStarted { if i.ClientStarted {
i.Client.Quit() i.Client.Quit()
} }
return nil return nil
} }
func (i *IRC) sendSuccess(context *Context) error { func (i *IRC) sendSuccess(context *Context) error {
msg := fmt.Sprintf(ircSuccessMessage, context.Repo.Name, context.Commit.HashShort(), context.Commit.Author) msg := fmt.Sprintf(ircSuccessMessage, context.Repo.Name, context.Commit.HashShort(), context.Commit.Author)
i.send(i.Channel, msg) i.send(i.Channel, msg)
if i.ClientStarted { if i.ClientStarted {
i.Client.Quit() i.Client.Quit()
} }
return nil return nil
} }
func (i *IRC) send(channel string, message string) error { func (i *IRC) send(channel string, message string) error {
if !i.ClientStarted { if !i.ClientStarted {
i.Connect() i.Connect()
} }
i.Client.Notice(channel, message) i.Client.Notice(channel, message)
return nil return nil
} }

View file

@ -31,7 +31,7 @@ type Notification struct {
Email *Email `yaml:"email,omitempty"` Email *Email `yaml:"email,omitempty"`
Webhook *Webhook `yaml:"webhook,omitempty"` Webhook *Webhook `yaml:"webhook,omitempty"`
Hipchat *Hipchat `yaml:"hipchat,omitempty"` Hipchat *Hipchat `yaml:"hipchat,omitempty"`
Irc *IRC `yaml:"irc,omitempty"` Irc *IRC `yaml:"irc,omitempty"`
} }
func (n *Notification) Send(context *Context) error { func (n *Notification) Send(context *Context) error {
@ -50,10 +50,10 @@ func (n *Notification) Send(context *Context) error {
n.Hipchat.Send(context) n.Hipchat.Send(context)
} }
// send irc notifications // send irc notifications
if n.Irc != nil { if n.Irc != nil {
n.Irc.Send(context) n.Irc.Send(context)
} }
return nil return nil
} }

View file

@ -1,2 +1 @@
package publish package publish

View file

@ -1,11 +1,11 @@
package template package template
import ( import (
"crypto/md5"
"errors" "errors"
"fmt" "fmt"
"html/template" "html/template"
"io" "io"
"crypto/md5"
"strings" "strings"
"github.com/GeertJohan/go.rice" "github.com/GeertJohan/go.rice"
@ -99,7 +99,7 @@ func init() {
h := md5.New() h := md5.New()
io.WriteString(h, mainjs) io.WriteString(h, mainjs)
jshash := fmt.Sprintf("%x", h.Sum(nil)) jshash := fmt.Sprintf("%x", h.Sum(nil))
base = strings.Replace(base, "main.js", "main.js?h=" + jshash, 1) base = strings.Replace(base, "main.js", "main.js?h="+jshash, 1)
// extract the base form template as a string // extract the base form template as a string
form, err := box.String("form.html") form, err := box.String("form.html")