Skip to content

Commit

Permalink
ci, go.mod: bump to go 1.23 (#1094)
Browse files Browse the repository at this point in the history
* ci, go.mod: bump to go 1.23

Now that go.mod matches our go version, we can stop setting go version
in CI separately.

Signed-off-by: Casey Callendrello <[email protected]>

* minor: fix lint errors

Bumping golangci-lint to v1.61 introduced some new reasonable checks;
fix the errors they found.

Signed-off-by: Casey Callendrello <[email protected]>

* ci: bump golangci-lint to v1.61.0

Also, fix some deprecated config directives.

Signed-off-by: Casey Callendrello <[email protected]>

---------

Signed-off-by: Casey Callendrello <[email protected]>
  • Loading branch information
squeed committed Sep 17, 2024
1 parent cc8b1bd commit e5df283
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 45 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
matrix:
goarch: [amd64, arm, arm64, mips64le, ppc64le, riscv64, s390x]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22

- name: Checkout code
uses: actions/checkout@v4
go-version-file: go.mod

- name: Build
env:
Expand Down Expand Up @@ -68,13 +68,13 @@ jobs:
- name: Install dos2unix
run: sudo apt-get install dos2unix

- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Checkout code
uses: actions/checkout@v4
go-version-file: go.mod

- name: Build
env:
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
pull_request: {}

env:
# be sure to update the version in release.yaml too
GO_VERSION: "1.22"
LINUX_ARCHES: "amd64 386 arm arm64 s390x mips64le ppc64le riscv64"

jobs:
Expand All @@ -18,15 +16,14 @@ jobs:
- name: setup go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod
- uses: ibiqlik/action-yamllint@v3
with:
format: auto
- uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2
version: v1.61.0
args: -v
skip-cache: true
verify-vendor:
name: Verify vendor directory
runs-on: ubuntu-latest
Expand All @@ -35,7 +32,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod
- name: Check module vendoring
run: |
go mod tidy
Expand All @@ -50,7 +47,7 @@ jobs:
- name: setup go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod
- name: Build on all supported architectures
run: |
set -e
Expand All @@ -74,7 +71,7 @@ jobs:
- name: setup go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod
- name: Set up Go for root
run: |
sudo ln -sf `which go` `sudo which go` || true
Expand Down Expand Up @@ -105,6 +102,6 @@ jobs:
- name: setup go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod
- name: test
run: bash ./test_windows.sh
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ linters-settings:
- prefix(github.com/containernetworking)

run:
skip-dirs:
- vendor
timeout: 5m
modules-download-mode: vendor
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/containernetworking/plugins

go 1.21
go 1.23

require (
github.com/Microsoft/hcsshim v0.12.6
Expand Down
2 changes: 1 addition & 1 deletion pkg/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAnnotate(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if !reflect.DeepEqual(Annotatef(test.existingErr, test.contextMessage), test.expectedErr) {
if !reflect.DeepEqual(Annotate(test.existingErr, test.contextMessage), test.expectedErr) {
t.Errorf("test case %s fails", test.name)
return
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/link/spoofcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package link_test

import (
"errors"
"fmt"

"github.com/networkplumbing/go-nft/nft"
Expand Down Expand Up @@ -301,10 +302,10 @@ type configurerStub struct {
func (a *configurerStub) Apply(c *nft.Config) (*nft.Config, error) {
a.applyCounter++
if a.failFirstApplyConfig && a.applyCounter == 1 {
return nil, fmt.Errorf(errorFirstApplyText)
return nil, errors.New(errorFirstApplyText)
}
if a.failSecondApplyConfig && a.applyCounter == 2 {
return nil, fmt.Errorf(errorSecondApplyText)
return nil, errors.New(errorSecondApplyText)
}
a.applyConfig = append(a.applyConfig, c)
if a.applyReturnNil {
Expand All @@ -316,7 +317,7 @@ func (a *configurerStub) Apply(c *nft.Config) (*nft.Config, error) {
func (a *configurerStub) Read(_ ...string) (*nft.Config, error) {
a.readCalled = true
if a.failReadConfig {
return nil, fmt.Errorf(errorReadText)
return nil, errors.New(errorReadText)
}
return a.readConfig, nil
}
11 changes: 6 additions & 5 deletions plugins/ipam/host-local/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"errors"
"fmt"
"net"
"strings"
Expand Down Expand Up @@ -130,7 +131,7 @@ func cmdAdd(args *skel.CmdArgs) error {
for _, ip := range requestedIPs {
errstr = errstr + " " + ip.String()
}
return fmt.Errorf(errstr)
return errors.New(errstr)
}

result.Routes = ipamConf.Routes
Expand All @@ -151,18 +152,18 @@ func cmdDel(args *skel.CmdArgs) error {
defer store.Close()

// Loop through all ranges, releasing all IPs, even if an error occurs
var errors []string
var errs []string
for idx, rangeset := range ipamConf.Ranges {
ipAllocator := allocator.NewIPAllocator(&rangeset, store, idx)

err := ipAllocator.Release(args.ContainerID, args.IfName)
if err != nil {
errors = append(errors, err.Error())
errs = append(errs, err.Error())
}
}

if errors != nil {
return fmt.Errorf(strings.Join(errors, ";"))
if errs != nil {
return errors.New(strings.Join(errs, ";"))
}
return nil
}
1 change: 0 additions & 1 deletion plugins/main/host-device/host-device.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ func moveLinkOut(containerNs ns.NetNS, ifName string) error {
}
return nil
})

if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions plugins/meta/bandwidth/bandwidth_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ var _ = Describe("bandwidth config test", func() {
StdinData: []byte(conf),
}

Expect(hostNs.Do(func(netNS ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

_, _, err := testutils.CmdAdd(containerNs.Path(), args.ContainerID, "", []byte(conf), func() error { return cmdAdd(args) })
Expand Down Expand Up @@ -166,7 +166,7 @@ var _ = Describe("bandwidth config test", func() {
StdinData: []byte(conf),
}

Expect(hostNs.Do(func(netNS ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

_, _, err := testutils.CmdAdd(containerNs.Path(), args.ContainerID, "", []byte(conf), func() error { return cmdAdd(args) })
Expand Down Expand Up @@ -216,7 +216,7 @@ var _ = Describe("bandwidth config test", func() {
StdinData: []byte(conf),
}

Expect(hostNs.Do(func(netNS ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

_, _, err := testutils.CmdAdd(containerNs.Path(), args.ContainerID, "", []byte(conf), func() error { return cmdAdd(args) })
Expand Down Expand Up @@ -264,7 +264,7 @@ var _ = Describe("bandwidth config test", func() {
StdinData: []byte(conf),
}

Expect(hostNs.Do(func(netNS ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

_, _, err := testutils.CmdAdd(containerNs.Path(), args.ContainerID, "", []byte(conf), func() error { return cmdAdd(args) })
Expand Down Expand Up @@ -312,7 +312,7 @@ var _ = Describe("bandwidth config test", func() {
StdinData: []byte(conf),
}

Expect(hostNs.Do(func(netNS ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

_, _, err := testutils.CmdAdd(containerNs.Path(), args.ContainerID, "", []byte(conf), func() error { return cmdAdd(args) })
Expand Down Expand Up @@ -371,7 +371,7 @@ var _ = Describe("bandwidth config test", func() {
StdinData: []byte(conf),
}

Expect(hostNs.Do(func(netNS ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()
r, out, err := testutils.CmdAdd(containerNs.Path(), args.ContainerID, "", []byte(conf), func() error { return cmdAdd(args) })
Expect(err).NotTo(HaveOccurred(), string(out))
Expand Down Expand Up @@ -454,7 +454,7 @@ var _ = Describe("bandwidth config test", func() {
})).To(Succeed())

// Container ingress (host egress)
Expect(hostNs.Do(func(n ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

vethLink, err := netlink.LinkByName(hostIfname)
Expand Down Expand Up @@ -520,7 +520,7 @@ var _ = Describe("bandwidth config test", func() {
StdinData: []byte(conf),
}

Expect(hostNs.Do(func(netNS ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

_, _, err := testutils.CmdAdd(containerNs.Path(), args.ContainerID, "", []byte(conf), func() error { return cmdAdd(args) })
Expand Down
12 changes: 6 additions & 6 deletions plugins/meta/bandwidth/bandwidth_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var _ = Describe("bandwidth test", func() {
})).To(Succeed())

// Container ingress (host egress)
Expect(hostNs.Do(func(n ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

vethLink, err := netlink.LinkByName(hostIfname)
Expand Down Expand Up @@ -381,7 +381,7 @@ var _ = Describe("bandwidth test", func() {
})).To(Succeed())

// Container ingress (host egress)
Expect(hostNs.Do(func(n ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

vethLink, err := netlink.LinkByName(hostIfname)
Expand Down Expand Up @@ -638,7 +638,7 @@ var _ = Describe("bandwidth test", func() {
})).To(Succeed())

// Container ingress (host egress)
Expect(hostNs.Do(func(n ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

vethLink, err := netlink.LinkByName(hostIfname)
Expand Down Expand Up @@ -888,7 +888,7 @@ var _ = Describe("bandwidth test", func() {

// check container ingress side / host egress side, we should not have any htb qdisc/classes/filters defined for the host veth
// only the qdisc ingress + a noqueue qdisc
Expect(hostNs.Do(func(n ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

containerIfLink, err := netlink.LinkByName(hostIfname)
Expand Down Expand Up @@ -957,7 +957,7 @@ var _ = Describe("bandwidth test", func() {
return nil
})).To(Succeed())

Expect(hostNs.Do(func(n ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

containerIfLink, err := netlink.LinkByName(hostIfname)
Expand Down Expand Up @@ -1133,7 +1133,7 @@ var _ = Describe("bandwidth test", func() {
})).To(Succeed())

// Container ingress (host egress)
Expect(hostNs.Do(func(n ns.NetNS) error {
Expect(hostNs.Do(func(_ ns.NetNS) error {
defer GinkgoRecover()

vethLink, err := netlink.LinkByName(hostIfname)
Expand Down
2 changes: 1 addition & 1 deletion plugins/meta/tuning/tuning.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func restoreBackup(ifName, containerID, backupPath string) error {
}

if len(errStr) > 0 {
return fmt.Errorf(strings.Join(errStr, "; "))
return errors.New(strings.Join(errStr, "; "))
}

if err = os.Remove(filePath); err != nil {
Expand Down

0 comments on commit e5df283

Please sign in to comment.