diff --git a/.github/workflows/check-generated-artifacts.yml b/.github/workflows/check-generated-artifacts.yml index 722fb87453..321ebaf39e 100644 --- a/.github/workflows/check-generated-artifacts.yml +++ b/.github/workflows/check-generated-artifacts.yml @@ -20,7 +20,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: '1.20' - name: Run the automatic generation working-directory: ./ diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 897c98c17e..e19a20bcfd 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -203,7 +203,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: '1.20' env: GOPATH: ${{ github.workspace }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 557d62182a..feba5cd71c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,13 +17,13 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: '1.20' - name: golangci-lint uses: golangci/golangci-lint-action@v3.4.0 with: only-new-issues: true - version: v1.50.0 + version: v1.51.2 args: --timeout=900s gomodtidy: @@ -41,7 +41,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: '1.20' - name: Execute go mod tidy and check the outcome working-directory: ./ diff --git a/Makefile b/Makefile index 13f451fefe..84567d9838 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ fmt: gci addlicense # Install golangci-lint if not available golangci-lint: ifeq (, $(shell which golangci-lint)) - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.0 + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2 GOLANGCILINT=$(GOBIN)/golangci-lint else GOLANGCILINT=$(shell which golangci-lint) diff --git a/build/common/Dockerfile b/build/common/Dockerfile index 2e3d5be6a4..a96604b452 100644 --- a/build/common/Dockerfile +++ b/build/common/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19 as builder +FROM golang:1.20 as builder WORKDIR /tmp/builder COPY go.mod ./go.mod diff --git a/build/liqo-test/Dockerfile b/build/liqo-test/Dockerfile index 6835e7a9f1..00a53ec553 100644 --- a/build/liqo-test/Dockerfile +++ b/build/liqo-test/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19 as builder +FROM golang:1.20 as builder ENV PATH /go/bin:/usr/local/go/bin:$PATH ENV GOPATH /go ENV K8S_VERSION=1.25.0 diff --git a/build/liqonet/Dockerfile b/build/liqonet/Dockerfile index 3272ab84d2..0a0dcedf00 100644 --- a/build/liqonet/Dockerfile +++ b/build/liqonet/Dockerfile @@ -5,7 +5,7 @@ ARG VERSION=0.5.2 RUN cargo install --version $VERSION boringtun-cli -FROM golang:1.19 as goBuilder +FROM golang:1.20 as goBuilder WORKDIR /tmp/builder COPY go.mod ./go.mod diff --git a/go.mod b/go.mod index 8fef64e24e..a9c2c5a6f1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/liqotech/liqo -go 1.19 +go 1.20 require ( github.com/Azure/azure-sdk-for-go v68.0.0+incompatible @@ -33,6 +33,8 @@ require ( github.com/virtual-kubelet/virtual-kubelet v1.6.1-0.20220831210300-d2523fe808a2 github.com/vishvananda/netlink v1.2.1-beta.2 github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 + go4.org/netipx v0.0.0-20220925034521-797b0c90d8ab + golang.org/x/exp v0.0.0-20221114191408-850992195362 golang.org/x/mod v0.8.0 golang.org/x/sync v0.1.0 golang.org/x/sys v0.5.0 @@ -44,7 +46,6 @@ require ( google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v3 v3.0.1 helm.sh/helm/v3 v3.11.1 - inet.af/netaddr v0.0.0-20220811202034-502d2d690317 k8s.io/api v0.26.1 k8s.io/apiextensions-apiserver v0.26.1 k8s.io/apimachinery v0.26.1 @@ -228,11 +229,7 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect - go4.org/intern v0.0.0-20220617035311-6925f38cc365 // indirect - go4.org/netipx v0.0.0-20220925034521-797b0c90d8ab // indirect - go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect golang.org/x/crypto v0.5.0 // indirect - golang.org/x/exp v0.0.0-20221114191408-850992195362 golang.org/x/net v0.7.0 // indirect golang.org/x/oauth2 v0.4.0 // indirect golang.org/x/term v0.5.0 // indirect diff --git a/go.sum b/go.sum index a05d325c25..d030da1cba 100644 --- a/go.sum +++ b/go.sum @@ -264,7 +264,6 @@ github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 h1:ZClxb8laGDf5arX github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1 h1:yY9rWGoXv1U5pl4gxqlULARMQD7x0QG85lqEXTWysik= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= @@ -1021,14 +1020,8 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA= -go4.org/intern v0.0.0-20220617035311-6925f38cc365 h1:t9hFvR102YlOqU0fQn1wgwhNvSbHGBbbJxX9JKfU3l0= -go4.org/intern v0.0.0-20220617035311-6925f38cc365/go.mod h1:WXRv3p7T6gzt0CcJm43AAKdKVZmcQbwwC7EwquU5BZU= go4.org/netipx v0.0.0-20220925034521-797b0c90d8ab h1:+yW1yrZ09EYNu1spCUOHBBNRbrLnfmutwyhbhCv3b6Q= go4.org/netipx v0.0.0-20220925034521-797b0c90d8ab/go.mod h1:tgPU4N2u9RByaTN3NC2p9xOzyFpte4jYwsIIRF7XlSc= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 h1:FyBZqvoA/jbNzuAWLQE2kG820zMAkcilx6BMjGbL/E4= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1544,8 +1537,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -inet.af/netaddr v0.0.0-20220811202034-502d2d690317 h1:U2fwK6P2EqmopP/hFLTOAjWTki0qgd4GMJn5X8wOleU= -inet.af/netaddr v0.0.0-20220811202034-502d2d690317/go.mod h1:OIezDfdzOgFhuw4HuWapWq2e9l0H9tK4F1j+ETRtF3k= k8s.io/api v0.19.1/go.mod h1:+u/k4/K/7vp4vsfdT7dyl8Oxk1F26Md4g5F26Tu85PU= k8s.io/api v0.21.1/go.mod h1:FstGROTmsSHBarKc8bylzXih8BLNYTiS3TZcsoEDg2s= k8s.io/api v0.22.1/go.mod h1:bh13rkTp3F1XEaLGykbyRD2QaTTzPm0e/BMd8ptFONY= diff --git a/pkg/liqonet/ipam/ipam.go b/pkg/liqonet/ipam/ipam.go index bf8309ab70..348ae49139 100644 --- a/pkg/liqonet/ipam/ipam.go +++ b/pkg/liqonet/ipam/ipam.go @@ -19,12 +19,13 @@ import ( "errors" "fmt" "net" + "net/netip" "strings" "sync" goipam "github.com/metal-stack/go-ipam" + "go4.org/netipx" grpc "google.golang.org/grpc" - "inet.af/netaddr" "k8s.io/client-go/dynamic" "k8s.io/klog/v2" @@ -329,24 +330,24 @@ func (liqoIPAM *IPAM) isAcquired(network string) bool { // Function that receives a network as parameter and returns the pool to which this network belongs to. func (liqoIPAM *IPAM) getPoolFromNetwork(network string) (networkPool string, success bool, err error) { - var poolIPset netaddr.IPSetBuilder - var c netaddr.IPPrefix + var poolIPset netipx.IPSetBuilder + var c netip.Prefix // Get resource pools := liqoIPAM.ipamStorage.getPools() // Build IPSet for new network - ipprefix, err := netaddr.ParseIPPrefix(network) + ipprefix, err := netip.ParsePrefix(network) if err != nil { return } for _, pool := range pools { // Build IPSet for pool - c, err = netaddr.ParseIPPrefix(pool) + c, err = netip.ParsePrefix(pool) if err != nil { return } poolIPset.AddPrefix(c) // Check if the pool contains network - var ipSet *netaddr.IPSet + var ipSet *netipx.IPSet ipSet, err = poolIPset.IPSet() if err != nil { return @@ -979,11 +980,11 @@ func (liqoIPAM *IPAM) GetExternalCIDR(mask uint8) (string, error) { // the IP address does belong to the network. func ipBelongsToNetwork(ip, network string) (bool, error) { // Parse network - p, err := netaddr.ParseIPPrefix(network) + p, err := netip.ParsePrefix(network) if err != nil { return false, fmt.Errorf("cannot parse network: %w", err) } - return p.Contains(netaddr.MustParseIP(ip)), nil + return p.Contains(netip.MustParseAddr(ip)), nil } func (liqoIPAM *IPAM) belongsToPodCIDRInternal(ip string) (bool, error) { diff --git a/pkg/liqonet/utils/utils.go b/pkg/liqonet/utils/utils.go index cb1c4fb258..87911f635d 100644 --- a/pkg/liqonet/utils/utils.go +++ b/pkg/liqonet/utils/utils.go @@ -24,7 +24,7 @@ import ( "syscall" "time" - "inet.af/netaddr" + "go4.org/netipx" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -116,12 +116,12 @@ func SetMask(network string, mask uint8) string { // Next used to get the second half of a given network. func Next(network string) string { - prefix, err := netaddr.ParseIPPrefix(network) + prefix, err := netip.ParsePrefix(network) utilruntime.Must(err) // Step 1: Get last IP address of network // Step 2: Get next IP address - firstIP := prefix.Range().To().Next() - prefix = netaddr.IPPrefixFrom(firstIP, prefix.Bits()) + firstIP := netipx.RangeOfPrefix(prefix).To().Next() + prefix = netip.PrefixFrom(firstIP, prefix.Bits()) return prefix.String() }