Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Apr 3, 2023
1 parent 3b24c1d commit dde75e9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
6 changes: 3 additions & 3 deletions cmd/boots/dhcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (d *dhcpConfig) serveDHCP(ctx context.Context, log logr.Logger) error {
return e
})
<-ctx.Done()
listener.Shutdown()
_ = listener.Shutdown()
err := g.Wait()
log.Info("shutting down dhcp server")
return err
Expand Down Expand Up @@ -91,7 +91,7 @@ func (d *dhcpConfig) addFlags(fs *flag.FlagSet) {
return nil
})
// This sets the default value for the flag when coupled with fs.Func.
fs.Set("dhcp-addr", "0.0.0.0:67")
_ = fs.Set("dhcp-addr", "0.0.0.0:67")

fs.Func("dhcp-public-ip", "[dhcp] public IP address where Boots will be available. Used for DHCP option 54", func(s string) error {
var p netaddr.IP
Expand All @@ -115,7 +115,7 @@ func (d *dhcpConfig) addFlags(fs *flag.FlagSet) {
d.handler.Netboot.IPXEScriptURL = &url.URL{Scheme: "http", Host: p.String(), Path: "/auto.ipxe"}
return nil
})
fs.Set("dhcp-public-ip", "0.0.0.0")
_ = fs.Set("dhcp-public-ip", "0.0.0.0")
fs.Func("ipxe-remote-tftp-addr", "[dhcp] remote IP:Port where iPXE binaries are served via TFTP.", func(s string) error {
if s == "" {
return nil
Expand Down
20 changes: 10 additions & 10 deletions cmd/boots/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,30 @@ func (h *httpConfig) addFlags(fs *flag.FlagSet) {
})
}

func (c *httpConfig) serveHTTP(ctx context.Context, log logr.Logger, ipxeBinaryHandler stdhttp.HandlerFunc, finder backend.HardwareFinder) error {
func (h *httpConfig) serveHTTP(ctx context.Context, log logr.Logger, ipxeBinaryHandler stdhttp.HandlerFunc, finder backend.HardwareFinder) error {
httpServer := &http.Config{
GitRev: GitRev,
StartTime: startTime,
Logger: log,
TrustedProxies: c.trustedProxies,
TrustedProxies: h.trustedProxies,
IPXEScript: &http.IPXEScript{
Finder: finder,
Logger: log,
OsieURL: c.osieURL,
ExtraKernelParams: strings.Split(c.extraKernelArgs, " "),
SyslogFQDN: c.publicSyslogIP,
TinkServerTLS: c.tinkServerTLS,
TinkServerGRPCAddr: c.tinkServerGRPCAddr,
OsieURL: h.osieURL,
ExtraKernelParams: strings.Split(h.extraKernelArgs, " "),
SyslogFQDN: h.publicSyslogIP,
TinkServerTLS: h.tinkServerTLS,
TinkServerGRPCAddr: h.tinkServerGRPCAddr,
},
}

srv := &stdhttp.Server{}
srv := &stdhttp.Server{} //nolint: gosec // Slowloris is handled by httpServer.ServeHTTP
g, ctx := errgroup.WithContext(ctx)
g.Go(func() error {
return httpServer.ServeHTTP(srv, c.addr, ipxeBinaryHandler)
return httpServer.ServeHTTP(srv, h.addr, ipxeBinaryHandler)
})
<-ctx.Done()
go srv.Shutdown(ctx)
go func() { _ = srv.Shutdown(ctx) }()
time.AfterFunc(time.Second*5, func() { srv.Close() })
err := g.Wait()
if errors.Is(err, stdhttp.ErrServerClosed) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/boots/ipxe.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (i *ipxeConfig) addTFTPFlags(fs *flag.FlagSet) {
return nil
})
// This sets the default value for the flag when coupled with fs.Func.
fs.Set("ipxe-tftp-addr", "0.0.0.0:69")
_ = fs.Set("ipxe-tftp-addr", "0.0.0.0:69")

// tftp timeout
fs.DurationVar(&i.TFTP.Timeout, "ipxe-tftp-timeout", time.Second*5, "[ipxe] local iPXE TFTP server requests timeout.")
Expand Down
13 changes: 5 additions & 8 deletions cmd/boots/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ import (
"golang.org/x/sync/errgroup"
)

var (
// GitRev is the git revision of the build. It is set by the Makefile.
GitRev = "unknown (use make)"
)

const name = "boots"

// GitRev is the git revision of the build. It is set by the Makefile.
var GitRev = "unknown (use make)"

type config struct {
// loglevel is the log level for boots.
logLevel string
Expand Down Expand Up @@ -71,8 +69,7 @@ func main() {
fs := flag.NewFlagSet(name, flag.ExitOnError)
cli := newCLI(cfg, fs)
if err := cli.Parse(os.Args[1:]); err != nil {
//fmt.Printf("type %T\n", err)
//fmt.Printf("error parsing cli, %v\n", err)
fmt.Printf("error parsing cli, %v\n", err)
os.Exit(1)
}

Expand Down Expand Up @@ -101,7 +98,7 @@ func main() {
lg := log.WithValues("service", "github.com/tinkerbell/boots").WithName("github.com/tinkerbell/ipxedust")
fn, err := cfg.ipxe.tftpServer(lg)
if err != nil {
return nil
return err
}
return fn(ctx)
})
Expand Down

0 comments on commit dde75e9

Please sign in to comment.