From 358f76b4ede3cb9028a02d86abe91f7ca4501c92 Mon Sep 17 00:00:00 2001
From: Joel Takvorian <joel.takvorian@qaraywa.net>
Date: Wed, 15 Feb 2023 17:24:20 +0100
Subject: [PATCH] Move to go1.19 (#96)

* Move to go1.19

* Fix go1.19 breaking cvhanges

* Still allow building with 1.18

* revert space changes on autogen files
---
 .github/workflows/pull_request.yml     | 5 ++++-
 .github/workflows/pull_request_e2e.yml | 2 +-
 .github/workflows/push_image.yml       | 4 ++--
 .github/workflows/push_image_pr.yml    | 2 +-
 .github/workflows/release.yml          | 2 +-
 .golangci.yml                          | 2 +-
 Dockerfile                             | 5 ++---
 e2e/cluster/kind.go                    | 4 ++--
 e2e/cluster/tester/loki.go             | 4 ++--
 pkg/agent/tls.go                       | 8 ++++----
 10 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index 64e697d6..d011bbb8 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -10,12 +10,15 @@ jobs:
   test:
     name: test
     runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        go: ['1.18','1.19']
     steps:
     - uses: actions/checkout@v3
     - name: Set up Go
       uses: actions/setup-go@v3
       with:
-        go-version: 1.18
+        go-version: ${{ matrix.go }}
     - name: Install make
       run: sudo apt -y install make
     - name: Run verification and tests
diff --git a/.github/workflows/pull_request_e2e.yml b/.github/workflows/pull_request_e2e.yml
index 2243738a..d42a12a9 100644
--- a/.github/workflows/pull_request_e2e.yml
+++ b/.github/workflows/pull_request_e2e.yml
@@ -17,7 +17,7 @@ jobs:
     - name: set up go 1.x
       uses: actions/setup-go@v3
       with:
-        go-version: 1.18
+        go-version: 1.19
     - name: checkout
       uses: actions/checkout@v3
     - name: run end-to-end tests
diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml
index a2e4f729..72eff44b 100644
--- a/.github/workflows/push_image.yml
+++ b/.github/workflows/push_image.yml
@@ -14,10 +14,10 @@ env:
 jobs:
   push-image:
     name: push image
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-latest
     strategy:
       matrix:
-        go: ['1.18']
+        go: ['1.19']
     steps:
       - name: install make
         run: sudo apt-get install make
diff --git a/.github/workflows/push_image_pr.yml b/.github/workflows/push_image_pr.yml
index 1542a529..a7e44de1 100644
--- a/.github/workflows/push_image_pr.yml
+++ b/.github/workflows/push_image_pr.yml
@@ -16,7 +16,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        go: ['1.18']
+        go: ['1.19']
     steps:
       - name: install make
         run: sudo apt-get install make
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 59f6b717..7ad5373f 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -16,7 +16,7 @@ jobs:
     runs-on: ubuntu-20.04
     strategy:
       matrix:
-        go: ['1.18']
+        go: ['1.19']
     steps:
       - name: checkout
         uses: actions/checkout@v3
diff --git a/.golangci.yml b/.golangci.yml
index b75c21b7..6f8b9897 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -21,7 +21,7 @@ linters:
     - varcheck
 linters-settings:
   stylecheck:
-    go: "1.18"
+    go: "1.19"
   gocritic:
     enabled-checks:
       - hugeParam
diff --git a/Dockerfile b/Dockerfile
index ae57888e..1fa4974b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,8 +1,7 @@
 # Build the manager binary
-FROM registry.access.redhat.com/ubi9/go-toolset:1.18.4 as builder
+FROM docker.io/library/golang:1.19 as builder
 
 ARG SW_VERSION="unknown"
-ARG GOVERSION="1.18.4"
 
 WORKDIR /opt/app-root
 
@@ -20,7 +19,7 @@ COPY Makefile Makefile
 RUN make compile
 
 # Create final image from minimal + built binary
-FROM registry.access.redhat.com/ubi9/ubi-minimal:9.1.0
+FROM registry.access.redhat.com/ubi9/ubi-minimal:9.1
 WORKDIR /
 COPY --from=builder /opt/app-root/bin/netobserv-ebpf-agent .
 USER 65532:65532
diff --git a/e2e/cluster/kind.go b/e2e/cluster/kind.go
index b2e27a84..3b481683 100644
--- a/e2e/cluster/kind.go
+++ b/e2e/cluster/kind.go
@@ -11,7 +11,7 @@ import (
 	"errors"
 	"fmt"
 	"io"
-	"io/ioutil"
+	"os"
 	"path"
 	"sort"
 	"testing"
@@ -264,7 +264,7 @@ func deployManifestFile(definition Deployment,
 ) error {
 	log.WithField("file", definition.ManifestFile).Info("deploying manifest file")
 
-	b, err := ioutil.ReadFile(definition.ManifestFile)
+	b, err := os.ReadFile(definition.ManifestFile)
 	if err != nil {
 		return fmt.Errorf("reading manifest file %q: %w", definition.ManifestFile, err)
 	}
diff --git a/e2e/cluster/tester/loki.go b/e2e/cluster/tester/loki.go
index 00ffaf03..4c7f2b2a 100644
--- a/e2e/cluster/tester/loki.go
+++ b/e2e/cluster/tester/loki.go
@@ -3,7 +3,7 @@ package tester
 import (
 	"encoding/json"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"net/url"
 
@@ -33,7 +33,7 @@ func (l *Loki) get(pathQuery string) (status int, body string, err error) {
 	if err != nil {
 		return 0, "", err
 	}
-	bodyBytes, err := ioutil.ReadAll(resp.Body)
+	bodyBytes, err := io.ReadAll(resp.Body)
 	if err != nil {
 		return resp.StatusCode, "", err
 	}
diff --git a/pkg/agent/tls.go b/pkg/agent/tls.go
index 24af3d8f..3430eb70 100644
--- a/pkg/agent/tls.go
+++ b/pkg/agent/tls.go
@@ -3,7 +3,7 @@ package agent
 import (
 	"crypto/tls"
 	"crypto/x509"
-	"io/ioutil"
+	"os"
 )
 
 func buildTLSConfig(cfg *Config) (*tls.Config, error) {
@@ -11,7 +11,7 @@ func buildTLSConfig(cfg *Config) (*tls.Config, error) {
 		InsecureSkipVerify: cfg.KafkaTLSInsecureSkipVerify,
 	}
 	if cfg.KafkaTLSCACertPath != "" {
-		caCert, err := ioutil.ReadFile(cfg.KafkaTLSCACertPath)
+		caCert, err := os.ReadFile(cfg.KafkaTLSCACertPath)
 		if err != nil {
 			return nil, err
 		}
@@ -19,11 +19,11 @@ func buildTLSConfig(cfg *Config) (*tls.Config, error) {
 		tlsConfig.RootCAs.AppendCertsFromPEM(caCert)
 
 		if cfg.KafkaTLSUserCertPath != "" && cfg.KafkaTLSUserKeyPath != "" {
-			userCert, err := ioutil.ReadFile(cfg.KafkaTLSUserCertPath)
+			userCert, err := os.ReadFile(cfg.KafkaTLSUserCertPath)
 			if err != nil {
 				return nil, err
 			}
-			userKey, err := ioutil.ReadFile(cfg.KafkaTLSUserKeyPath)
+			userKey, err := os.ReadFile(cfg.KafkaTLSUserKeyPath)
 			if err != nil {
 				return nil, err
 			}
-- 
GitLab