Merge pull request #6531 from yanggangtony/delete-io-util
delete io/ioutil package as it is deprecatedpull/6481/head
commit
605eab1eb8
|
@ -19,7 +19,7 @@ package controller
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ func TestBackupFinalizerReconcile(t *testing.T) {
|
||||||
reconciler, backupper := mockBackupFinalizerReconciler(fakeClient, fakeClock)
|
reconciler, backupper := mockBackupFinalizerReconciler(fakeClient, fakeClock)
|
||||||
pluginManager.On("CleanupClients").Return(nil)
|
pluginManager.On("CleanupClients").Return(nil)
|
||||||
backupStore.On("GetBackupItemOperations", test.backup.Name).Return(test.backupOperations, nil)
|
backupStore.On("GetBackupItemOperations", test.backup.Name).Return(test.backupOperations, nil)
|
||||||
backupStore.On("GetBackupContents", mock.Anything).Return(ioutil.NopCloser(bytes.NewReader([]byte("hello world"))), nil)
|
backupStore.On("GetBackupContents", mock.Anything).Return(io.NopCloser(bytes.NewReader([]byte("hello world"))), nil)
|
||||||
backupStore.On("PutBackupContents", mock.Anything, mock.Anything).Return(nil)
|
backupStore.On("PutBackupContents", mock.Anything, mock.Anything).Return(nil)
|
||||||
backupStore.On("PutBackupMetadata", mock.Anything, mock.Anything).Return(nil)
|
backupStore.On("PutBackupMetadata", mock.Anything, mock.Anything).Return(nil)
|
||||||
pluginManager.On("GetBackupItemActionsV2").Return(nil, nil)
|
pluginManager.On("GetBackupItemActionsV2").Return(nil, nil)
|
||||||
|
|
|
@ -19,7 +19,6 @@ package provider
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -211,13 +210,13 @@ func TestResticRunRestore(t *testing.T) {
|
||||||
func TestClose(t *testing.T) {
|
func TestClose(t *testing.T) {
|
||||||
t.Run("Delete existing credentials file", func(t *testing.T) {
|
t.Run("Delete existing credentials file", func(t *testing.T) {
|
||||||
// Create temporary files for the credentials and caCert
|
// Create temporary files for the credentials and caCert
|
||||||
credentialsFile, err := ioutil.TempFile("", "credentialsFile")
|
credentialsFile, err := os.CreateTemp("", "credentialsFile")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create temp file: %v", err)
|
t.Fatalf("failed to create temp file: %v", err)
|
||||||
}
|
}
|
||||||
defer os.Remove(credentialsFile.Name())
|
defer os.Remove(credentialsFile.Name())
|
||||||
|
|
||||||
caCertFile, err := ioutil.TempFile("", "caCertFile")
|
caCertFile, err := os.CreateTemp("", "caCertFile")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create temp file: %v", err)
|
t.Fatalf("failed to create temp file: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -240,7 +239,7 @@ func TestClose(t *testing.T) {
|
||||||
|
|
||||||
t.Run("Delete existing caCert file", func(t *testing.T) {
|
t.Run("Delete existing caCert file", func(t *testing.T) {
|
||||||
// Create temporary files for the credentials and caCert
|
// Create temporary files for the credentials and caCert
|
||||||
caCertFile, err := ioutil.TempFile("", "caCertFile")
|
caCertFile, err := os.CreateTemp("", "caCertFile")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create temp file: %v", err)
|
t.Fatalf("failed to create temp file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -376,7 +375,7 @@ func installTestCRD(ctx context.Context, index int, group, path string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func rerenderTestYaml(index int, group, path string) (string, error) {
|
func rerenderTestYaml(index int, group, path string) (string, error) {
|
||||||
content, err := ioutil.ReadFile(path)
|
content, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrapf(err, "failed to get %s when install test yaml", path)
|
return "", errors.Wrapf(err, "failed to get %s when install test yaml", path)
|
||||||
}
|
}
|
||||||
|
@ -399,7 +398,7 @@ func rerenderTestYaml(index int, group, path string) (string, error) {
|
||||||
newContent = strings.ReplaceAll(newContent, group, fmt.Sprintf("%s.%d", group, index))
|
newContent = strings.ReplaceAll(newContent, group, fmt.Sprintf("%s.%d", group, index))
|
||||||
|
|
||||||
By(fmt.Sprintf("\n%s\n", newContent))
|
By(fmt.Sprintf("\n%s\n", newContent))
|
||||||
tmpFile, err := ioutil.TempFile("", "test-yaml")
|
tmpFile, err := os.CreateTemp("", "test-yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrapf(err, "failed to create temp file when install storage class")
|
return "", errors.Wrapf(err, "failed to create temp file when install storage class")
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package filtering
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -270,7 +269,7 @@ func (r *ResourcePoliciesCase) installTestStorageClasses(path string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
content, err := ioutil.ReadFile(path)
|
content, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to get %s when install storage class", path)
|
return errors.Wrapf(err, "failed to get %s when install storage class", path)
|
||||||
}
|
}
|
||||||
|
@ -278,7 +277,7 @@ func (r *ResourcePoliciesCase) installTestStorageClasses(path string) error {
|
||||||
// replace sc to new value
|
// replace sc to new value
|
||||||
newContent := strings.ReplaceAll(string(content), "name: e2e-storage-class", "name: e2e-storage-class-2")
|
newContent := strings.ReplaceAll(string(content), "name: e2e-storage-class", "name: e2e-storage-class-2")
|
||||||
|
|
||||||
tmpFile, err := ioutil.TempFile("", "sc-file")
|
tmpFile, err := os.CreateTemp("", "sc-file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to create temp file when install storage class")
|
return errors.Wrapf(err, "failed to create temp file when install storage class")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue