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 vsukhin committed Sep 8, 2023
1 parent 7143d2b commit f71967a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions cmd/kubectl-testkube/config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package config

import (
"io/ioutil"
"os"
"testing"

Expand All @@ -10,7 +9,7 @@ import (

func TestSave(t *testing.T) {
// override default directory
dir, err := ioutil.TempDir("", "test-config-save")
dir, err := os.MkdirTemp("", "test-config-save")
assert.NoError(t, err)
defaultDirectory = dir

Expand Down
15 changes: 7 additions & 8 deletions contrib/executor/zap/pkg/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package runner

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -19,7 +18,7 @@ func TestRun(t *testing.T) {

t.Run("Run successful API scan", func(t *testing.T) {
// given
tempDir, err := ioutil.TempDir(os.TempDir(), "")
tempDir, err := os.MkdirTemp(os.TempDir(), "")
assert.NoError(t, err)
runner, err := NewRunner(context.TODO(), envs.Params{
DataDir: tempDir,
Expand Down Expand Up @@ -50,7 +49,7 @@ func TestRun(t *testing.T) {

t.Run("Run API scan with PASS and WARN", func(t *testing.T) {
// given
tempDir, err := ioutil.TempDir(os.TempDir(), "")
tempDir, err := os.MkdirTemp(os.TempDir(), "")
assert.NoError(t, err)
runner, err := NewRunner(context.TODO(), envs.Params{
DataDir: tempDir,
Expand Down Expand Up @@ -81,7 +80,7 @@ func TestRun(t *testing.T) {

t.Run("Run API scan with WARN and FailOnWarn", func(t *testing.T) {
// given
tempDir, err := ioutil.TempDir(os.TempDir(), "")
tempDir, err := os.MkdirTemp(os.TempDir(), "")
assert.NoError(t, err)
runner, err := NewRunner(context.TODO(), envs.Params{
DataDir: tempDir,
Expand Down Expand Up @@ -112,7 +111,7 @@ func TestRun(t *testing.T) {

t.Run("Run API scan with FAIL", func(t *testing.T) {
// given
tempDir, err := ioutil.TempDir(os.TempDir(), "")
tempDir, err := os.MkdirTemp(os.TempDir(), "")
assert.NoError(t, err)
runner, err := NewRunner(context.TODO(), envs.Params{
DataDir: tempDir,
Expand Down Expand Up @@ -143,7 +142,7 @@ func TestRun(t *testing.T) {

t.Run("Run Baseline scan with PASS", func(t *testing.T) {
// given
tempDir, err := ioutil.TempDir(os.TempDir(), "")
tempDir, err := os.MkdirTemp(os.TempDir(), "")
assert.NoError(t, err)
runner, err := NewRunner(context.TODO(), envs.Params{
DataDir: tempDir,
Expand Down Expand Up @@ -172,7 +171,7 @@ func TestRun(t *testing.T) {

t.Run("Run Baseline scan with WARN", func(t *testing.T) {
// given
tempDir, err := ioutil.TempDir(os.TempDir(), "")
tempDir, err := os.MkdirTemp(os.TempDir(), "")
assert.NoError(t, err)
runner, err := NewRunner(context.TODO(), envs.Params{
DataDir: tempDir,
Expand Down Expand Up @@ -202,7 +201,7 @@ func TestRun(t *testing.T) {

t.Run("Run Full scan with FAIL", func(t *testing.T) {
// given
tempDir, err := ioutil.TempDir(os.TempDir(), "")
tempDir, err := os.MkdirTemp(os.TempDir(), "")
assert.NoError(t, err)
runner, err := NewRunner(context.TODO(), envs.Params{
DataDir: tempDir,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/client/client_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package client

import (
"bytes"
"io/ioutil"
"io"
"net/http"
)

Expand All @@ -18,6 +18,6 @@ func (c ClientMock) Do(req *http.Request) (*http.Response, error) {
return nil, err
}
return &http.Response{
Body: ioutil.NopCloser(bytes.NewReader(c.body)),
Body: io.NopCloser(bytes.NewReader(c.body)),
}, c.err
}
3 changes: 1 addition & 2 deletions pkg/repository/storage/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -81,7 +80,7 @@ func getDocDBTLSConfig() (*tls.Config, error) {
}()

tlsConfig := new(tls.Config)
certs, err := ioutil.ReadFile(caFilePath)
certs, err := os.ReadFile(caFilePath)
if err != nil {
return nil, fmt.Errorf("could not read CA file: %s", err)
}
Expand Down

0 comments on commit f71967a

Please sign in to comment.