Skip to content

Commit bcddff3

Browse files
committed
Replace ioutil with os package functions for file operations
1 parent d638611 commit bcddff3

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

internal/test/e2e/e2e_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"os/exec"
109
"strings"
@@ -79,11 +78,11 @@ func exportInitialState(t *testing.T, testProjectName string, tailorBinary strin
7978
if exportErr != nil {
8079
t.Fatalf("Could not export initial state: %s\n%s", exportErr, exportStderr)
8180
}
82-
tempDir, tempDirErr := ioutil.TempDir("..", "initial-export-")
81+
tempDir, tempDirErr := os.MkdirTemp("..", "initial-export-")
8382
if tempDirErr != nil {
8483
t.Fatalf("Could not create temp dir: %s", tempDirErr)
8584
}
86-
writeErr := ioutil.WriteFile(tempDir+"/template.yml", exportStdout, 0644)
85+
writeErr := os.WriteFile(tempDir+"/template.yml", exportStdout, 0644)
8786
if writeErr != nil {
8887
t.Logf("Failed to write file template.yml into %s", tempDir)
8988
os.RemoveAll(tempDir)
@@ -93,7 +92,7 @@ func exportInitialState(t *testing.T, testProjectName string, tailorBinary strin
9392
}
9493

9594
func walkSubdirs(t *testing.T, dir string, fun func(subdir string)) {
96-
files, err := ioutil.ReadDir(dir)
95+
files, err := os.ReadDir(dir)
9796
if err != nil {
9897
t.Fatal(err)
9998
}
@@ -262,7 +261,7 @@ func runCmd(executable string, args []string) (outBytes, errBytes []byte, err er
262261
}
263262

264263
func readTestCaseSteps(folder string) (testCaseSteps, error) {
265-
content, err := ioutil.ReadFile(folder + "/steps.json")
264+
content, err := os.ReadFile(folder + "/steps.json")
266265
if err != nil {
267266
return nil, fmt.Errorf("Cannot read file: %w", err)
268267
}

internal/test/helper/file.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package helper
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"path"
87
"runtime"
@@ -48,5 +47,5 @@ func readFile(name string) ([]byte, error) {
4847
return []byte{}, fmt.Errorf("Could not get filename when looking for %s", name)
4948
}
5049
filepath := path.Join(path.Dir(filename), name)
51-
return ioutil.ReadFile(filepath)
50+
return os.ReadFile(filepath)
5251
}

pkg/cli/cli.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"bytes"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"log"
109
"os"
1110
"os/exec"
@@ -136,7 +135,7 @@ func AskForAction(question string, options []string, reader *bufio.Reader) strin
136135

137136
// EditEnvFile opens content in EDITOR, and returns saved content.
138137
func EditEnvFile(content string) (string, error) {
139-
err := ioutil.WriteFile(".ENV.DEC", []byte(content), 0644)
138+
err := os.WriteFile(".ENV.DEC", []byte(content), 0644)
140139
if err != nil {
141140
return "", err
142141
}
@@ -160,7 +159,7 @@ func EditEnvFile(content string) (string, error) {
160159
if err != nil {
161160
return "", err
162161
}
163-
data, err := ioutil.ReadFile(".ENV.DEC")
162+
data, err := os.ReadFile(".ENV.DEC")
164163
if err != nil {
165164
return "", err
166165
}

0 commit comments

Comments
 (0)