Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #344

Merged
merged 10 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
timezone: "America/New_York"
reviewers:
- jacobweinstock

- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
timezone: "America/New_York"
reviewers:
- jacobweinstock

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "05:00"
timezone: "America/New_York"
reviewers:
- jacobweinstock
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ FLAGS
-backend-kube-namespace [backend] an optional Kubernetes namespace override to query hardware data from, kube backend only
-dhcp-addr [dhcp] local IP and port to listen on for DHCP requests (default "0.0.0.0:67")
-dhcp-enabled [dhcp] enable DHCP server (default "true")
-dhcp-http-ipxe-binary-ip [dhcp] http ipxe binary server IP address to use in DHCP packets (default "http://172.17.0.2:8080/ipxe/")
-dhcp-http-ipxe-script-url [dhcp] http ipxe script server URL to use in DHCP packets (default "http://172.17.0.2/auto.ipxe")
-dhcp-http-ipxe-binary-url [dhcp] HTTP ipxe binaries URL to use in DHCP packets (default "http://172.17.0.2:8080/ipxe/")
-dhcp-http-ipxe-script-url [dhcp] HTTP ipxe script URL to use in DHCP packets (default "http://172.17.0.2/auto.ipxe")
-dhcp-ip-for-packet [dhcp] ip address to use in DHCP packets (opt 54, etc) (default "172.17.0.2")
-dhcp-syslog-ip [dhcp] syslog server IP address to use in DHCP packets (opt 7) (default "172.17.0.2")
-dhcp-tftp-ip [dhcp] tftp server IP address to use in DHCP packets (opt 66, etc) (default "172.17.0.2:69")
Expand Down
4 changes: 2 additions & 2 deletions cmd/smee/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func dhcpFlags(c *config, fs *flag.FlagSet) {
fs.StringVar(&c.dhcp.ipForPacket, "dhcp-ip-for-packet", detectPublicIPv4(""), "[dhcp] IP address to use in DHCP packets (opt 54, etc)")
fs.StringVar(&c.dhcp.syslogIP, "dhcp-syslog-ip", detectPublicIPv4(""), "[dhcp] syslog server IP address to use in DHCP packets (opt 7)")
fs.StringVar(&c.dhcp.tftpIP, "dhcp-tftp-ip", detectPublicIPv4(":69"), "[dhcp] tftp server IP address to use in DHCP packets (opt 66, etc)")
fs.StringVar(&c.dhcp.httpIpxeBinaryIP, "dhcp-http-ipxe-binary-ip", "http://"+detectPublicIPv4(":8080/ipxe/"), "[dhcp] HTTP ipxe binary server IP address to use in DHCP packets")
fs.StringVar(&c.dhcp.httpIpxeScriptURL, "dhcp-http-ipxe-script-url", "http://"+detectPublicIPv4("/auto.ipxe"), "[dhcp] HTTP ipxe script server URL to use in DHCP packets")
fs.StringVar(&c.dhcp.httpIpxeBinaryURL, "dhcp-http-ipxe-binary-url", "http://"+detectPublicIPv4(":8080/ipxe/"), "[dhcp] HTTP ipxe binaries URL to use in DHCP packets")
fs.StringVar(&c.dhcp.httpIpxeScriptURL, "dhcp-http-ipxe-script-url", "http://"+detectPublicIPv4("/auto.ipxe"), "[dhcp] HTTP ipxe script URL to use in DHCP packets")
}

