Skip to content

Commit e5a9571

Browse files
committed
Fix SA1019 - io/ioutil has been deprecated since Go 1.16
1 parent 430f096 commit e5a9571

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

cmd/core/project-init.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ package core
2222

2323
import (
2424
"fmt"
25-
"io/ioutil"
2625
"os"
2726
"path/filepath"
2827

@@ -43,7 +42,7 @@ var projectInitCmd = &cobra.Command{
4342
if err != nil {
4443
return
4544
}
46-
err = ioutil.WriteFile(filepath.Join("chunks", chk, "Dockerfile"), []byte("ARG base\nFROM ${base}\n\n"), 0755)
45+
err = os.WriteFile(filepath.Join("chunks", chk, "Dockerfile"), []byte("ARG base\nFROM ${base}\n\n"), 0755)
4746
if err != nil {
4847
return
4948
}
@@ -52,7 +51,7 @@ var projectInitCmd = &cobra.Command{
5251
if err != nil && !os.IsExist(err) {
5352
return
5453
}
55-
err = ioutil.WriteFile(fmt.Sprintf("tests/%s.yaml", chk), []byte("- desc: \"it should say hello\"\n command: [\"echo\", \"hello\"]\n assert:\n - status == 0\n - stdout.indexOf(\"hello\") != -1\n - stderr.length == 0"), 0755)
54+
err = os.WriteFile(fmt.Sprintf("tests/%s.yaml", chk), []byte("- desc: \"it should say hello\"\n command: [\"echo\", \"hello\"]\n assert:\n - status == 0\n - stdout.indexOf(\"hello\") != -1\n - stderr.length == 0"), 0755)
5655
if err != nil {
5756
return
5857
}
@@ -63,7 +62,7 @@ var projectInitCmd = &cobra.Command{
6362
if err != nil {
6463
return
6564
}
66-
err = ioutil.WriteFile("base/Dockerfile", []byte("FROM ubuntu:latest\n"), 0755)
65+
err = os.WriteFile("base/Dockerfile", []byte("FROM ubuntu:latest\n"), 0755)
6766
if err != nil {
6867
return
6968
}

cmd/util/test-add.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"encoding/csv"
2626
"encoding/json"
2727
"fmt"
28-
"io/ioutil"
2928
"os"
3029
"strings"
3130

@@ -47,7 +46,7 @@ var testAddCmd = &cobra.Command{
4746
log.SetFormatter(&fancylog.Formatter{})
4847

4948
fn := args[0]
50-
fc, err := ioutil.ReadFile(fn)
49+
fc, err := os.ReadFile(fn)
5150
if err != nil && !os.IsNotExist(err) {
5251
log.Fatal(err)
5352
}
@@ -129,7 +128,7 @@ var testAddCmd = &cobra.Command{
129128
}
130129
fmt.Println(string(fc))
131130

132-
err = ioutil.WriteFile(args[0], fc, 0644)
131+
err = os.WriteFile(args[0], fc, 0644)
133132
if err != nil {
134133
log.Fatal(err)
135134
}

cmd/util/test-run.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ package util
2323
import (
2424
"context"
2525
"encoding/xml"
26-
"io/ioutil"
2726
"os"
2827

2928
log "github.com/sirupsen/logrus"
@@ -45,7 +44,7 @@ var testRunCmd = &cobra.Command{
4544
var tests []*test.Spec
4645

4746
for _, fn := range testFiles {
48-
fc, err := ioutil.ReadFile(fn)
47+
fc, err := os.ReadFile(fn)
4948
if err != nil {
5049
log.Fatal(err)
5150
}
@@ -68,7 +67,7 @@ var testRunCmd = &cobra.Command{
6867
log.Fatal(err)
6968
}
7069

71-
err = ioutil.WriteFile(xmlout, fc, 0644)
70+
err = os.WriteFile(xmlout, fc, 0644)
7271
if err != nil {
7372
log.Fatal(err)
7473
}

pkg/dazzle/build_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"context"
2525
"encoding/json"
2626
"fmt"
27-
"io/ioutil"
2827
"net/http"
2928
"os"
3029
"os/exec"
@@ -376,7 +375,7 @@ func TestProjectChunk_test_integration(t *testing.T) {
376375
- "status == 0"
377376
- stdout.indexOf("xxx") != -1`)
378377

379-
err = ioutil.WriteFile(targetDir+"/tests/basic.yaml", newTest, 0644)
378+
err = os.WriteFile(targetDir+"/tests/basic.yaml", newTest, 0644)
380379
if err != nil {
381380
t.Errorf("TestProjectChunk_test_integration() error:%v writing new test", err)
382381
return

pkg/dazzle/registry.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"encoding/json"
2626
"fmt"
2727
"io"
28-
"io/ioutil"
2928

3029
"github.com/containerd/containerd/errdefs"
3130
"github.com/containerd/containerd/remotes"
@@ -161,7 +160,7 @@ func (r resolverRegistry) Pull(ctx context.Context, ref reference.Reference, cfg
161160
return
162161
}
163162
defer manifestr.Close()
164-
manifestraw, err := ioutil.ReadAll(manifestr)
163+
manifestraw, err := io.ReadAll(manifestr)
165164
if err != nil {
166165
return
167166
}
@@ -176,7 +175,7 @@ func (r resolverRegistry) Pull(ctx context.Context, ref reference.Reference, cfg
176175
return
177176
}
178177
defer cfgr.Close()
179-
cfgraw, err := ioutil.ReadAll(cfgr)
178+
cfgraw, err := io.ReadAll(cfgr)
180179
if err != nil {
181180
return
182181
}

0 commit comments

Comments
 (0)