Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <[email protected]>
  • Loading branch information
testwill authored and naphelps committed May 10, 2024
1 parent eea3d80 commit 0534d95
Show file tree
Hide file tree
Showing 105 changed files with 363 additions and 430 deletions.
5 changes: 2 additions & 3 deletions api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"net/url"

Expand Down Expand Up @@ -74,13 +73,13 @@ func (r *Request) ToHTTP() (*http.Request, error) {
// No body

case r.BodyBytes != nil:
req.Request.Body = ioutil.NopCloser(bytes.NewReader(r.BodyBytes))
req.Request.Body = io.NopCloser(bytes.NewReader(r.BodyBytes))

default:
if c, ok := r.Body.(io.ReadCloser); ok {
req.Request.Body = c
} else {
req.Request.Body = ioutil.NopCloser(r.Body)
req.Request.Body = io.NopCloser(r.Body)
}
}

Expand Down
3 changes: 1 addition & 2 deletions api/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
)

Expand Down Expand Up @@ -44,7 +43,7 @@ func (r *Response) Error() error {
}

r.Body.Close()
r.Body = ioutil.NopCloser(bodyBuf)
r.Body = io.NopCloser(bodyBuf)
ns := r.Header.Get(NamespaceHeaderName)

// Build up the error object
Expand Down
3 changes: 1 addition & 2 deletions api/ssh_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"net/http"
"os"

Expand Down Expand Up @@ -140,7 +139,7 @@ func (c *SSHHelperConfig) NewClient() (*Client, error) {
// Vault address is a required parameter.
// Mount point defaults to "ssh".
func LoadSSHHelperConfig(path string) (*SSHHelperConfig, error) {
contents, err := ioutil.ReadFile(path)
contents, err := os.ReadFile(path)
if err != nil && !os.IsNotExist(err) {
return nil, multierror.Prefix(err, "ssh_helper:")
}
Expand Down
5 changes: 2 additions & 3 deletions api/sys_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"encoding/json"
"errors"
"io"
"io/ioutil"
"net/http"
"sync"
"time"
Expand Down Expand Up @@ -195,7 +194,7 @@ func (c *Sys) RaftSnapshotWithContext(ctx context.Context, snapWriter io.Writer)
dup := io.TeeReader(resp.Body, wPipe)
go func() {
defer func() {
io.Copy(ioutil.Discard, rPipe)
io.Copy(io.Discard, rPipe)
rPipe.Close()
wg.Done()
}()
Expand All @@ -216,7 +215,7 @@ func (c *Sys) RaftSnapshotWithContext(ctx context.Context, snapWriter io.Writer)
continue
}
var b []byte
b, err = ioutil.ReadAll(t)
b, err = io.ReadAll(t)
if err != nil || len(b) == 0 {
return
}
Expand Down
7 changes: 3 additions & 4 deletions builtin/audit/file/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package file

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand All @@ -25,7 +24,7 @@ func TestAuditFile_fileModeNew(t *testing.T) {
t.Fatal(err)
}

path, err := ioutil.TempDir("", "vault-test_audit_file-file_mode_new")
path, err := os.MkdirTemp("", "vault-test_audit_file-file_mode_new")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -58,7 +57,7 @@ func TestAuditFile_fileModeNew(t *testing.T) {
}

func TestAuditFile_fileModeExisting(t *testing.T) {
f, err := ioutil.TempFile("", "test")
f, err := os.CreateTemp("", "test")
if err != nil {
t.Fatalf("Failure to create test file.")
}
Expand Down Expand Up @@ -97,7 +96,7 @@ func TestAuditFile_fileModeExisting(t *testing.T) {
}

func TestAuditFile_fileMode0000(t *testing.T) {
f, err := ioutil.TempFile("", "test")
f, err := os.CreateTemp("", "test")
if err != nil {
t.Fatalf("Failure to create test file. The error is %v", err)
}
Expand Down
Loading

0 comments on commit 0534d95

Please sign in to comment.