func backendFlags(c *config, fs *flag.FlagSet) {
Expand Down
8 changes: 4 additions & 4 deletions cmd/smee/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestParser(t *testing.T) {
ipForPacket: "192.168.2.4",
syslogIP: "192.168.2.4",
tftpIP: "192.168.2.4:69",
httpIpxeBinaryIP: "http://192.168.2.4:8080/ipxe/",
httpIpxeBinaryURL: "http://192.168.2.4:8080/ipxe/",
httpIpxeScriptURL: "http://192.168.2.4/auto.ipxe",
},
logLevel: "info",
Expand All @@ -52,7 +52,7 @@ func TestParser(t *testing.T) {
"-dhcp-ip-for-packet", "192.168.2.4",
"-dhcp-syslog-ip", "192.168.2.4",
"-dhcp-tftp-ip", "192.168.2.4:69",
"-dhcp-http-ipxe-binary-ip", "http://192.168.2.4:8080/ipxe/",
"-dhcp-http-ipxe-binary-url", "http://192.168.2.4:8080/ipxe/",
"-dhcp-http-ipxe-script-url", "http://192.168.2.4/auto.ipxe",
}
cli := newCLI(&got, fs)
Expand Down Expand Up @@ -86,8 +86,8 @@ FLAGS
-backend-kube-namespace [backend] an optional Kubernetes namespace override to query hardware data from, kube backend only
-dhcp-addr [dhcp] local IP:Port to listen on for DHCP requests (default "0.0.0.0:67")
-dhcp-enabled [dhcp] enable DHCP server (default "true")
-dhcp-http-ipxe-binary-ip [dhcp] HTTP ipxe binary server IP address to use in DHCP packets (default "http://%[1]v:8080/ipxe/")
-dhcp-http-ipxe-script-url [dhcp] HTTP ipxe script server URL to use in DHCP packets (default "http://%[1]v/auto.ipxe")
-dhcp-http-ipxe-binary-url [dhcp] HTTP ipxe binaries URL to use in DHCP packets (default "http://%[1]v:8080/ipxe/")
-dhcp-http-ipxe-script-url [dhcp] HTTP ipxe script URL to use in DHCP packets (default "http://%[1]v/auto.ipxe")
-dhcp-ip-for-packet [dhcp] IP address to use in DHCP packets (opt 54, etc) (default "%[1]v")
-dhcp-syslog-ip [dhcp] syslog server IP address to use in DHCP packets (opt 7) (default "%[1]v")
-dhcp-tftp-ip [dhcp] tftp server IP address to use in DHCP packets (opt 66, etc) (default "%[1]v:69")
Expand Down
45 changes: 26 additions & 19 deletions cmd/smee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"flag"
"fmt"
"net"
"net/netip"
"net/url"
"os"
Expand All @@ -16,6 +17,7 @@ import (
"github.com/equinix-labs/otel-init-go/otelinit"
"github.com/go-logr/logr"
"github.com/go-logr/zapr"
"github.com/insomniacslk/dhcp/dhcpv4/server4"
"github.com/tinkerbell/dhcp"
"github.com/tinkerbell/dhcp/handler"
"github.com/tinkerbell/dhcp/handler/reservation"
Expand Down Expand Up @@ -83,7 +85,7 @@ type dhcpConfig struct {
ipForPacket string
syslogIP string
tftpIP string
httpIpxeBinaryIP string
httpIpxeBinaryURL string
httpIpxeScriptURL string
}

Expand Down Expand Up @@ -206,14 +208,25 @@ func main() {

// dhcp server
if cfg.dhcp.enabled {
listener, dh, err := cfg.dhcpListener(ctx, log)
dh, err := cfg.dhcpHandler(ctx, log)
if err != nil {
log.Error(err, "failed to create dhcp listener")
panic(fmt.Errorf("failed to create dhcp listener: %w", err))
}
log.Info("starting dhcp server", "bind_addr", cfg.dhcp.bindAddr)
g.Go(func() error {
return listener.ListenAndServe(ctx, dh)
bindAddr, err := netip.ParseAddrPort(cfg.dhcp.bindAddr)
if err != nil {
panic(fmt.Errorf("invalid tftp address for DHCP server: %w", err))
}
conn, err := server4.NewIPv4UDPConn("", net.UDPAddrFromAddrPort(bindAddr))
if err != nil {
panic(err)
}
defer conn.Close()
ds := &dhcp.Server{Logger: log, Conn: conn, Handlers: []dhcp.Handler{dh}}

return ds.Serve(ctx)
})
}

Expand All @@ -224,31 +237,29 @@ func main() {
log.Info("smee is shutting down")
}

func (c *config) dhcpListener(ctx context.Context, log logr.Logger) (*dhcp.Listener, *reservation.Handler, error) {
func (c *config) dhcpHandler(ctx context.Context, log logr.Logger) (*reservation.Handler, error) {
// 1. create the handler
// 2. create the backend
// 3. add the backend to the handler
// 4. create the listener
// 5. start the listener(handler)
pktIP, err := netip.ParseAddr(c.dhcp.ipForPacket)
if err != nil {
return nil, nil, fmt.Errorf("invalid bind address: %w", err)
return nil, fmt.Errorf("invalid bind address: %w", err)
}
tftpIP, err := netip.ParseAddrPort(c.dhcp.tftpIP)
if err != nil {
return nil, nil, fmt.Errorf("invalid tftp address for DHCP server: %w", err)
return nil, fmt.Errorf("invalid tftp address for DHCP server: %w", err)
}
httpBinaryURL, err := url.Parse(c.dhcp.httpIpxeBinaryIP)
httpBinaryURL, err := url.Parse(c.dhcp.httpIpxeBinaryURL)
if err != nil || httpBinaryURL == nil {
return nil, nil, fmt.Errorf("invalid http ipxe binary url: %w", err)
return nil, fmt.Errorf("invalid http ipxe binary url: %w", err)
}
httpScriptURL, err := url.Parse(c.dhcp.httpIpxeScriptURL)
if err != nil || httpScriptURL == nil {
return nil, nil, fmt.Errorf("invalid http ipxe script url: %w", err)
return nil, fmt.Errorf("invalid http ipxe script url: %w", err)
}
syslogIP, err := netip.ParseAddr(c.dhcp.syslogIP)
if err != nil {
return nil, nil, fmt.Errorf("invalid syslog address: %w", err)
return nil, fmt.Errorf("invalid syslog address: %w", err)
}
dh := &reservation.Handler{
Backend: nil,
Expand All @@ -269,22 +280,18 @@ func (c *config) dhcpListener(ctx context.Context, log logr.Logger) (*dhcp.Liste
case c.backends.file.Enabled:
b, err := c.backends.file.Backend(ctx, log)
if err != nil {
return nil, nil, fmt.Errorf("failed to create file backend: %w", err)
return nil, fmt.Errorf("failed to create file backend: %w", err)
}
dh.Backend = b
default: // default backend is kubernetes
b, err := c.backends.kubernetes.Backend(ctx)
if err != nil {
return nil, nil, fmt.Errorf("failed to create kubernetes backend: %w", err)
return nil, fmt.Errorf("failed to create kubernetes backend: %w", err)
}
dh.Backend = b
}
bindAddr, err := netip.ParseAddrPort(c.dhcp.bindAddr)
if err != nil {
return nil, nil, fmt.Errorf("invalid tftp address for DHCP server: %w", err)
}

return &dhcp.Listener{Addr: bindAddr}, dh, nil
return dh, nil
}

// defaultLogger is zap logr implementation.
Expand Down
92 changes: 46 additions & 46 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,100 +3,100 @@ module github.com/tinkerbell/smee
go 1.20

require (
github.com/equinix-labs/otel-init-go v0.0.8
github.com/equinix-labs/otel-init-go v0.0.9
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.4
github.com/google/go-cmp v0.5.9
github.com/insomniacslk/dhcp v0.0.0-20230908212754-65c27093e38a
github.com/packethost/xff v0.0.0-20190305172552-d3e9190c41b3
github.com/peterbourgon/ff/v3 v3.4.0
github.com/prometheus/client_golang v1.16.0
github.com/tinkerbell/dhcp v0.0.0-20230805015827-0f48a3240de4
github.com/tinkerbell/ipxedust v0.0.0-20230724133306-6eefab8af845
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0
go.opentelemetry.io/otel v1.16.0
go.opentelemetry.io/otel/trace v1.16.0
go.uber.org/zap v1.25.0
golang.org/x/sync v0.3.0
k8s.io/client-go v0.28.0
github.com/prometheus/client_golang v1.17.0
github.com/tinkerbell/dhcp v0.0.0-20231005170012-b334cc8fa1ce
github.com/tinkerbell/ipxedust v0.0.0-20231005170705-152536cb4cf6
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0
go.opentelemetry.io/otel v1.19.0
go.opentelemetry.io/otel/trace v1.19.0
go.uber.org/zap v1.26.0
golang.org/x/sync v0.4.0
k8s.io/client-go v0.28.2
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zerologr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.9.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/insomniacslk/dhcp v0.0.0-20230731140434-0f9eb93a696c // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pin/tftp/v3 v3.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rs/zerolog v1.29.1 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rs/zerolog v1.31.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tinkerbell/tink v0.9.0 // indirect
github.com/u-root/uio v0.0.0-20230305220412-3e8cd9d6bf63 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/sdk v1.16.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/net v0.13.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20231005195138-3e424a577f31 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/grpc v1.58.2 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.28.0 // indirect
k8s.io/apimachinery v0.28.0 // indirect
k8s.io/api v0.28.2 // indirect
k8s.io/apimachinery v0.28.2 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230718181711-3c0fae5ee9fd // indirect
k8s.io/kube-openapi v0.0.0-20230928205116-a78145627833 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/controller-runtime v0.15.0 // indirect
sigs.k8s.io/controller-runtime v0.16.2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
Expand Down
Loading
Loading