mirror of
https://github.com/danderson/netboot.git
synced 2025-08-07 15:17:15 +02:00
Fix most of golangci-lint errors in the pixiecore package, keep unused logging function and unchecked errors in example
This commit is contained in:
parent
603e85bc4c
commit
f47ae40332
@ -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
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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{
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user