Skip to content

Commit

Permalink
Bump up min Go version to 1.20 and other dependent changes (#228)
Browse files Browse the repository at this point in the history
controller-runtime v15 has a min Golang version requirement that
breaks the container builds. This change bumps up the Go version used
to build the container. Starting 1.21 Golang, go.mod requires the Go
version and treats that as min required go version to compile your
binary. So, also bump up the Go version for local builds.

Additional changes:

- As per golang/go#56319
and golang/go#54880, global rand is
automatically, randomly seeded. So we don't need to call `Seed`
anymore.

- Package ioutil has been deprecated. Port the code to use replacement
methods.
  • Loading branch information
aruneshpa committed Sep 25, 2023
1 parent da48843 commit 9280cde
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
@@ -1,7 +1,7 @@
name: ci

env:
GO_VERSION: 1.19.3
GO_VERSION: 1.20.0

on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,5 +1,5 @@
# Go version used to build the binaries.
ARG GO_VERSION=1.18.4
ARG GO_VERSION=1.20

## Docker image used to build the binaries.
FROM golang:${GO_VERSION} as builder
Expand Down
2 changes: 1 addition & 1 deletion go.mod
@@ -1,6 +1,6 @@
module github.com/vmware-tanzu/vm-operator

go 1.18
go 1.20

replace (
github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.9.4
Expand Down
3 changes: 0 additions & 3 deletions main.go
Expand Up @@ -6,7 +6,6 @@ package main
import (
"crypto/tls"
"flag"
"math/rand"
"net/http"
"net/http/pprof"
"os"
Expand Down Expand Up @@ -119,8 +118,6 @@ func main() {
setupLog.Info("Starting VM Operator controller", "version", pkg.BuildVersion,
"buildnumber", pkg.BuildNumber, "buildtype", pkg.BuildType, "commit", pkg.BuildCommit)

rand.Seed(time.Now().UnixNano())

profilerAddress := flag.String(
"profiler-address",
defaultProfilerAddr,
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/enc_test.go
Expand Up @@ -7,7 +7,7 @@ import (
"bytes"
"compress/gzip"
"encoding/base64"
"io/ioutil"
"io"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -170,7 +170,7 @@ var _ = Describe("EncodeGzipBase64", func() {
Expect(err).NotTo(HaveOccurred())
defer Expect(gzipReader.Close()).To(Succeed())

ungzipped, err := ioutil.ReadAll(gzipReader)
ungzipped, err := io.ReadAll(gzipReader)
Expect(err).NotTo(HaveOccurred())
Expect(input).Should(Equal(string(ungzipped)))
})
Expand Down
6 changes: 3 additions & 3 deletions test/builder/util.go
Expand Up @@ -12,7 +12,7 @@ import (
"encoding/pem"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"

"github.com/google/uuid"
Expand Down Expand Up @@ -604,7 +604,7 @@ func indexOfVersion(

func LoadCRDs(rootFilePath string) ([]*apiextensionsv1.CustomResourceDefinition, error) {
// Read the CRD files.
files, err := ioutil.ReadDir(rootFilePath)
files, err := os.ReadDir(rootFilePath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -641,7 +641,7 @@ func LoadCRDs(rootFilePath string) ([]*apiextensionsv1.CustomResourceDefinition,
// copied from https://github.com/kubernetes-sigs/controller-runtime/blob/5bf44d2ffd6201703508e11fbae74fcedc5ce148/pkg/envtest/crd.go#L434-L458
func readDocuments(fp string) ([][]byte, error) {
//nolint:gosec
b, err := ioutil.ReadFile(fp)
b, err := os.ReadFile(fp)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 9280cde

Please sign in to comment.