fix: Remove references to deprecated io/ioutil pkg (#2867)

* Update benchmark_test

* Updae tar.go

* Update further refs

* Commit next set of replacements

* Reverting changes in vendor folder

* Update integreation_with_context_test.go

* Update k8s_test.go

* Update remaining usages

* Replace conflicting usage of fs local variable
This commit is contained in:
Manish Giri
2023-11-28 13:02:53 -08:00
committed by GitHub
parent 2b3d3c7eff
commit 7bfc73c3ad
32 changed files with 173 additions and 143 deletions
+3 -3
View File
@@ -19,7 +19,7 @@ package integration
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"os/exec"
"path/filepath"
@@ -94,7 +94,7 @@ func newResult(t *testing.T, f string) result {
if err != nil {
t.Errorf("could not read benchmark file %s", f)
}
byteValue, _ := ioutil.ReadAll(jsonFile)
byteValue, _ := io.ReadAll(jsonFile)
if err := json.Unmarshal(byteValue, &current); err != nil {
t.Errorf("could not unmarshal benchmark file")
}
@@ -160,7 +160,7 @@ func runInGcloud(dir string, num int) (string, error) {
}
// grab gcs and to temp dir and return
tmpDir, err := ioutil.TempDir("", fmt.Sprintf("%d", num))
tmpDir, err := os.MkdirTemp("", fmt.Sprintf("%d", num))
if err != nil {
return "", err
}
+1 -2
View File
@@ -20,7 +20,6 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
@@ -459,7 +458,7 @@ func buildKanikoImage(
shdUpload bool,
) (string, error) {
benchmarkEnv := "BENCHMARK_FILE=false"
benchmarkDir, err := ioutil.TempDir("", "")
benchmarkDir, err := os.MkdirTemp("", "")
if err != nil {
return "", err
}
+12 -3
View File
@@ -18,7 +18,7 @@ package integration
import (
"fmt"
"io/ioutil"
"io/fs"
"os"
"path/filepath"
"testing"
@@ -31,12 +31,21 @@ func TestWithContext(t *testing.T) {
}
dir := filepath.Join(cwd, "dockerfiles-with-context")
testDirs, err := ioutil.ReadDir(dir)
entries, err := os.ReadDir(dir)
if err != nil {
t.Fatal(err)
}
testDirs := make([]fs.FileInfo, 0, len(entries))
for _, entry := range entries {
info, err := entry.Info()
if err != nil {
t.Fatal(err)
}
testDirs = append(testDirs, info)
}
builder := NewDockerFileBuilder()
for _, tdInfo := range testDirs {
+13 -4
View File
@@ -18,7 +18,7 @@ package integration
import (
"fmt"
"io/ioutil"
"io/fs"
"log"
"os"
"os/exec"
@@ -41,10 +41,19 @@ func TestK8s(t *testing.T) {
dir := filepath.Join(cwd, "dockerfiles-with-context")
testDirs, err := ioutil.ReadDir(dir)
entries, err := os.ReadDir(dir)
if err != nil {
t.Fatal(err)
}
testDirs := make([]fs.FileInfo, 0, len(entries))
for _, entry := range entries {
info, err := entry.Info()
if err != nil {
t.Fatal(err)
}
testDirs = append(testDirs, info)
}
builder := NewDockerFileBuilder()
@@ -64,7 +73,7 @@ func TestK8s(t *testing.T) {
dockerImage := GetDockerImage(config.imageRepo, name)
kanikoImage := GetKanikoImage(config.imageRepo, name)
tmpfile, err := ioutil.TempFile("", "k8s-job-*.yaml")
tmpfile, err := os.CreateTemp("", "k8s-job-*.yaml")
if err != nil {
log.Fatal(err)
}
@@ -77,7 +86,7 @@ func TestK8s(t *testing.T) {
t.Logf("Testing K8s based Kaniko building of dockerfile %s and push to %s \n",
testDir, kanikoImage)
content, err := ioutil.ReadFile(tmpfile.Name())
content, err := os.ReadFile(tmpfile.Name())
if err != nil {
log.Fatal(err)
}
+1 -2
View File
@@ -19,7 +19,6 @@ package integration
import (
"compress/gzip"
"fmt"
"io/ioutil"
"log"
"os"
"time"
@@ -35,7 +34,7 @@ func CreateIntegrationTarball() (string, error) {
if err != nil {
return "nil", fmt.Errorf("Failed find path to integration dir: %w", err)
}
tempDir, err := ioutil.TempDir("", "")
tempDir, err := os.MkdirTemp("", "")
if err != nil {
return "", fmt.Errorf("Failed to create temporary directory to hold tarball: %w", err)
}