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

Migrations to golang 1.19 #271

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.17.x, 1.18.x
kmlebedev marked this conversation as resolved.
Show resolved Hide resolved
go-version: [1.19.x]
#goarch: [386, amd64, arm, ppc64le, arm64]
goarch: [amd64, arm64]
os: [ubuntu-latest] #, macos-latest, windows-latest]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
strategy:
matrix:
#go-version: [1.15.x, 1.16.x]
go-version: [1.17.x]
go-version: [1.19.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Set up Go version
uses: actions/setup-go@v1
with:
go-version: 1.17
go-version: 1.19

- name: Checkout code into the Go module directory
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17
FROM golang:1.19
ADD . /usr/src/whereabouts
RUN mkdir -p $GOPATH/src/github.com/k8snetworkplumbingwg/whereabouts
WORKDIR $GOPATH/src/github.com/k8snetworkplumbingwg/whereabouts
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17
FROM golang:1.19
ADD . /usr/src/whereabouts

ENV GOARCH "arm64"
Expand Down
3 changes: 1 addition & 2 deletions cmd/whereabouts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io/fs"
"io/ioutil"
"net"
"os"
"strings"
Expand Down Expand Up @@ -135,7 +134,7 @@ var _ = Describe("Whereabouts operations", func() {

BeforeEach(func() {
var err error
tmpDir, err = ioutil.TempDir("/tmp", "whereabouts")
tmpDir, err = os.MkdirTemp("/tmp", "whereabouts")
Expect(err).ToNot(HaveOccurred())
kubeConfigPath = fmt.Sprintf("%s/%s", tmpDir, whereaboutsConfigFile)
Expect(os.WriteFile(kubeConfigPath, kubeconfig(), fs.ModePerm)).To(Succeed())
Expand Down
5 changes: 1 addition & 4 deletions e2e/client/ippool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package client

import (
"context"
"errors"
"fmt"
"time"

kubeClient "github.com/k8snetworkplumbingwg/whereabouts/pkg/storage/kubernetes"
Expand All @@ -16,8 +14,7 @@ import (
func isIPPoolAllocationsEmpty(k8sIPAM *kubeClient.KubernetesIPAM, ipPoolName string) wait.ConditionFunc {
return func() (bool, error) {
ipPool, err := k8sIPAM.GetIPPool(context.Background(), ipPoolName)
noPoolError := fmt.Errorf("k8s pool initialized")
if errors.As(err, &noPoolError) {
if err != nil && err.Error() == kubeClient.ErrMsgK8sPoolInit {
kmlebedev marked this conversation as resolved.
Show resolved Hide resolved
return true, nil
} else if err != nil {
return false, err
Expand Down
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/k8snetworkplumbingwg/whereabouts

go 1.17
go 1.19

require (
github.com/blang/semver v3.5.1+incompatible
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,6 @@ k8s.io/gengo v0.0.0-20211129171323-c02415ce4185 h1:TT1WdmqqXareKxZ/oNXEUSwKlLiHz
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
"${SCRIPT_ROOT}/hack/update-codegen.sh"
echo "diffing ${DIFFROOT} against freshly generated codegen"
ret=0
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
diff -Nbaupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
if [[ $ret -eq 0 ]]
then
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net"
"os"
"strings"
Expand Down Expand Up @@ -225,7 +225,7 @@ func GetFlatIPAM(isControlLoop bool, IPAM *types.IPAMConfig, extraConfigPaths ..

defer jsonFile.Close()

jsonBytes, err := ioutil.ReadAll(jsonFile)
jsonBytes, err := io.ReadAll(jsonFile)
if err != nil {
return flatipam, foundflatfile, fmt.Errorf("LoadIPAMConfig Flatfile (%s) - ioutil.ReadAll error: %s", confpath, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package config

import (
"fmt"
"io/ioutil"
"net"
"os"
"testing"

. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -61,7 +61,7 @@ var _ = Describe("Allocation operations", func() {
"gateway": "192.168.5.5"
}`

err := ioutil.WriteFile("/tmp/whereabouts.conf", []byte(globalconf), 0755)
err := os.WriteFile("/tmp/whereabouts.conf", []byte(globalconf), 0755)
Expect(err).NotTo(HaveOccurred())

conf := `{
Expand Down
5 changes: 2 additions & 3 deletions pkg/controlloop/pod_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package controlloop
import (
"context"
"fmt"
"io/ioutil"
"os"
"path"
"testing"
Expand Down Expand Up @@ -45,10 +44,10 @@ var _ = Describe("IPControlLoop", func() {
const configFilePermissions = 0755

var err error
cniConfigDir, err = ioutil.TempDir("", "multus-config")
cniConfigDir, err = os.MkdirTemp("", "multus-config")
Expect(err).ToNot(HaveOccurred())
Expect(os.MkdirAll(path.Join(cniConfigDir, path.Dir(whereaboutsConfigPath)), configFilePermissions)).To(Succeed())
Expect(ioutil.WriteFile(
Expect(os.WriteFile(
path.Join(cniConfigDir, whereaboutsConfigPath),
[]byte(dummyWhereaboutsConfig()), configFilePermissions)).To(Succeed())
})
Expand Down
6 changes: 5 additions & 1 deletion pkg/storage/kubernetes/ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
"gomodules.xyz/jsonpatch/v2"
)

const (
ErrMsgK8sPoolInit = "k8s pool initialized"
)

// NewKubernetesIPAM returns a new KubernetesIPAM Client configured to a kubernetes CRD backend
func NewKubernetesIPAM(containerID string, ipamConf whereaboutstypes.IPAMConfig) (*KubernetesIPAM, error) {
var namespace string
Expand Down Expand Up @@ -144,7 +148,7 @@ func (i *KubernetesIPAM) getPool(ctx context.Context, name string, iprange strin
}
// if the pool was created for the first time, trigger another retry of the allocation loop
// so all of the metadata / resourceVersions are populated as necessary by the `client.Get` call
return nil, &temporaryError{fmt.Errorf("k8s pool initialized")}
return nil, &temporaryError{fmt.Errorf(ErrMsgK8sPoolInit)}
} else if err != nil {
return nil, fmt.Errorf("k8s get error: %s", err)
}
Expand Down