Fix Go formatting in beam and dockerscript

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
Solomon Hykes 2014-04-22 16:09:42 -07:00
parent 1df27fa300
commit c5b6f20d56
11 changed files with 56 additions and 71 deletions

View file

@ -1,8 +1,8 @@
package beam package beam
import ( import (
"testing"
"github.com/dotcloud/docker/pkg/beam/data" "github.com/dotcloud/docker/pkg/beam/data"
"testing"
) )
func TestSendConn(t *testing.T) { func TestSendConn(t *testing.T) {

View file

@ -2,8 +2,8 @@ package data
import ( import (
"fmt" "fmt"
"strings"
"strconv" "strconv"
"strings"
) )
func Encode(obj map[string][]string) string { func Encode(obj map[string][]string) string {

BIN
beam/examples/beamsh/beamsh Executable file

Binary file not shown.

View file

@ -2,6 +2,7 @@ package main
import ( import (
"bufio" "bufio"
"flag"
"fmt" "fmt"
"github.com/dotcloud/docker/pkg/beam" "github.com/dotcloud/docker/pkg/beam"
"github.com/dotcloud/docker/pkg/beam/data" "github.com/dotcloud/docker/pkg/beam/data"
@ -14,7 +15,6 @@ import (
"path" "path"
"strings" "strings"
"sync" "sync"
"flag"
) )
var rootPlugins = []string{ var rootPlugins = []string{
@ -168,7 +168,6 @@ func executeScript(out beam.Sender, script []*dockerscript.Command) error {
return nil return nil
} }
// 1) Find a handler for the command (if no handler, fail) // 1) Find a handler for the command (if no handler, fail)
// 2) Attach new in & out pair to the handler // 2) Attach new in & out pair to the handler
// 3) [in the background] Copy handler output to our own output // 3) [in the background] Copy handler output to our own output
@ -217,10 +216,8 @@ func executeCommand(out beam.Sender, cmd *dockerscript.Command) error {
return nil return nil
} }
type Handler func([]string, io.Writer, io.Writer, beam.Receiver, beam.Sender) type Handler func([]string, io.Writer, io.Writer, beam.Receiver, beam.Sender)
func Handlers(sink beam.Sender) (*beam.UnixConn, error) { func Handlers(sink beam.Sender) (*beam.UnixConn, error) {
var tasks sync.WaitGroup var tasks sync.WaitGroup
pub, priv, err := beam.USocketPair() pub, priv, err := beam.USocketPair()
@ -329,11 +326,12 @@ func GetHandler(name string) Handler {
return nil return nil
} }
// VARIOUS HELPER FUNCTIONS: // VARIOUS HELPER FUNCTIONS:
func connToFile(conn net.Conn) (f *os.File, err error) { func connToFile(conn net.Conn) (f *os.File, err error) {
if connWithFile, ok := conn.(interface { File() (*os.File, error) }); !ok { if connWithFile, ok := conn.(interface {
File() (*os.File, error)
}); !ok {
return nil, fmt.Errorf("no file descriptor available") return nil, fmt.Errorf("no file descriptor available")
} else { } else {
f, err = connWithFile.File() f, err = connWithFile.File()
@ -386,7 +384,6 @@ func scriptString(script []*dockerscript.Command) string {
return fmt.Sprintf("'%s'", strings.Join(lines, "; ")) return fmt.Sprintf("'%s'", strings.Join(lines, "; "))
} }
func dialer(addr string) (chan net.Conn, error) { func dialer(addr string) (chan net.Conn, error) {
u, err := url.Parse(addr) u, err := url.Parse(addr)
if err != nil { if err != nil {
@ -430,8 +427,6 @@ func listener(addr string) (chan net.Conn, error) {
return connections, nil return connections, nil
} }
func SendToConn(connections chan net.Conn, src beam.Receiver) error { func SendToConn(connections chan net.Conn, src beam.Receiver) error {
var tasks sync.WaitGroup var tasks sync.WaitGroup
defer tasks.Wait() defer tasks.Wait()
@ -479,7 +474,6 @@ func SendToConn(connections chan net.Conn, src beam.Receiver) error {
return nil return nil
} }
func msgDesc(payload []byte, attachment *os.File) string { func msgDesc(payload []byte, attachment *os.File) string {
return beam.MsgDesc(payload, attachment) return beam.MsgDesc(payload, attachment)
} }
@ -534,7 +528,6 @@ func ReceiveFromConn(connections chan net.Conn, dst beam.Sender) error {
return nil return nil
} }
func bicopy(a, b io.ReadWriteCloser) { func bicopy(a, b io.ReadWriteCloser) {
var iotasks sync.WaitGroup var iotasks sync.WaitGroup
oneCopy := func(dst io.WriteCloser, src io.Reader) { oneCopy := func(dst io.WriteCloser, src io.Reader) {
@ -547,4 +540,3 @@ func bicopy(a, b io.ReadWriteCloser) {
go oneCopy(b, a) go oneCopy(b, a)
iotasks.Wait() iotasks.Wait()
} }

View file

@ -1,24 +1,23 @@
package main package main
import ( import (
"io" "bufio"
"os/exec" "fmt"
"github.com/dotcloud/docker/pkg/beam" "github.com/dotcloud/docker/pkg/beam"
"github.com/dotcloud/docker/pkg/beam/data" "github.com/dotcloud/docker/pkg/beam/data"
"github.com/dotcloud/docker/pkg/term" "github.com/dotcloud/docker/pkg/term"
"github.com/dotcloud/docker/utils" "github.com/dotcloud/docker/utils"
"text/template" "io"
"fmt"
"sync"
"os"
"strings"
"path"
"bufio"
"net" "net"
"net/url" "net/url"
"os"
"os/exec"
"path"
"strings"
"sync"
"text/template"
) )
func CmdLogger(args []string, stdout, stderr io.Writer, in beam.Receiver, out beam.Sender) { func CmdLogger(args []string, stdout, stderr io.Writer, in beam.Receiver, out beam.Sender) {
if err := os.MkdirAll("logs", 0700); err != nil { if err := os.MkdirAll("logs", 0700); err != nil {
fmt.Fprintf(stderr, "%v\n", err) fmt.Fprintf(stderr, "%v\n", err)

View file

@ -1,10 +1,10 @@
package beam package beam
import ( import (
"io"
"fmt" "fmt"
"os"
"github.com/dotcloud/docker/pkg/beam/data" "github.com/dotcloud/docker/pkg/beam/data"
"io"
"os"
) )
type Router struct { type Router struct {
@ -40,8 +40,6 @@ func (r *Router) NewRoute() *Route {
return route return route
} }
type Route struct { type Route struct {
rules []func([]byte, *os.File) bool rules []func([]byte, *os.File) bool
handler func([]byte, *os.File) error handler func([]byte, *os.File) error
@ -70,7 +68,6 @@ func (r *Route) HasAttachment() *Route {
return r return r
} }
func (route *Route) Tee(dst Sender) *Route { func (route *Route) Tee(dst Sender) *Route {
inner := route.handler inner := route.handler
route.handler = func(payload []byte, attachment *os.File) error { route.handler = func(payload []byte, attachment *os.File) error {
@ -125,7 +122,6 @@ func (r *Route) KeyStartsWith(k string, beginning ...string) *Route {
return r return r
} }
func (r *Route) KeyEquals(k string, full ...string) *Route { func (r *Route) KeyEquals(k string, full ...string) *Route {
r.rules = append(r.rules, func(payload []byte, attachment *os.File) bool { r.rules = append(r.rules, func(payload []byte, attachment *os.File) bool {
values := data.Message(payload).Get(k) values := data.Message(payload).Get(k)

View file

@ -3,9 +3,9 @@ package beam
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"testing"
"os" "os"
"sync" "sync"
"testing"
) )
type msg struct { type msg struct {
@ -17,7 +17,6 @@ func (m msg) String() string {
return MsgDesc(m.payload, m.attachment) return MsgDesc(m.payload, m.attachment)
} }
type mockReceiver []msg type mockReceiver []msg
func (r *mockReceiver) Send(p []byte, a *os.File) error { func (r *mockReceiver) Send(p []byte, a *os.File) error {

View file

@ -1,11 +1,11 @@
package beam package beam
import ( import (
"bufio"
"fmt" "fmt"
"net" "net"
"os" "os"
"syscall" "syscall"
"bufio"
) )
func debugCheckpoint(msg string, args ...interface{}) { func debugCheckpoint(msg string, args ...interface{}) {

View file

@ -1,8 +1,8 @@
package dockerscript package dockerscript
import ( import (
"github.com/dotcloud/docker/pkg/dockerscript/scanner"
"fmt" "fmt"
"github.com/dotcloud/docker/pkg/dockerscript/scanner"
"io" "io"
"strings" "strings"
) )

View file

@ -1,8 +1,8 @@
package scanner package scanner
import ( import (
"unicode"
"strings" "strings"
"unicode"
) )
// extra functions used to hijack the upstream text/scanner // extra functions used to hijack the upstream text/scanner
@ -19,4 +19,3 @@ func detectIdent(ch rune) bool {
} }
return false return false
} }