remove ioutil usage in all project

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero
2022-04-03 15:53:19 +08:00
parent 1aa87538a7
commit 303ef9cd80
14 changed files with 28 additions and 38 deletions
+1 -2
View File
@@ -3,7 +3,6 @@ package app
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/signal"
@@ -87,7 +86,7 @@ func New(conf ConfigProvider) *App {
}
func Init(app *App) *App {
app.readFile = ioutil.ReadFile
app.readFile = os.ReadFile
app.deleteFile = os.Remove
app.glob = filepath.Glob
app.abs = filepath.Abs
+1 -2
View File
@@ -2,7 +2,6 @@ package app
import (
"fmt"
"io/ioutil"
"os"
"sort"
"strings"
@@ -52,7 +51,7 @@ func (r *Run) withPreparedCharts(helmfileCommand string, opts state.ChartPrepare
// Create tmp directory and bail immediately if it fails
var dir string
if len(opts.OutputDir) == 0 {
tempDir, err := ioutil.TempDir("", "helmfile*")
tempDir, err := os.MkdirTemp("", "helmfile*")
if err != nil {
return err
}
+2 -3
View File
@@ -1,7 +1,6 @@
package app
import (
"io/ioutil"
"os"
"path/filepath"
"reflect"
@@ -24,7 +23,7 @@ func assertEqualsToSnapshot(t *testing.T, name string, data string) {
return
}
wantData, err := ioutil.ReadFile(snapshotFileName)
wantData, err := os.ReadFile(snapshotFileName)
if err != nil {
t.Fatalf(
"Snapshot file %q does not exist. Rerun this test with `HELMFILE_UPDATE_SNAPSHOT=1 go test -v -run %s %s` to create the snapshot",
@@ -53,7 +52,7 @@ func update(t *testing.T, snapshotFileName string, data []byte) {
t.Fatalf("%v", err)
}
if err := ioutil.WriteFile(snapshotFileName, data, 0644); err != nil {
if err := os.WriteFile(snapshotFileName, data, 0644); err != nil {
t.Fatalf("%v", err)
}
}