1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-30 08:06:52 +02:00

Format go code.

This commit is contained in:
Benjamin Manns 2014-03-06 10:45:21 -08:00
parent 922993c258
commit baf468973f
6 changed files with 37 additions and 38 deletions

View File

@ -514,7 +514,7 @@ func (b *Builder) writeProxyScript(dir string) error {
// map ip address to localhost
for _, container := range b.services {
// 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)
}
}

View File

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

View File

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

View File

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

View File

@ -1,2 +1 @@
package publish

View File

@ -1,11 +1,11 @@
package template
import (
"crypto/md5"
"errors"
"fmt"
"html/template"
"io"
"crypto/md5"
"strings"
"github.com/GeertJohan/go.rice"
@ -99,7 +99,7 @@ func init() {
h := md5.New()
io.WriteString(h, mainjs)
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
form, err := box.String("form.html")