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
import (
"testing"
"github.com/dotcloud/docker/pkg/beam/data"
"testing"
)
func TestSendConn(t *testing.T) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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