diff --git a/pixiecore/booters.go b/pixiecore/booters.go index a83daa8..cdeab20 100644 --- a/pixiecore/booters.go +++ b/pixiecore/booters.go @@ -257,7 +257,7 @@ func (b *apibooter) ReadBootFile(id ID) (io.ReadCloser, int64, error) { } var ( ret io.ReadCloser - sz int64 = -1 + sz int64 ) if u.Scheme == "file" { // TODO serveFile @@ -284,9 +284,9 @@ func (b *apibooter) ReadBootFile(id ID) (io.ReadCloser, int64, error) { } ret, sz, err = resp.Body, resp.ContentLength, nil - } - if err != nil { - return nil, -1, err + if err != nil { + return nil, -1, err + } } return ret, sz, nil } diff --git a/pixiecore/cli/bootipv6cmd.go b/pixiecore/cli/bootipv6cmd.go index 4d51a32..e001c81 100644 --- a/pixiecore/cli/bootipv6cmd.go +++ b/pixiecore/cli/bootipv6cmd.go @@ -2,12 +2,13 @@ package cli import ( "fmt" + "net" + "strings" + "github.com/spf13/cobra" "go.universe.tf/netboot/dhcp6" "go.universe.tf/netboot/dhcp6/pool" "go.universe.tf/netboot/pixiecore" - "net" - "strings" ) // pixiecore bootipv6 --listen-addr=2001:db8:f00f:cafe::4/64 --httpboot-url=http://[2001:db8:f00f:cafe::4]/bootx64.efi --ipxe-url=http://[2001:db8:f00f:cafe::4]/script.ipxe @@ -41,7 +42,6 @@ var bootIPv6Cmd = &cobra.Command{ if addr == "" { fatalf("Please specify address to bind to") - } else { } if ipxeURL == "" { fatalf("Please specify ipxe config file url") diff --git a/pixiecore/cli/ipv6apicmd.go b/pixiecore/cli/ipv6apicmd.go index 4ecfef9..54a5b82 100644 --- a/pixiecore/cli/ipv6apicmd.go +++ b/pixiecore/cli/ipv6apicmd.go @@ -2,13 +2,14 @@ package cli import ( "fmt" + "net" + "strings" + "time" + "github.com/spf13/cobra" "go.universe.tf/netboot/dhcp6" "go.universe.tf/netboot/dhcp6/pool" "go.universe.tf/netboot/pixiecore" - "net" - "strings" - "time" ) // pixiecore ipv6api --listen-addr=2001:db8:f00f:cafe::4 --api-request-url=http://[2001:db8:f00f:cafe::4]:8888 @@ -42,7 +43,6 @@ var ipv6ApiCmd = &cobra.Command{ if addr == "" { fatalf("Please specify address to bind to") - } else { } if apiURL == "" { fatalf("Please specify ipxe config file url") diff --git a/pixiecore/http_test.go b/pixiecore/http_test.go index 2fc6a38..23e5a3c 100644 --- a/pixiecore/http_test.go +++ b/pixiecore/http_test.go @@ -22,7 +22,6 @@ import ( "io/ioutil" "net/http" "net/http/httptest" - "sync" "testing" ) @@ -34,8 +33,6 @@ func (b booterFunc) ReadBootFile(id ID) (io.ReadCloser, int64, error) { } func (b booterFunc) WriteBootFile(id ID, r io.Reader) error { return errors.New("no") } -var logSync sync.Mutex - func TestIpxe(t *testing.T) { booter := func(m Machine) (*Spec, error) { return &Spec{ diff --git a/pixiecore/tftp.go b/pixiecore/tftp.go index 651e710..08b891f 100644 --- a/pixiecore/tftp.go +++ b/pixiecore/tftp.go @@ -60,12 +60,11 @@ func extractInfo(path string) (net.HardwareAddr, int, error) { } func (s *Server) logTFTPTransfer(clientAddr net.Addr, path string, err error) { - mac, _, err := extractInfo(path) - if err != nil { - // Unknown path, nothing to log. + mac, _, pathErr := extractInfo(path) + if pathErr != nil { + s.log("TFTP", "unable to extract mac from request:%v", pathErr) return } - if err != nil { s.log("TFTP", "Send of %q to %s failed: %s", path, clientAddr, err) } else {