Skip to content

Commit 981a3fd

Browse files
committed
Remove references to package io/ioutil
Package io/ioutil has been marked deprecated in Go 1.16. Signed-off-by: Austin Vazquez <[email protected]>
1 parent 4449ceb commit 981a3fd

6 files changed

Lines changed: 22 additions & 14 deletions

File tree

.golangci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
linters:
22
enable:
3+
- depguard
34
- structcheck
45
- varcheck
56
- staticcheck
@@ -18,3 +19,12 @@ run:
1819
- cmd/ctr/commands/images
1920
- cmd\\ctr\\commands\\run
2021
- cmd\\ctr\\commands\\images
22+
23+
linters-settings:
24+
depguard:
25+
list-type: denylist
26+
include-go-root: true
27+
packages:
28+
# use "io" or "os" instead
29+
# https://go.dev/doc/go1.16#ioutil
30+
- io/ioutil

cmd/ctd-decoder/enc_helpers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package main
1919
import (
2020
b64 "encoding/base64"
2121
"errors"
22-
"io/ioutil"
2322
"os"
2423
"path/filepath"
2524
"strings"
@@ -49,7 +48,7 @@ func getDecryptionKeys(keysPath string) (encconfig.CryptoConfig, error) {
4948
return errors.New("Symbolic links not supported in decryption keys paths")
5049
}
5150

52-
privateKey, err := ioutil.ReadFile(path)
51+
privateKey, err := os.ReadFile(path)
5352
if err != nil {
5453
return err
5554
}

cmd/ctd-decoder/main_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
package main
2121

2222
import (
23-
"io/ioutil"
23+
"io"
2424
"os"
2525
)
2626

@@ -29,5 +29,5 @@ const payloadFD = 3
2929
func readPayload() ([]byte, error) {
3030
f := os.NewFile(payloadFD, "configFd")
3131
defer f.Close()
32-
return ioutil.ReadAll(f)
32+
return io.ReadAll(f)
3333
}

cmd/ctd-decoder/main_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ package main
2121

2222
import (
2323
"fmt"
24-
"io/ioutil"
24+
"io"
2525
"os"
2626

2727
winio "github.com/Microsoft/go-winio"
@@ -35,5 +35,5 @@ func readPayload() ([]byte, error) {
3535
return nil, fmt.Errorf("could not DialPipe: %w", err)
3636
}
3737
defer conn.Close()
38-
return ioutil.ReadAll(conn)
38+
return io.ReadAll(conn)
3939
}

cmd/ctr/app/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package app
1818

1919
import (
2020
"fmt"
21-
"io/ioutil"
21+
"io"
2222

2323
"github.com/containerd/containerd/cmd/ctr/commands/content"
2424
"github.com/containerd/containerd/cmd/ctr/commands/events"
@@ -46,7 +46,7 @@ var extraCmds = []cli.Command{}
4646

4747
func init() {
4848
// Discard grpc logs so that they don't mess with our stdio
49-
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
49+
grpclog.SetLoggerV2(grpclog.NewLoggerV2(io.Discard, io.Discard, io.Discard))
5050

5151
cli.VersionPrinter = func(c *cli.Context) {
5252
fmt.Println(c.App.Name, version.Package, c.App.Version)

images/encryption/parsehelpers/parsehelpers.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package parsehelpers
2121
import (
2222
"errors"
2323
"fmt"
24-
"io/ioutil"
2524
"os"
2625
"strconv"
2726
"strings"
@@ -69,7 +68,7 @@ func processRecipientKeys(recipients []string) ([][]byte, [][]byte, [][]byte, []
6968
gpgRecipients = append(gpgRecipients, []byte(value))
7069

7170
case "jwe":
72-
tmp, err := ioutil.ReadFile(value)
71+
tmp, err := os.ReadFile(value)
7372
if err != nil {
7473
return nil, nil, nil, nil, nil, nil, fmt.Errorf("unable to read file: %w", err)
7574
}
@@ -79,7 +78,7 @@ func processRecipientKeys(recipients []string) ([][]byte, [][]byte, [][]byte, []
7978
pubkeys = append(pubkeys, tmp)
8079

8180
case "pkcs7":
82-
tmp, err := ioutil.ReadFile(value)
81+
tmp, err := os.ReadFile(value)
8382
if err != nil {
8483
return nil, nil, nil, nil, nil, nil, fmt.Errorf("unable to read file %s: %w", value, err)
8584
}
@@ -89,7 +88,7 @@ func processRecipientKeys(recipients []string) ([][]byte, [][]byte, [][]byte, []
8988
x509s = append(x509s, tmp)
9089

9190
case "pkcs11":
92-
tmp, err := ioutil.ReadFile(value)
91+
tmp, err := os.ReadFile(value)
9392
if err != nil {
9493
return nil, nil, nil, nil, nil, nil, fmt.Errorf("unable to read file %s: %w", value, err)
9594
}
@@ -118,7 +117,7 @@ func processRecipientKeys(recipients []string) ([][]byte, [][]byte, [][]byte, []
118117
// - <password>
119118
func processPwdString(pwdString string) ([]byte, error) {
120119
if strings.HasPrefix(pwdString, "file=") {
121-
return ioutil.ReadFile(pwdString[5:])
120+
return os.ReadFile(pwdString[5:])
122121
} else if strings.HasPrefix(pwdString, "pass=") {
123122
return []byte(pwdString[5:]), nil
124123
} else if strings.HasPrefix(pwdString, "fd=") {
@@ -179,7 +178,7 @@ func processPrivateKeyFiles(keyFilesAndPwds []string) ([][]byte, [][]byte, [][]b
179178
}
180179

181180
keyfile := parts[0]
182-
tmp, err := ioutil.ReadFile(keyfile)
181+
tmp, err := os.ReadFile(keyfile)
183182
if err != nil {
184183
return nil, nil, nil, nil, nil, nil, err
185184
}

0 commit comments

Comments
 (0)