Skip to content

Commit 4d0fcf2

Browse files
authored
Update to go-1.23, satisfy linter (#25)
1 parent 516176c commit 4d0fcf2

File tree

15 files changed

+113
-118
lines changed

15 files changed

+113
-118
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@ jobs:
3131
- name: Check out code into the Go module directory
3232
uses: actions/checkout@v4
3333

34-
- name: Set up Go 1.22
35-
uses: actions/setup-go@v4
34+
- name: Set up Go 1.23
35+
uses: actions/setup-go@v5
3636
with:
37-
go-version: "1.22"
37+
go-version: "1.23"
3838
cache: false
3939

40+
- name: make ipxe
41+
run: |
42+
make ipxe
43+
4044
- name: Lint
41-
uses: golangci/golangci-lint-action@v3
45+
uses: golangci/golangci-lint-action@v6
4246
with:
4347
args: -p bugs -p unused --timeout=3m
4448

@@ -49,7 +53,7 @@ jobs:
4953
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true
5054
5155
- name: Build and push image
52-
uses: docker/build-push-action@v4
56+
uses: docker/build-push-action@v6
5357
with:
5458
context: .
5559
push: true

.github/workflows/release-drafter.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: release-drafter/release-drafter@v5
13+
- uses: release-drafter/release-drafter@v6
1414
env:
1515
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# be aware that bookworm has a newer gcc which can not compile the older ipxe
2-
FROM golang:1.22-bullseye as builder
2+
FROM golang:1.23-bullseye as builder
33
WORKDIR /work
44
COPY . .
55
RUN apt update \
66
&& apt install --yes --no-install-recommends \
77
liblzma-dev \
88
&& make ipxe pixie
99

10-
FROM alpine:3.19
10+
FROM alpine:3.20
1111
RUN apk -U add ca-certificates
1212
COPY --from=builder /work/build/pixie /pixie
1313
ENTRYPOINT ["/pixie"]

dhcp4/conn_linux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func newLinuxConn(port int) (conn, error) {
5252
// Get UDP dport
5353
bpf.LoadIndirect{Off: 2, Size: 2},
5454
// Correct dport?
55-
bpf.JumpIf{Cond: bpf.JumpEqual, Val: uint32(port), SkipFalse: 1},
55+
bpf.JumpIf{Cond: bpf.JumpEqual, Val: uint32(port), SkipFalse: 1}, // nolint:gosec
5656
// Accept
5757
bpf.RetConstant{Val: 1500},
5858
// Ignore
@@ -81,7 +81,7 @@ func newLinuxConn(port int) (conn, error) {
8181
}
8282

8383
ret := &linuxConn{
84-
port: uint16(port),
84+
port: uint16(port), // nolint:gosec
8585
conn: r,
8686
}
8787
return ret, nil
@@ -108,9 +108,9 @@ func (c *linuxConn) Send(b []byte, addr *net.UDPAddr, ifidx int) error {
108108
// src port
109109
binary.BigEndian.PutUint16(raw[:2], c.port)
110110
// dst port
111-
binary.BigEndian.PutUint16(raw[2:4], uint16(addr.Port))
111+
binary.BigEndian.PutUint16(raw[2:4], uint16(addr.Port)) // nolint:gosec
112112
// length
113-
binary.BigEndian.PutUint16(raw[4:6], uint16(8+len(b)))
113+
binary.BigEndian.PutUint16(raw[4:6], uint16(8+len(b))) // nolint:gosec
114114
copy(raw[8:], b)
115115

116116
hdr := ipv4.Header{

dhcp4/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (o Options) Copy() Options {
146146
func (o Options) marshalLimited(w io.Writer, nBytes int, skip52 bool) (Options, error) {
147147
ks := make([]int, 0, len(o))
148148
for n := range o {
149-
if n <= 0 || n >= 255 {
149+
if n <= 0 || n >= 255 { // nolint:staticcheck
150150
return nil, fmt.Errorf("invalid DHCP option number %d", n)
151151
}
152152
ks = append(ks, int(n))
@@ -250,7 +250,7 @@ func (o Options) Int32(n Option) (int32, error) {
250250
if len(bs) != 4 {
251251
return 0, errOptionWrongSize
252252
}
253-
return int32(binary.BigEndian.Uint32(bs)), nil
253+
return int32(binary.BigEndian.Uint32(bs)), nil // nolint:gosec
254254
}
255255

256256
// IPs returns the value of option n as a list of IPv4 addresses.

dhcp6/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type Option struct {
6666

6767
// MakeOption creates an Option with given ID and value
6868
func MakeOption(id uint16, value []byte) *Option {
69-
return &Option{ID: id, Length: uint16(len(value)), Value: value}
69+
return &Option{ID: id, Length: uint16(len(value)), Value: value} // nolint:gosec
7070
}
7171

7272
// Options contains all options of a DHCPv6 packet

dhcp6/options_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
func TestMarshalOption(t *testing.T) {
1010
expectedURL := []byte("http://blah")
11-
expectedLength := uint16(len(expectedURL))
11+
expectedLength := uint16(len(expectedURL)) // nolint:gosec
1212
opt := &Option{ID: OptBootfileURL, Length: expectedLength, Value: expectedURL}
1313

1414
marshalled, err := opt.Marshal()
@@ -85,7 +85,7 @@ func TestMakeStatusOption(t *testing.T) {
8585
if noAddrOption.ID != OptStatusCode {
8686
t.Fatalf("Expected option id %d, got %d", OptStatusCode, noAddrOption.ID)
8787
}
88-
if noAddrOption.Length != uint16(2+len(expectedMessage)) {
88+
if noAddrOption.Length != uint16(2+len(expectedMessage)) { // nolint:gosec
8989
t.Fatalf("Expected option length of %d, got %d", 2+len(expectedMessage), noAddrOption.Length)
9090
}
9191
if binary.BigEndian.Uint16(noAddrOption.Value[0:2]) != expectedStatusCode {

dhcp6/packet_builder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dhcp6
22

33
import (
44
"encoding/binary"
5-
"fmt"
5+
"errors"
66
"net"
77
"testing"
88
)
@@ -144,7 +144,7 @@ func TestMakeNoAddrsAvailable(t *testing.T) {
144144

145145
builder := MakePacketBuilder(90, 100)
146146

147-
msg := builder.makeMsgAdvertiseWithNoAddrsAvailable(transactionID, expectedServerID, expectedClientID, fmt.Errorf(expectedMessage))
147+
msg := builder.makeMsgAdvertiseWithNoAddrsAvailable(transactionID, expectedServerID, expectedClientID, errors.New(expectedMessage))
148148

149149
if msg.Type != MsgAdvertise {
150150
t.Fatalf("Expected message type %d, got %d", MsgAdvertise, msg.Type)
@@ -306,7 +306,7 @@ func TestMakeMsgReplyWithNoAddrsAvailable(t *testing.T) {
306306

307307
msg := builder.makeMsgReply(transactionID, expectedServerID, expectedClientID, 0x10,
308308
[]*IdentityAssociation{identityAssociation}, [][]byte{[]byte("id-2")}, expectedBootFileURL, []net.IP{},
309-
fmt.Errorf(expectedErrorMessage))
309+
errors.New(expectedErrorMessage))
310310

311311
iaNaOption := msg.Options[OptIaNa]
312312
if iaNaOption == nil {

dhcp6/packet_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
func TestShouldDiscardSolicitWithoutBootfileUrlOption(t *testing.T) {
99
clientID := []byte("clientid")
1010
options := make(Options)
11-
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID})
11+
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID}) // nolint:gosec
1212
solicit := &Packet{Type: MsgSolicit, TransactionID: [3]byte{'1', '2', '3'}, Options: options}
1313

1414
if err := shouldDiscardSolicit(solicit); err == nil {
@@ -31,8 +31,8 @@ func TestShouldDiscardSolicitWithServerIdOption(t *testing.T) {
3131
clientID := []byte("clientid")
3232
options := make(Options)
3333
options.Add(MakeOptionRequestOptions([]uint16{OptBootfileURL}))
34-
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID})
35-
options.Add(&Option{ID: OptServerID, Length: uint16(len(serverID)), Value: serverID})
34+
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID}) // nolint:gosec
35+
options.Add(&Option{ID: OptServerID, Length: uint16(len(serverID)), Value: serverID}) // nolint:gosec
3636
solicit := &Packet{Type: MsgSolicit, TransactionID: [3]byte{'1', '2', '3'}, Options: options}
3737

3838
if err := shouldDiscardSolicit(solicit); err == nil {
@@ -44,8 +44,8 @@ func TestShouldDiscardRequestWithoutBootfileUrlOption(t *testing.T) {
4444
serverID := []byte("serverid")
4545
clientID := []byte("clientid")
4646
options := make(Options)
47-
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID})
48-
options.Add(&Option{ID: OptServerID, Length: uint16(len(serverID)), Value: serverID})
47+
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID}) // nolint:gosec
48+
options.Add(&Option{ID: OptServerID, Length: uint16(len(serverID)), Value: serverID}) // nolint:gosec
4949
request := &Packet{Type: MsgRequest, TransactionID: [3]byte{'1', '2', '3'}, Options: options}
5050

5151
if err := shouldDiscardRequest(request, serverID); err == nil {
@@ -57,7 +57,7 @@ func TestShouldDiscardRequestWithoutClientIdOption(t *testing.T) {
5757
serverID := []byte("serverid")
5858
options := make(Options)
5959
options.Add(MakeOptionRequestOptions([]uint16{OptBootfileURL}))
60-
options.Add(&Option{ID: OptServerID, Length: uint16(len(serverID)), Value: serverID})
60+
options.Add(&Option{ID: OptServerID, Length: uint16(len(serverID)), Value: serverID}) // nolint:gosec
6161
request := &Packet{Type: MsgRequest, TransactionID: [3]byte{'1', '2', '3'}, Options: options}
6262

6363
if err := shouldDiscardRequest(request, serverID); err == nil {
@@ -69,7 +69,7 @@ func TestShouldDiscardRequestWithoutServerIdOption(t *testing.T) {
6969
clientID := []byte("clientid")
7070
options := make(Options)
7171
options.Add(MakeOptionRequestOptions([]uint16{OptBootfileURL}))
72-
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID})
72+
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID}) // nolint:gosec
7373
request := &Packet{Type: MsgRequest, TransactionID: [3]byte{'1', '2', '3'}, Options: options}
7474

7575
if err := shouldDiscardRequest(request, []byte("serverid")); err == nil {
@@ -82,8 +82,8 @@ func TestShouldDiscardRequestWithWrongServerId(t *testing.T) {
8282
serverID := []byte("serverid")
8383
options := make(Options)
8484
options.Add(MakeOptionRequestOptions([]uint16{OptBootfileURL}))
85-
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID})
86-
options.Add(&Option{ID: OptServerID, Length: uint16(len(serverID)), Value: serverID})
85+
options.Add(&Option{ID: OptClientID, Length: uint16(len(clientID)), Value: clientID}) // nolint:gosec
86+
options.Add(&Option{ID: OptServerID, Length: uint16(len(serverID)), Value: serverID}) // nolint:gosec
8787
request := &Packet{Type: MsgRequest, TransactionID: [3]byte{'1', '2', '3'}, Options: options}
8888

8989
if err := shouldDiscardRequest(request, []byte("wrongid")); err == nil {
@@ -97,5 +97,5 @@ func MakeOptionRequestOptions(options []uint16) *Option {
9797
binary.BigEndian.PutUint16(value[i*2:], option)
9898
}
9999

100-
return &Option{ID: OptOro, Length: uint16(len(options) * 2), Value: value}
100+
return &Option{ID: OptOro, Length: uint16(len(options) * 2), Value: value} // nolint:gosec
101101
}

go.mod

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
11
module github.com/metal-stack/pixie
22

3-
go 1.22
3+
go 1.23
44

55
require (
6-
github.com/metal-stack/metal-api v0.26.3
6+
github.com/metal-stack/metal-api v0.34.0
77
github.com/metal-stack/v v1.0.3
88
github.com/pin/tftp/v3 v3.1.0
9-
github.com/prometheus/client_golang v1.18.0
10-
github.com/spf13/cobra v1.8.0
11-
github.com/spf13/viper v1.18.2
12-
github.com/stretchr/testify v1.8.4
13-
golang.org/x/crypto v0.19.0
14-
golang.org/x/net v0.21.0
15-
google.golang.org/grpc v1.61.0
9+
github.com/prometheus/client_golang v1.20.3
10+
github.com/spf13/cobra v1.8.1
11+
github.com/spf13/viper v1.19.0
12+
github.com/stretchr/testify v1.9.0
13+
golang.org/x/crypto v0.27.0
14+
golang.org/x/net v0.29.0
15+
google.golang.org/grpc v1.66.0
1616
)
1717

1818
require (
1919
github.com/beorn7/perks v1.0.1 // indirect
20-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
20+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2121
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2222
github.com/fsnotify/fsnotify v1.7.0 // indirect
23-
github.com/golang/protobuf v1.5.3 // indirect
2423
github.com/hashicorp/hcl v1.0.0 // indirect
2524
github.com/inconshreveable/mousetrap v1.1.0 // indirect
25+
github.com/klauspost/compress v1.17.9 // indirect
2626
github.com/magiconair/properties v1.8.7 // indirect
2727
github.com/mitchellh/mapstructure v1.5.0 // indirect
28-
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
28+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
29+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
2930
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
30-
github.com/prometheus/client_model v0.5.0 // indirect
31-
github.com/prometheus/common v0.46.0 // indirect
32-
github.com/prometheus/procfs v0.12.0 // indirect
33-
github.com/sagikazarmark/locafero v0.4.0 // indirect
31+
github.com/prometheus/client_model v0.6.1 // indirect
32+
github.com/prometheus/common v0.59.1 // indirect
33+
github.com/prometheus/procfs v0.15.1 // indirect
34+
github.com/sagikazarmark/locafero v0.6.0 // indirect
3435
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
3536
github.com/sourcegraph/conc v0.3.0 // indirect
3637
github.com/spf13/afero v1.11.0 // indirect
37-
github.com/spf13/cast v1.6.0 // indirect
38+
github.com/spf13/cast v1.7.0 // indirect
3839
github.com/spf13/pflag v1.0.5 // indirect
3940
github.com/subosito/gotenv v1.6.0 // indirect
4041
go.uber.org/multierr v1.11.0 // indirect
41-
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
42-
golang.org/x/sys v0.17.0 // indirect
43-
golang.org/x/text v0.14.0 // indirect
44-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect
45-
google.golang.org/protobuf v1.32.0 // indirect
42+
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
43+
golang.org/x/sys v0.25.0 // indirect
44+
golang.org/x/text v0.18.0 // indirect
45+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
46+
google.golang.org/protobuf v1.34.2 // indirect
4647
gopkg.in/ini.v1 v1.67.0 // indirect
4748
gopkg.in/yaml.v3 v3.0.1 // indirect
4849
)

0 commit comments

Comments
 (0)