зеркало из https://github.com/github/vitess-gh.git
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Родитель
458dc32060
Коммит
ecf27f44c4
|
@ -21,7 +21,6 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"regexp"
|
||||
|
@ -220,7 +219,7 @@ func main() {
|
|||
}
|
||||
|
||||
func applyFilePatch(dockerYaml []byte, patchFile string) []byte {
|
||||
yamlPatch, err := ioutil.ReadFile(patchFile)
|
||||
yamlPatch, err := os.ReadFile(patchFile)
|
||||
if err != nil {
|
||||
log.Fatalf("reading yaml patch file %s: %s", patchFile, err)
|
||||
}
|
||||
|
@ -272,7 +271,7 @@ func createFile(filePath string) *os.File {
|
|||
}
|
||||
|
||||
func readFile(filePath string) []byte {
|
||||
file, err := ioutil.ReadFile(filePath)
|
||||
file, err := os.ReadFile(filePath)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("reading %s: %s", filePath, err)
|
||||
|
@ -296,7 +295,7 @@ func handleError(err error) {
|
|||
|
||||
func appendToSqlFile(schemaFileNames []string, f *os.File) {
|
||||
for _, file := range schemaFileNames {
|
||||
data, err := ioutil.ReadFile(tablesPath + file)
|
||||
data, err := os.ReadFile(tablesPath + file)
|
||||
if err != nil {
|
||||
log.Fatalf("reading %s: %s", tablesPath+file, err)
|
||||
}
|
||||
|
@ -313,7 +312,7 @@ func appendToSqlFile(schemaFileNames []string, f *os.File) {
|
|||
}
|
||||
|
||||
func getTableName(sqlFile string) string {
|
||||
sqlFileData, err := ioutil.ReadFile(sqlFile)
|
||||
sqlFileData, err := os.ReadFile(sqlFile)
|
||||
if err != nil {
|
||||
log.Fatalf("reading sqlFile file %s: %s", sqlFile, err)
|
||||
}
|
||||
|
@ -325,7 +324,7 @@ func getTableName(sqlFile string) string {
|
|||
}
|
||||
|
||||
func getPrimaryKey(sqlFile string) string {
|
||||
sqlFileData, err := ioutil.ReadFile(sqlFile)
|
||||
sqlFileData, err := os.ReadFile(sqlFile)
|
||||
if err != nil {
|
||||
log.Fatalf("reading sqlFile file %s: %s", sqlFile, err)
|
||||
}
|
||||
|
@ -337,7 +336,7 @@ func getPrimaryKey(sqlFile string) string {
|
|||
}
|
||||
|
||||
func getKeyColumns(sqlFile string) string {
|
||||
sqlFileData, err := ioutil.ReadFile(sqlFile)
|
||||
sqlFileData, err := os.ReadFile(sqlFile)
|
||||
if err != nil {
|
||||
log.Fatalf("reading sqlFile file %s: %s", sqlFile, err)
|
||||
}
|
||||
|
@ -404,7 +403,7 @@ func writeVschemaFile(file []byte, fileName string) {
|
|||
}
|
||||
|
||||
func writeFile(file []byte, fileName string) {
|
||||
err := ioutil.WriteFile(fileName, file, 0644)
|
||||
err := os.WriteFile(fileName, file, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("writing %s %s", fileName, err)
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package common
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
vtfcr "vitess.io/vitess/go/vt/vttablet/customrule/filecustomrule"
|
||||
"vitess.io/vitess/go/vt/vttablet/tabletserver/rules"
|
||||
|
@ -32,7 +32,7 @@ func MustWriteJSON(obj interface{}, path string) {
|
|||
log.Fatalf("Unable to marshal object: %v", err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(path, enc, 0400)
|
||||
err = os.WriteFile(path, enc, 0400)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to save new JSON: %v", err)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package command
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -71,7 +71,7 @@ func commandApplyRoutingRules(cmd *cobra.Command, args []string) error {
|
|||
|
||||
var rulesBytes []byte
|
||||
if applyRoutingRulesOptions.RulesFilePath != "" {
|
||||
data, err := ioutil.ReadFile(applyRoutingRulesOptions.RulesFilePath)
|
||||
data, err := os.ReadFile(applyRoutingRulesOptions.RulesFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package command
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -78,7 +78,7 @@ func commandApplyVSchema(cmd *cobra.Command, args []string) error {
|
|||
var err error
|
||||
if sqlMode {
|
||||
if applyVSchemaOptions.SQLFile != "" {
|
||||
sqlBytes, err := ioutil.ReadFile(applyVSchemaOptions.SQLFile)
|
||||
sqlBytes, err := os.ReadFile(applyVSchemaOptions.SQLFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func commandApplyVSchema(cmd *cobra.Command, args []string) error {
|
|||
} else { // jsonMode
|
||||
var schema []byte
|
||||
if applyVSchemaOptions.VSchemaFile != "" {
|
||||
schema, err = ioutil.ReadFile(applyVSchemaOptions.VSchemaFile)
|
||||
schema, err = os.ReadFile(applyVSchemaOptions.VSchemaFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"vitess.io/vitess/go/exit"
|
||||
"vitess.io/vitess/go/vt/log"
|
||||
|
@ -123,7 +123,7 @@ func getFileParam(flag, flagFile, name string, required bool) (string, error) {
|
|||
|
||||
return "", nil
|
||||
}
|
||||
data, err := ioutil.ReadFile(flagFile)
|
||||
data, err := os.ReadFile(flagFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot read file %v: %v", flagFile, err)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -130,7 +130,7 @@ func initConfig(tabletAlias *topodatapb.TabletAlias) (*tabletenv.TabletConfig, *
|
|||
}
|
||||
|
||||
if *tabletConfig != "" {
|
||||
bytes, err := ioutil.ReadFile(*tabletConfig)
|
||||
bytes, err := os.ReadFile(*tabletConfig)
|
||||
if err != nil {
|
||||
log.Exitf("error reading config file %s: %v", *tabletConfig, err)
|
||||
}
|
||||
|
@ -181,10 +181,10 @@ func extractOnlineDDL() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(binaryFileName, ghostBinary, 0755); err != nil {
|
||||
if err := os.WriteFile(binaryFileName, ghostBinary, 0755); err != nil {
|
||||
// One possibility of failure is that gh-ost is up and running. In that case,
|
||||
// let's pause and check if the running gh-ost is exact same binary as the one we wish to extract.
|
||||
foundBytes, _ := ioutil.ReadFile(binaryFileName)
|
||||
foundBytes, _ := os.ReadFile(binaryFileName)
|
||||
if bytes.Equal(ghostBinary, foundBytes) {
|
||||
// OK, it's the same binary, there is no need to extract the file anyway
|
||||
return nil
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -76,7 +75,7 @@ func TestPersistentMode(t *testing.T) {
|
|||
conf := config
|
||||
defer resetFlags(args, conf)
|
||||
|
||||
dir, err := ioutil.TempDir("/tmp", "vttestserver_persistent_mode_")
|
||||
dir, err := os.MkdirTemp("/tmp", "vttestserver_persistent_mode_")
|
||||
assert.NoError(t, err)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
|
@ -230,7 +229,7 @@ func TestMtlsAuth(t *testing.T) {
|
|||
defer resetFlags(args, conf)
|
||||
|
||||
// Our test root.
|
||||
root, err := ioutil.TempDir("", "tlstest")
|
||||
root, err := os.MkdirTemp("", "tlstest")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
@ -273,7 +272,7 @@ func TestMtlsAuthUnauthorizedFails(t *testing.T) {
|
|||
defer resetFlags(args, conf)
|
||||
|
||||
// Our test root.
|
||||
root, err := ioutil.TempDir("", "tlstest")
|
||||
root, err := os.MkdirTemp("", "tlstest")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
|
@ -607,7 +607,7 @@ func cmdEdit(ctx context.Context, subFlags *flag.FlagSet, args []string) error {
|
|||
return fmt.Errorf("edit: cannot start $EDITOR: %v", err)
|
||||
}
|
||||
|
||||
fileData, err := ioutil.ReadFile(tmpPath)
|
||||
fileData, err := os.ReadFile(tmpPath)
|
||||
if err != nil {
|
||||
os.Remove(tmpPath)
|
||||
return fmt.Errorf("edit: cannot read file %v", err)
|
||||
|
@ -784,7 +784,7 @@ func getPathData(ctx context.Context, filePath string) ([]byte, error) {
|
|||
var err error
|
||||
file, err := os.Open(filePath)
|
||||
if err == nil {
|
||||
data, err := ioutil.ReadAll(file)
|
||||
data, err := io.ReadAll(file)
|
||||
if err == nil {
|
||||
return data, err
|
||||
}
|
||||
|
@ -800,7 +800,7 @@ func setPathData(ctx context.Context, filePath string, data []byte) error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(filePath, []byte(data), 0666)
|
||||
return os.WriteFile(filePath, []byte(data), 0666)
|
||||
}
|
||||
|
||||
func fileCp(ctx context.Context, srcPath, dstPath string) error {
|
||||
|
@ -954,7 +954,7 @@ func cmdUnzip(ctx context.Context, subFlags *flag.FlagSet, args []string) error
|
|||
if err != nil {
|
||||
return fmt.Errorf("unzip: error %v", err)
|
||||
}
|
||||
data, err := ioutil.ReadAll(rc)
|
||||
data, err := io.ReadAll(rc)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unzip: failed reading archive: %v", err)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ limitations under the License.
|
|||
package ioutil2
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
@ -26,7 +25,7 @@ import (
|
|||
// WriteFileAtomic writes the data to a temp file and atomically move if everything else succeeds.
|
||||
func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error {
|
||||
dir, name := path.Split(filename)
|
||||
f, err := ioutil.TempFile(dir, name)
|
||||
f, err := os.CreateTemp(dir, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package ioutil2
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -32,7 +31,7 @@ func TestWrite(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rData, err := ioutil.ReadFile(fname)
|
||||
rData, err := os.ReadFile(fname)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package mysql
|
|||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -47,7 +46,7 @@ func TestValidCert(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestSSLConnection")
|
||||
root, err := os.MkdirTemp("", "TestSSLConnection")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
@ -130,7 +129,7 @@ func TestNoCert(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestSSLConnection")
|
||||
root, err := os.MkdirTemp("", "TestSSLConnection")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
@ -249,7 +248,7 @@ func (a *AuthServerStatic) DefaultAuthMethodDescription() AuthMethodDescription
|
|||
func (a *AuthServerStatic) reload() {
|
||||
jsonBytes := []byte(a.jsonConfig)
|
||||
if a.file != "" {
|
||||
data, err := ioutil.ReadFile(a.file)
|
||||
data, err := os.ReadFile(a.file)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to read mysql_auth_server_static_file file: %v", err)
|
||||
return
|
||||
|
|
|
@ -18,7 +18,6 @@ package mysql
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"syscall"
|
||||
|
@ -128,7 +127,7 @@ func TestHostMatcher(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStaticConfigHUP(t *testing.T) {
|
||||
tmpFile, err := ioutil.TempFile("", "mysql_auth_server_static_file.json")
|
||||
tmpFile, err := os.CreateTemp("", "mysql_auth_server_static_file.json")
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't create temp file: %v", err)
|
||||
}
|
||||
|
@ -136,7 +135,7 @@ func TestStaticConfigHUP(t *testing.T) {
|
|||
|
||||
oldStr := "str5"
|
||||
jsonConfig := fmt.Sprintf("{\"%s\":[{\"Password\":\"%s\"}]}", oldStr, oldStr)
|
||||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
if err := os.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
t.Fatalf("couldn't write temp file: %v", err)
|
||||
}
|
||||
|
||||
|
@ -159,7 +158,7 @@ func TestStaticConfigHUP(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStaticConfigHUPWithRotation(t *testing.T) {
|
||||
tmpFile, err := ioutil.TempFile("", "mysql_auth_server_static_file.json")
|
||||
tmpFile, err := os.CreateTemp("", "mysql_auth_server_static_file.json")
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't create temp file: %v", err)
|
||||
}
|
||||
|
@ -167,7 +166,7 @@ func TestStaticConfigHUPWithRotation(t *testing.T) {
|
|||
|
||||
oldStr := "str1"
|
||||
jsonConfig := fmt.Sprintf("{\"%s\":[{\"Password\":\"%s\"}]}", oldStr, oldStr)
|
||||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
if err := os.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
t.Fatalf("couldn't write temp file: %v", err)
|
||||
}
|
||||
|
||||
|
@ -184,7 +183,7 @@ func TestStaticConfigHUPWithRotation(t *testing.T) {
|
|||
|
||||
func hupTest(t *testing.T, aStatic *AuthServerStatic, tmpFile *os.File, oldStr, newStr string) {
|
||||
jsonConfig := fmt.Sprintf("{\"%s\":[{\"Password\":\"%s\"}]}", newStr, newStr)
|
||||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
if err := os.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
t.Fatalf("couldn't overwrite temp file: %v", err)
|
||||
}
|
||||
|
||||
|
@ -205,7 +204,7 @@ func hupTest(t *testing.T, aStatic *AuthServerStatic, tmpFile *os.File, oldStr,
|
|||
|
||||
func hupTestWithRotation(t *testing.T, aStatic *AuthServerStatic, tmpFile *os.File, oldStr, newStr string) {
|
||||
jsonConfig := fmt.Sprintf("{\"%s\":[{\"Password\":\"%s\"}]}", newStr, newStr)
|
||||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
if err := os.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
t.Fatalf("couldn't overwrite temp file: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"crypto/x509"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
@ -277,7 +276,7 @@ func readFromFile(filePath string) (string, error) {
|
|||
if filePath == "" {
|
||||
return "", nil
|
||||
}
|
||||
fileBytes, err := ioutil.ReadFile(filePath)
|
||||
fileBytes, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
log.Errorf("Could not read file: %s", filePath)
|
||||
return "", err
|
||||
|
|
|
@ -19,7 +19,6 @@ package mysql
|
|||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -139,7 +138,7 @@ func TestConnectTimeout(t *testing.T) {
|
|||
// Tests a connection where Dial to a unix socket fails
|
||||
// properly returns the right error. To simulate exactly the
|
||||
// right failure, try to dial a Unix socket that's just a temp file.
|
||||
fd, err := ioutil.TempFile("", "mysql")
|
||||
fd, err := os.CreateTemp("", "mysql")
|
||||
if err != nil {
|
||||
t.Fatalf("cannot create TemFile: %v", err)
|
||||
}
|
||||
|
@ -175,7 +174,7 @@ func TestTLSClientDisabled(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestTLSServer")
|
||||
root, err := os.MkdirTemp("", "TestTLSServer")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(root)
|
||||
tlstest.CreateCA(root)
|
||||
|
@ -248,7 +247,7 @@ func TestTLSClientPreferredDefault(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestTLSServer")
|
||||
root, err := os.MkdirTemp("", "TestTLSServer")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(root)
|
||||
tlstest.CreateCA(root)
|
||||
|
@ -369,7 +368,7 @@ func TestTLSClientVerifyCA(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestTLSServer")
|
||||
root, err := os.MkdirTemp("", "TestTLSServer")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(root)
|
||||
tlstest.CreateCA(root)
|
||||
|
@ -453,7 +452,7 @@ func TestTLSClientVerifyIdentity(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestTLSServer")
|
||||
root, err := os.MkdirTemp("", "TestTLSServer")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(root)
|
||||
tlstest.CreateCA(root)
|
||||
|
|
|
@ -19,7 +19,6 @@ package endtoend
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -174,7 +173,7 @@ func TestMain(m *testing.M) {
|
|||
|
||||
exitCode := func() int {
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestTLSServer")
|
||||
root, err := os.MkdirTemp("", "TestTLSServer")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "TempDir failed: %v", err)
|
||||
return 1
|
||||
|
@ -191,16 +190,16 @@ ssl-cert=%v/server-cert.pem
|
|||
ssl-key=%v/server-key.pem
|
||||
`, root, root, root)
|
||||
extraMyCnf := path.Join(root, "ssl_my.cnf")
|
||||
if err := ioutil.WriteFile(extraMyCnf, []byte(cnf), os.ModePerm); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ioutil.WriteFile(%v) failed: %v", extraMyCnf, err)
|
||||
if err := os.WriteFile(extraMyCnf, []byte(cnf), os.ModePerm); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "os.WriteFile(%v) failed: %v", extraMyCnf, err)
|
||||
return 1
|
||||
}
|
||||
|
||||
// For LargeQuery tests
|
||||
cnf = "max_allowed_packet=100M\n"
|
||||
maxPacketMyCnf := path.Join(root, "max_packet.cnf")
|
||||
if err := ioutil.WriteFile(maxPacketMyCnf, []byte(cnf), os.ModePerm); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ioutil.WriteFile(%v) failed: %v", maxPacketMyCnf, err)
|
||||
if err := os.WriteFile(maxPacketMyCnf, []byte(cnf), os.ModePerm); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "os.WriteFile(%v) failed: %v", maxPacketMyCnf, err)
|
||||
return 1
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ package fakesqldb
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
|
@ -153,9 +152,9 @@ type ExpectedExecuteFetch struct {
|
|||
// New creates a server, and starts listening.
|
||||
func New(t testing.TB) *DB {
|
||||
// Pick a path for our socket.
|
||||
socketDir, err := ioutil.TempDir("", "fakesqldb")
|
||||
socketDir, err := os.MkdirTemp("", "fakesqldb")
|
||||
if err != nil {
|
||||
t.Fatalf("ioutil.TempDir failed: %v", err)
|
||||
t.Fatalf("os.MkdirTemp failed: %v", err)
|
||||
}
|
||||
socketFile := path.Join(socketDir, "fakesqldb.sock")
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package mysql
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -112,7 +111,7 @@ func TestSSLConnection(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestSSLConnection")
|
||||
root, err := os.MkdirTemp("", "TestSSLConnection")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -75,7 +75,7 @@ func Init() {
|
|||
data := []byte(*ldapAuthConfigString)
|
||||
if *ldapAuthConfigFile != "" {
|
||||
var err error
|
||||
data, err = ioutil.ReadFile(*ldapAuthConfigFile)
|
||||
data, err = os.ReadFile(*ldapAuthConfigFile)
|
||||
if err != nil {
|
||||
log.Exitf("Failed to read mysql_ldap_auth_config_file: %v", err)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -344,7 +343,7 @@ func FuzzTLSServer(data []byte) int {
|
|||
|
||||
host := l.Addr().(*net.TCPAddr).IP.String()
|
||||
port := l.Addr().(*net.TCPAddr).Port
|
||||
root, err := ioutil.TempDir("", "TestTLSServer")
|
||||
root, err := os.MkdirTemp("", "TestTLSServer")
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ limitations under the License.
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"runtime/debug"
|
||||
"testing"
|
||||
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
func TestFuzzHandleNextCommandFromFile(t *testing.T) {
|
||||
directoryName := "fuzzdata"
|
||||
files, err := ioutil.ReadDir(directoryName)
|
||||
files, err := os.ReadDir(directoryName)
|
||||
require.NoError(t, err)
|
||||
for _, file := range files {
|
||||
t.Run(file.Name(), func(t *testing.T) {
|
||||
|
@ -41,7 +41,7 @@ func TestFuzzHandleNextCommandFromFile(t *testing.T) {
|
|||
t.Fatal(string(debug.Stack()))
|
||||
}
|
||||
}()
|
||||
testcase, err := ioutil.ReadFile(path.Join(directoryName, file.Name()))
|
||||
testcase, err := os.ReadFile(path.Join(directoryName, file.Name()))
|
||||
require.NoError(t, err)
|
||||
FuzzHandleNextCommand(testcase)
|
||||
})
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -388,7 +387,7 @@ func TestConnectionUnixSocket(t *testing.T) {
|
|||
}
|
||||
defer authServer.close()
|
||||
|
||||
unixSocket, err := ioutil.TempFile("", "mysql_vitess_test.sock")
|
||||
unixSocket, err := os.CreateTemp("", "mysql_vitess_test.sock")
|
||||
require.NoError(t, err, "Failed to create temp file")
|
||||
|
||||
os.Remove(unixSocket.Name())
|
||||
|
@ -821,7 +820,7 @@ func TestTLSServer(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestTLSServer")
|
||||
root, err := os.MkdirTemp("", "TestTLSServer")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(root)
|
||||
tlstest.CreateCA(root)
|
||||
|
@ -920,7 +919,7 @@ func TestTLSRequired(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestTLSRequired")
|
||||
root, err := os.MkdirTemp("", "TestTLSRequired")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(root)
|
||||
tlstest.CreateCA(root)
|
||||
|
@ -999,7 +998,7 @@ func TestCachingSha2PasswordAuthWithTLS(t *testing.T) {
|
|||
port := l.Addr().(*net.TCPAddr).Port
|
||||
|
||||
// Create the certs.
|
||||
root, err := ioutil.TempDir("", "TestSSLConnection")
|
||||
root, err := os.MkdirTemp("", "TestSSLConnection")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -194,7 +193,7 @@ func TestChannel(t *testing.T) {
|
|||
func TestFile(t *testing.T) {
|
||||
logger := New("logger", 10)
|
||||
|
||||
dir, err := ioutil.TempDir("", "streamlog_file")
|
||||
dir, err := os.MkdirTemp("", "streamlog_file")
|
||||
if err != nil {
|
||||
t.Fatalf("error getting tempdir: %v", err)
|
||||
}
|
||||
|
@ -213,7 +212,7 @@ func TestFile(t *testing.T) {
|
|||
time.Sleep(10 * time.Millisecond)
|
||||
|
||||
want := "test 1\ntest 2\n"
|
||||
contents, _ := ioutil.ReadFile(logPath)
|
||||
contents, _ := os.ReadFile(logPath)
|
||||
got := string(contents)
|
||||
if want != string(got) {
|
||||
t.Errorf("streamlog file: want %q got %q", want, got)
|
||||
|
@ -227,7 +226,7 @@ func TestFile(t *testing.T) {
|
|||
time.Sleep(10 * time.Millisecond)
|
||||
|
||||
want = "test 1\ntest 2\ntest 3\n"
|
||||
contents, _ = ioutil.ReadFile(rotatedPath)
|
||||
contents, _ = os.ReadFile(rotatedPath)
|
||||
got = string(contents)
|
||||
if want != string(got) {
|
||||
t.Errorf("streamlog file: want %q got %q", want, got)
|
||||
|
@ -244,14 +243,14 @@ func TestFile(t *testing.T) {
|
|||
time.Sleep(10 * time.Millisecond)
|
||||
|
||||
want = "test 1\ntest 2\ntest 3\n"
|
||||
contents, _ = ioutil.ReadFile(rotatedPath)
|
||||
contents, _ = os.ReadFile(rotatedPath)
|
||||
got = string(contents)
|
||||
if want != string(got) {
|
||||
t.Errorf("streamlog file: want %q got %q", want, got)
|
||||
}
|
||||
|
||||
want = "test 4\n"
|
||||
contents, _ = ioutil.ReadFile(logPath)
|
||||
contents, _ = os.ReadFile(logPath)
|
||||
got = string(contents)
|
||||
if want != string(got) {
|
||||
t.Errorf("streamlog file: want %q got %q", want, got)
|
||||
|
|
|
@ -28,7 +28,7 @@ package tb
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
|
@ -96,7 +96,7 @@ func stack(calldepth int) []byte {
|
|||
// Print this much at least. If we can't find the source, it won't show.
|
||||
fmt.Fprintf(buf, "%s:%d (0x%x)\n", file, line, pc)
|
||||
if file != lastFile {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -89,11 +88,11 @@ func TestMainSetup(m *testing.M, useMysqlctld bool) {
|
|||
shard := &localCluster.Keyspaces[0].Shards[0]
|
||||
// changing password for mysql user
|
||||
dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory)
|
||||
initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
initDb, _ := os.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
sql := string(initDb)
|
||||
newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql")
|
||||
sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster)
|
||||
ioutil.WriteFile(newInitDBFile, []byte(sql), 0666)
|
||||
os.WriteFile(newInitDBFile, []byte(sql), 0666)
|
||||
|
||||
extraArgs := []string{"-db-credentials-file", dbCredentialFile}
|
||||
commonTabletArg = append(commonTabletArg, "-db-credentials-file", dbCredentialFile)
|
||||
|
@ -303,7 +302,7 @@ func TestBackupTransformErrorImpl(t *testing.T) {
|
|||
func validateManifestFile(t *testing.T, backupLocation string) {
|
||||
|
||||
// reading manifest
|
||||
data, err := ioutil.ReadFile(backupLocation + "/MANIFEST")
|
||||
data, err := os.ReadFile(backupLocation + "/MANIFEST")
|
||||
require.Nilf(t, err, "error while reading MANIFEST %v", err)
|
||||
manifest := make(map[string]interface{})
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package vtbackup
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -84,11 +83,11 @@ func TestMain(m *testing.M) {
|
|||
// Create a new init_db.sql file that sets up passwords for all users.
|
||||
// Then we use a db-credentials-file with the passwords.
|
||||
dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory)
|
||||
initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
initDb, _ := os.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
sql := string(initDb)
|
||||
newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql")
|
||||
sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster)
|
||||
err = ioutil.WriteFile(newInitDBFile, []byte(sql), 0666)
|
||||
err = os.WriteFile(newInitDBFile, []byte(sql), 0666)
|
||||
if err != nil {
|
||||
return 1, err
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -105,11 +104,11 @@ func LaunchCluster(setupType int, streamMode string, stripes int) (int, error) {
|
|||
shard := &localCluster.Keyspaces[0].Shards[0]
|
||||
|
||||
dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory)
|
||||
initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
initDb, _ := os.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
sql := string(initDb)
|
||||
newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql")
|
||||
sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster)
|
||||
err = ioutil.WriteFile(newInitDBFile, []byte(sql), 0666)
|
||||
err = os.WriteFile(newInitDBFile, []byte(sql), 0666)
|
||||
if err != nil {
|
||||
return 1, err
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
|
@ -670,14 +669,14 @@ func getPort() int {
|
|||
if _, err := os.Stat(tmpPortFileName); os.IsNotExist(err) {
|
||||
port = getVtStartPort()
|
||||
} else {
|
||||
result, _ := ioutil.ReadFile(tmpPortFileName)
|
||||
result, _ := os.ReadFile(tmpPortFileName)
|
||||
cport, err := strconv.Atoi(string(result))
|
||||
if err != nil || cport > 60000 || cport == 0 {
|
||||
cport = getVtStartPort()
|
||||
}
|
||||
port = cport
|
||||
}
|
||||
ioutil.WriteFile(tmpPortFileName, []byte(fmt.Sprintf("%d", port+200)), 0666)
|
||||
os.WriteFile(tmpPortFileName, []byte(fmt.Sprintf("%d", port+200)), 0666)
|
||||
return port
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package cluster
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -196,7 +195,7 @@ func (topo *TopoProcess) SetupConsul(cluster *LocalProcessCluster) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(configFile, config, 0666)
|
||||
err = os.WriteFile(configFile, config, 0666)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package cluster
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -157,7 +157,7 @@ func (vtgate *VtgateProcess) GetStatusForTabletOfShard(name string, endPointsCou
|
|||
}
|
||||
if resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -263,7 +263,7 @@ func (vtgate *VtgateProcess) GetVars() (map[string]interface{}, error) {
|
|||
return nil, fmt.Errorf("error getting response from %s", vtgate.VerifyURL)
|
||||
}
|
||||
if resp.StatusCode == 200 {
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("not able to parse response body")
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -145,7 +144,7 @@ func (vttablet *VttabletProcess) Setup() (err error) {
|
|||
|
||||
if vttablet.ServingStatus != "" {
|
||||
if err = vttablet.WaitForTabletStatus(vttablet.ServingStatus); err != nil {
|
||||
errFileContent, _ := ioutil.ReadFile(fname)
|
||||
errFileContent, _ := os.ReadFile(fname)
|
||||
if errFileContent != nil {
|
||||
log.Infof("vttablet error:\n%s\n", string(errFileContent))
|
||||
}
|
||||
|
@ -163,7 +162,7 @@ func (vttablet *VttabletProcess) GetStatus() string {
|
|||
return ""
|
||||
}
|
||||
if resp.StatusCode == 200 {
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
return string(respByte)
|
||||
}
|
||||
|
@ -178,7 +177,7 @@ func (vttablet *VttabletProcess) GetVars() map[string]interface{} {
|
|||
}
|
||||
if resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
return nil
|
||||
|
@ -194,7 +193,7 @@ func (vttablet *VttabletProcess) GetStatusDetails() string {
|
|||
if err != nil {
|
||||
return fmt.Sprintf("Status details failed: %v", err.Error())
|
||||
}
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
return string(respByte)
|
||||
}
|
||||
|
||||
|
@ -478,7 +477,7 @@ func (vttablet *VttabletProcess) WaitForVReplicationToCatchup(t testing.TB, work
|
|||
|
||||
// BulkLoad performs a bulk load of rows into a given vttablet.
|
||||
func (vttablet *VttabletProcess) BulkLoad(t testing.TB, db, table string, bulkInsert func(io.Writer)) {
|
||||
tmpbulk, err := ioutil.TempFile(path.Join(vttablet.Directory, "tmp"), "bulk_load")
|
||||
tmpbulk, err := os.CreateTemp(path.Join(vttablet.Directory, "tmp"), "bulk_load")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create tmp file for loading: %v", err)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package cluster
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -222,7 +222,7 @@ func (vtworker *VtworkerProcess) GetVars() (map[string]interface{}, error) {
|
|||
return nil, fmt.Errorf("error getting response from %s", vtworker.VerifyURL)
|
||||
}
|
||||
if resp.StatusCode == 200 {
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("not able to parse response body")
|
||||
|
|
|
@ -20,7 +20,7 @@ package clustertest
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
@ -66,7 +66,7 @@ func testTopoDataAPI(t *testing.T, url string) {
|
|||
assert.Equal(t, resp.StatusCode, 200)
|
||||
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(respByte, &resultMap)
|
||||
require.Nil(t, err)
|
||||
|
||||
|
@ -101,7 +101,7 @@ func testListAllTablets(t *testing.T) {
|
|||
func testTabletStatus(t *testing.T) {
|
||||
resp, err := http.Get(fmt.Sprintf("http://%s:%d", clusterInstance.Hostname, clusterInstance.Keyspaces[0].Shards[0].Vttablets[0].HTTPPort))
|
||||
require.Nil(t, err)
|
||||
respByte, err := ioutil.ReadAll(resp.Body)
|
||||
respByte, err := io.ReadAll(resp.Body)
|
||||
require.Nil(t, err)
|
||||
result := string(respByte)
|
||||
log.Infof("Tablet status response: %v", result)
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
@ -54,7 +54,7 @@ func verifyVtgateVariables(t *testing.T, url string) {
|
|||
resp, _ := http.Get(url)
|
||||
if resp != nil && resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
require.Nil(t, err)
|
||||
if resultMap["VtgateVSchemaCounts"] == nil {
|
||||
|
|
|
@ -20,7 +20,7 @@ package clustertest
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
|
@ -35,7 +35,7 @@ func TestVttabletProcess(t *testing.T) {
|
|||
testURL(t, fmt.Sprintf("http://localhost:%d/debug/vars/", firstTabletPort), "tablet debug var url")
|
||||
resp, _ := http.Get(fmt.Sprintf("http://localhost:%d/debug/vars", firstTabletPort))
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -56,7 +56,7 @@ package encryptedtransport
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -389,12 +389,12 @@ func getVitessClient(addr string) (vtgateservicepb.VitessClient, error) {
|
|||
func setCreds(t *testing.T, name string, ca string) {
|
||||
f1, err := os.Open(path.Join(certDirectory, "ca-cert.pem"))
|
||||
require.NoError(t, err)
|
||||
b1, err := ioutil.ReadAll(f1)
|
||||
b1, err := io.ReadAll(f1)
|
||||
require.NoError(t, err)
|
||||
|
||||
f2, err := os.Open(path.Join(certDirectory, ca+"-cert.pem"))
|
||||
require.NoError(t, err)
|
||||
b2, err := ioutil.ReadAll(f2)
|
||||
b2, err := io.ReadAll(f2)
|
||||
require.NoError(t, err)
|
||||
|
||||
caContent := append(b1, b2...)
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
@ -541,7 +541,7 @@ func getVar(vttablet *cluster.Vttablet) (map[string]interface{}, error) {
|
|||
}
|
||||
if resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
return resultMap, err
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -245,7 +245,7 @@ func startCluster(t *testing.T) string {
|
|||
tabletConfig := fmt.Sprintf(connFormat, productSocket, customerSocket)
|
||||
fmt.Printf("tablet_config:\n%s\n", tabletConfig)
|
||||
yamlFile := path.Join(clusterInstance.TmpDirectory, "external.yaml")
|
||||
err = ioutil.WriteFile(yamlFile, []byte(tabletConfig), 0644)
|
||||
err = os.WriteFile(yamlFile, []byte(tabletConfig), 0644)
|
||||
require.NoError(t, err)
|
||||
return yamlFile
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package onlineddl
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
@ -31,7 +31,7 @@ import (
|
|||
|
||||
// CreateTempScript creates a script in the temporary directory with given content
|
||||
func CreateTempScript(t *testing.T, content string) (fileName string) {
|
||||
f, err := ioutil.TempFile("", "onlineddl-test-")
|
||||
f, err := os.CreateTemp("", "onlineddl-test-")
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = f.WriteString(content)
|
||||
|
|
|
@ -19,7 +19,7 @@ package vrepl
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -223,7 +223,7 @@ func throttleResponse(tablet *cluster.Vttablet, path string) (resp *http.Respons
|
|||
if err != nil {
|
||||
return resp, respBody, err
|
||||
}
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
respBody = string(b)
|
||||
return resp, respBody, err
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
|
@ -136,7 +135,7 @@ func TestSchemaChange(t *testing.T) {
|
|||
shards := clusterInstance.Keyspaces[0].Shards
|
||||
require.Equal(t, 1, len(shards))
|
||||
|
||||
files, err := ioutil.ReadDir(testDataPath)
|
||||
files, err := os.ReadDir(testDataPath)
|
||||
require.NoError(t, err)
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
|
@ -156,7 +155,7 @@ func readTestFile(t *testing.T, testName string, fileName string) (content strin
|
|||
return "", false
|
||||
}
|
||||
require.NoError(t, err)
|
||||
b, err := ioutil.ReadFile(filePath)
|
||||
b, err := os.ReadFile(filePath)
|
||||
require.NoError(t, err)
|
||||
return strings.TrimSpace(string(b)), true
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -526,7 +525,7 @@ func tlsLaunchRecoveryTablet(t *testing.T, tablet *cluster.Vttablet, tabletForBi
|
|||
}
|
||||
|
||||
func getCNFromCertPEM(filename string) string {
|
||||
pemBytes, _ := ioutil.ReadFile(filename)
|
||||
pemBytes, _ := os.ReadFile(filename)
|
||||
block, _ := pem.Decode(pemBytes)
|
||||
cert, _ := x509.ParseCertificate(block.Bytes)
|
||||
rdn := cert.Subject.ToRDNSequence()[0][0]
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -96,7 +95,7 @@ func TestMainImpl(m *testing.M) {
|
|||
localCluster.Keyspaces = append(localCluster.Keyspaces, *keyspace)
|
||||
|
||||
dbCredentialFile = initialsharding.WriteDbCredentialToTmp(localCluster.TmpDirectory)
|
||||
initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
initDb, _ := os.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
sql := string(initDb)
|
||||
newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql")
|
||||
sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster)
|
||||
|
@ -105,7 +104,7 @@ func TestMainImpl(m *testing.M) {
|
|||
SET GLOBAL old_alter_table = ON;
|
||||
`
|
||||
sql = sql + oldAlterTableMode
|
||||
ioutil.WriteFile(newInitDBFile, []byte(sql), 0666)
|
||||
os.WriteFile(newInitDBFile, []byte(sql), 0666)
|
||||
|
||||
extraArgs := []string{"-db-credentials-file", dbCredentialFile}
|
||||
commonTabletArg = append(commonTabletArg, "-db-credentials-file", dbCredentialFile)
|
||||
|
|
|
@ -18,7 +18,6 @@ package initialsharding
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -630,7 +629,7 @@ func checkSrvKeyspaceForSharding(t *testing.T, ksName string, expectedPartitions
|
|||
// Create a new init_db.sql file that sets up passwords for all users.
|
||||
// Then we use a db-credentials-file with the passwords.
|
||||
func writeInitDBFile() {
|
||||
initDb, _ := ioutil.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
initDb, _ := os.ReadFile(path.Join(os.Getenv("VTROOT"), "/config/init_db.sql"))
|
||||
sql := string(initDb)
|
||||
newInitDbFile = path.Join(ClusterInstance.TmpDirectory, "init_db_with_passwords.sql")
|
||||
sql = sql + GetPasswordUpdateSQL(ClusterInstance) + `
|
||||
|
@ -664,7 +663,7 @@ GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,
|
|||
ON *.* TO 'vt_filtered'@'127.0.0.1';
|
||||
FLUSH PRIVILEGES;
|
||||
`
|
||||
ioutil.WriteFile(newInitDbFile, []byte(sql), 0666)
|
||||
os.WriteFile(newInitDbFile, []byte(sql), 0666)
|
||||
|
||||
}
|
||||
|
||||
|
@ -678,7 +677,7 @@ func WriteDbCredentialToTmp(tmpDir string) string {
|
|||
"vt_filtered": ["VtFilteredPass"]
|
||||
}`)
|
||||
dbCredentialFile = path.Join(tmpDir, "db_credentials.json")
|
||||
ioutil.WriteFile(dbCredentialFile, data, 0666)
|
||||
os.WriteFile(dbCredentialFile, data, 0666)
|
||||
return dbCredentialFile
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
@ -360,7 +360,7 @@ func (bt *BufferingTest) Test(t *testing.T) {
|
|||
require.Equal(t, 200, resp.StatusCode)
|
||||
|
||||
var metadata VTGateBufferingStats
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(respByte, &metadata)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
@ -73,7 +73,7 @@ func verifyVtgateVariables(t *testing.T, url string) {
|
|||
require.Equal(t, 200, resp.StatusCode, "Vtgate api url response not found")
|
||||
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(respByte, &resultMap)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, resultMap, "VtgateVSchemaCounts", "Vschema count should be present in variables")
|
||||
|
|
|
@ -18,7 +18,7 @@ package tabletmanager
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -50,7 +50,7 @@ func TestTopoCustomRule(t *testing.T) {
|
|||
topoCustomRuleFile := "/tmp/rules.json"
|
||||
topoCustomRulePath := "/keyspaces/ks/configs/CustomRules"
|
||||
data := []byte("[]\n")
|
||||
err = ioutil.WriteFile(topoCustomRuleFile, data, 0777)
|
||||
err = os.WriteFile(topoCustomRuleFile, data, 0777)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Copy config file into topo.
|
||||
|
@ -93,7 +93,7 @@ func TestTopoCustomRule(t *testing.T) {
|
|||
"TableNames" : ["t1"],
|
||||
"Query" : "(select)|(SELECT)"
|
||||
}]`)
|
||||
err = ioutil.WriteFile(topoCustomRuleFile, data, 0777)
|
||||
err = os.WriteFile(topoCustomRuleFile, data, 0777)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = clusterInstance.VtctlclientProcess.ExecuteCommand("TopoCp", "-to_topo", topoCustomRuleFile, topoCustomRulePath)
|
||||
|
|
|
@ -18,7 +18,7 @@ package tabletmanager
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
|
@ -64,7 +64,7 @@ func assertNotAllowedURLTest(t *testing.T, url string) {
|
|||
resp, err := http.Get(url)
|
||||
require.NoError(t, err)
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
|
||||
|
@ -76,7 +76,7 @@ func assertAllowedURLTest(t *testing.T, url string) {
|
|||
resp, err := http.Get(url)
|
||||
require.NoError(t, err)
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -83,14 +82,14 @@ func (vs *VaultServer) start() error {
|
|||
}
|
||||
|
||||
hclFile := path.Join(os.Getenv("PWD"), vaultConfigFileName)
|
||||
hcl, _ := ioutil.ReadFile(hclFile)
|
||||
hcl, _ := os.ReadFile(hclFile)
|
||||
// Replace variable parts in Vault config file
|
||||
hcl = bytes.Replace(hcl, []byte("$server"), []byte(vs.address), 1)
|
||||
hcl = bytes.Replace(hcl, []byte("$port"), []byte(fmt.Sprintf("%d", vs.port1)), 1)
|
||||
hcl = bytes.Replace(hcl, []byte("$cert"), []byte(path.Join(os.Getenv("PWD"), vaultCertFileName)), 1)
|
||||
hcl = bytes.Replace(hcl, []byte("$key"), []byte(path.Join(os.Getenv("PWD"), vaultKeyFileName)), 1)
|
||||
newHclFile := path.Join(vs.logDir, vaultConfigFileName)
|
||||
err = ioutil.WriteFile(newHclFile, hcl, 0700)
|
||||
err = os.WriteFile(newHclFile, hcl, 0700)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
|
@ -154,7 +153,7 @@ func downloadExecFile(path string, url string) error {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
err = ioutil.WriteFile(path, []byte(""), 0700)
|
||||
err = os.WriteFile(path, []byte(""), 0700)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -151,7 +150,7 @@ func TestVaultAuth(t *testing.T) {
|
|||
time.Sleep(30 * time.Second)
|
||||
// Check the log for the Vault token renewal message
|
||||
// If we don't see it, that is a test failure
|
||||
logContents, _ := ioutil.ReadFile(path.Join(clusterInstance.TmpDirectory, vttabletLogFileName))
|
||||
logContents, _ := os.ReadFile(path.Join(clusterInstance.TmpDirectory, vttabletLogFileName))
|
||||
require.True(t, bytes.Contains(logContents, []byte(tokenRenewalString)))
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package vreplication
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
@ -108,7 +108,7 @@ func getQueryCount(url string, query string) int {
|
|||
fmt.Printf("http Get returns status %d\n", resp.StatusCode)
|
||||
return 0
|
||||
}
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
body := string(respByte)
|
||||
doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
|
||||
|
|
|
@ -19,8 +19,9 @@ package vreplication
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -60,7 +61,7 @@ func throttleResponse(tablet *cluster.VttabletProcess, path string) (resp *http.
|
|||
if err != nil {
|
||||
return resp, respBody, err
|
||||
}
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
respBody = string(b)
|
||||
return resp, respBody, err
|
||||
}
|
||||
|
@ -79,7 +80,7 @@ func throttlerCheckSelf(tablet *cluster.VttabletProcess, app string) (resp *http
|
|||
if err != nil {
|
||||
return resp, respBody, err
|
||||
}
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
respBody = string(b)
|
||||
return resp, respBody, err
|
||||
}
|
||||
|
@ -198,7 +199,7 @@ func TestCellAliasVreplicationWorkflow(t *testing.T) {
|
|||
func insertInitialData(t *testing.T) {
|
||||
t.Run("insertInitialData", func(t *testing.T) {
|
||||
log.Infof("Inserting initial data")
|
||||
lines, _ := ioutil.ReadFile("unsharded_init_data.sql")
|
||||
lines, _ := os.ReadFile("unsharded_init_data.sql")
|
||||
execMultipleQueries(t, vtgateConn, "product:0", string(lines))
|
||||
execVtgateQuery(t, vtgateConn, "product:0", "insert into customer_seq(id, next_id, cache) values(0, 100, 100);")
|
||||
execVtgateQuery(t, vtgateConn, "product:0", "insert into order_seq(id, next_id, cache) values(0, 100, 100);")
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -105,7 +105,7 @@ func TestStandalone(t *testing.T) {
|
|||
require.Nil(t, err)
|
||||
require.Equal(t, 200, resp.StatusCode)
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(respByte, &resultMap)
|
||||
require.Nil(t, err)
|
||||
cmd := resultMap["cmdline"]
|
||||
|
|
|
@ -32,7 +32,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -305,7 +305,7 @@ func testBufferBase(t *testing.T, isExternalParent bool) {
|
|||
bufferingStops := 0
|
||||
if resp.StatusCode == 200 {
|
||||
resultMap := make(map[string]interface{})
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
err := json.Unmarshal(respByte, &resultMap)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
|
@ -167,7 +166,7 @@ func testWithAutoSchemaFromChangeDir(t *testing.T) {
|
|||
_ = os.Mkdir(path.Join(schemaChangeDirectory, keyspaceName), 0700)
|
||||
_ = os.Mkdir(path.Join(schemaChangeDirectory, keyspaceName, "input"), 0700)
|
||||
sqlFile := path.Join(schemaChangeDirectory, keyspaceName, "input/create_test_table_x.sql")
|
||||
err := ioutil.WriteFile(sqlFile, []byte("create table test_table_x (id int)"), 0644)
|
||||
err := os.WriteFile(sqlFile, []byte("create table test_table_x (id int)"), 0644)
|
||||
require.Nil(t, err)
|
||||
timeout := time.Now().Add(10 * time.Second)
|
||||
matchFoundAfterAutoSchemaApply := false
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package loadkeyspace
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -82,7 +82,7 @@ func TestBlockedLoadKeyspace(t *testing.T) {
|
|||
|
||||
// check warning logs
|
||||
logDir := clusterInstance.VtgateProcess.LogDir
|
||||
all, err := ioutil.ReadFile(path.Join(logDir, "vtgate-stderr.txt"))
|
||||
all, err := os.ReadFile(path.Join(logDir, "vtgate-stderr.txt"))
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, string(all), "Unable to get initial schema reload")
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ func TestLoadKeyspaceWithNoTablet(t *testing.T) {
|
|||
|
||||
// check warning logs
|
||||
logDir := clusterInstance.VtgateProcess.LogDir
|
||||
all, err := ioutil.ReadFile(path.Join(logDir, "vtgate-stderr.txt"))
|
||||
all, err := os.ReadFile(path.Join(logDir, "vtgate-stderr.txt"))
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, string(all), "Unable to get initial schema reload")
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ func TestNoInitialKeyspace(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
// check info logs
|
||||
all, err := ioutil.ReadFile(path.Join(logDir, "vtgate.INFO"))
|
||||
all, err := os.ReadFile(path.Join(logDir, "vtgate.INFO"))
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, string(all), "No keyspace to load")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package worker
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os/exec"
|
||||
|
@ -151,7 +151,7 @@ func TestWebInterface(t *testing.T) {
|
|||
resp, err = http.Get(baseURL + "/status")
|
||||
assert.Nil(t, err)
|
||||
if resp.StatusCode == 200 {
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
respStr := string(respByte)
|
||||
assert.Contains(t, respStr, "Ping command was called with message: 'pong'", fmt.Sprintf("Command did not log output to /status: %s", respStr))
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ func TestWebInterface(t *testing.T) {
|
|||
resp, err = http.Get(baseURL + "/status")
|
||||
assert.Nil(t, err)
|
||||
if resp.StatusCode == 200 {
|
||||
respByte, _ := ioutil.ReadAll(resp.Body)
|
||||
respByte, _ := io.ReadAll(resp.Body)
|
||||
statusAfterReset := string(respByte)
|
||||
assert.Contains(t, statusAfterReset, "This worker is idle.", "/status does not indicate that the reset was successful")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ limitations under the License.
|
|||
package fuzzing
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"runtime/debug"
|
||||
"testing"
|
||||
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
func TestVtctlFuzzer(t *testing.T) {
|
||||
directoryName := "fuzzdata"
|
||||
files, err := ioutil.ReadDir(directoryName)
|
||||
files, err := os.ReadDir(directoryName)
|
||||
require.NoError(t, err)
|
||||
for _, file := range files {
|
||||
t.Run(file.Name(), func(t *testing.T) {
|
||||
|
@ -41,7 +41,7 @@ func TestVtctlFuzzer(t *testing.T) {
|
|||
t.Fatal(string(debug.Stack()))
|
||||
}
|
||||
}()
|
||||
testcase, err := ioutil.ReadFile(path.Join(directoryName, file.Name()))
|
||||
testcase, err := os.ReadFile(path.Join(directoryName, file.Name()))
|
||||
require.NoError(t, err)
|
||||
res := Fuzz(testcase)
|
||||
require.Equal(t, 1, res)
|
||||
|
|
|
@ -20,8 +20,8 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"go/types"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
|
@ -178,7 +178,7 @@ func (t *TypePaths) Set(path string) error {
|
|||
// currently exist on disk and returns any mismatches
|
||||
func VerifyFilesOnDisk(result map[string]*jen.File) (errors []error) {
|
||||
for fullPath, file := range result {
|
||||
existing, err := ioutil.ReadFile(fullPath)
|
||||
existing, err := os.ReadFile(fullPath)
|
||||
if err != nil {
|
||||
errors = append(errors, fmt.Errorf("missing file on disk: %s (%w)", fullPath, err))
|
||||
continue
|
||||
|
|
|
@ -18,8 +18,8 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"vitess.io/vitess/go/tools/goimports"
|
||||
|
||||
|
@ -53,7 +53,7 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalf("failed to apply goimport to '%s': %v", fullPath, err)
|
||||
}
|
||||
err = ioutil.WriteFile(fullPath, content, 0664)
|
||||
err = os.WriteFile(fullPath, content, 0664)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to save file to '%s': %v", fullPath, err)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package goimports
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
|
@ -27,7 +26,7 @@ import (
|
|||
// FormatJenFile formats the given *jen.File with goimports and return a slice
|
||||
// of byte corresponding to the formatted file.
|
||||
func FormatJenFile(file *jen.File) ([]byte, error) {
|
||||
tempFile, err := ioutil.TempFile("/tmp", "*.go")
|
||||
tempFile, err := os.CreateTemp("/tmp", "*.go")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -43,5 +42,5 @@ func FormatJenFile(file *jen.File) ([]byte, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ioutil.ReadFile(tempFile.Name())
|
||||
return os.ReadFile(tempFile.Name())
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -447,7 +446,7 @@ func createSortedPrTypeSlice(prPerType prsByType) []sortedPRType {
|
|||
}
|
||||
|
||||
func releaseSummary(summaryFile string) (string, error) {
|
||||
contentSummary, err := ioutil.ReadFile(summaryFile)
|
||||
contentSummary, err := os.ReadFile(summaryFile)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -107,7 +107,7 @@ TEST@planetscale.com docker/lite/install_dependencies.sh: Upgrade MySQL 8 to 8.
|
|||
}
|
||||
|
||||
func TestLoadSummaryReadme(t *testing.T) {
|
||||
readmeFile, err := ioutil.TempFile("", "*.md")
|
||||
readmeFile, err := os.CreateTemp("", "*.md")
|
||||
require.NoError(t, err)
|
||||
|
||||
readmeContent := `- New Gen4 feature
|
||||
|
@ -115,7 +115,7 @@ func TestLoadSummaryReadme(t *testing.T) {
|
|||
- Bunch of features
|
||||
`
|
||||
|
||||
err = ioutil.WriteFile(readmeFile.Name(), []byte(readmeContent), 0644)
|
||||
err = os.WriteFile(readmeFile.Name(), []byte(readmeContent), 0644)
|
||||
require.NoError(t, err)
|
||||
|
||||
str, err := releaseSummary(readmeFile.Name())
|
||||
|
@ -191,11 +191,11 @@ func TestGenerateReleaseNotes(t *testing.T) {
|
|||
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
outFile, err := ioutil.TempFile("", "*.md")
|
||||
outFile, err := os.CreateTemp("", "*.md")
|
||||
require.NoError(t, err)
|
||||
err = tc.releaseNote.generate(outFile)
|
||||
require.NoError(t, err)
|
||||
all, err := ioutil.ReadFile(outFile.Name())
|
||||
all, err := os.ReadFile(outFile.Name())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.expectedOut, string(all))
|
||||
})
|
||||
|
|
|
@ -21,8 +21,8 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"go/types"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -479,7 +479,7 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalf("failed to apply goimport to '%s': %v", fullPath, err)
|
||||
}
|
||||
err = ioutil.WriteFile(fullPath, content, 0664)
|
||||
err = os.WriteFile(fullPath, content, 0664)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to save file to '%s': %v", fullPath, err)
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ func main() {
|
|||
// this test fail.
|
||||
func VerifyFilesOnDisk(result map[string]*jen.File) (errors []error) {
|
||||
for fullPath, file := range result {
|
||||
existing, err := ioutil.ReadFile(fullPath)
|
||||
existing, err := os.ReadFile(fullPath)
|
||||
if err != nil {
|
||||
errors = append(errors, fmt.Errorf("missing file on disk: %s (%w)", fullPath, err))
|
||||
continue
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
|
@ -119,7 +118,7 @@ func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, strin
|
|||
if fcs.dbCredentials == nil {
|
||||
fcs.dbCredentials = make(map[string][]string)
|
||||
|
||||
data, err := ioutil.ReadFile(*dbCredentialsFile)
|
||||
data, err := os.ReadFile(*dbCredentialsFile)
|
||||
if err != nil {
|
||||
log.Warningf("Failed to read dbCredentials file: %v", *dbCredentialsFile)
|
||||
return "", "", err
|
||||
|
@ -249,7 +248,7 @@ func readFromFile(filePath string) (string, error) {
|
|||
if filePath == "" {
|
||||
return "", nil
|
||||
}
|
||||
fileBytes, err := ioutil.ReadFile(filePath)
|
||||
fileBytes, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package dbconfigs
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
@ -252,7 +251,7 @@ func TestAccessors(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCredentialsFileHUP(t *testing.T) {
|
||||
tmpFile, err := ioutil.TempFile("", "credentials.json")
|
||||
tmpFile, err := os.CreateTemp("", "credentials.json")
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't create temp file: %v", err)
|
||||
}
|
||||
|
@ -261,7 +260,7 @@ func TestCredentialsFileHUP(t *testing.T) {
|
|||
*dbCredentialsServer = "file"
|
||||
oldStr := "str1"
|
||||
jsonConfig := fmt.Sprintf("{\"%s\": [\"%s\"]}", oldStr, oldStr)
|
||||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
if err := os.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
t.Fatalf("couldn't write temp file: %v", err)
|
||||
}
|
||||
cs := GetCredentialsServer()
|
||||
|
@ -276,7 +275,7 @@ func TestCredentialsFileHUP(t *testing.T) {
|
|||
func hupTest(t *testing.T, tmpFile *os.File, oldStr, newStr string) {
|
||||
cs := GetCredentialsServer()
|
||||
jsonConfig := fmt.Sprintf("{\"%s\": [\"%s\"]}", newStr, newStr)
|
||||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
if err := os.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
t.Fatalf("couldn't overwrite temp file: %v", err)
|
||||
}
|
||||
_, pass, _ := cs.GetUserAndPassword(oldStr)
|
||||
|
|
|
@ -19,7 +19,7 @@ package grpcclient
|
|||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -59,7 +59,7 @@ func AppendStaticAuth(opts []grpc.DialOption) ([]grpc.DialOption, error) {
|
|||
if *credsFile == "" {
|
||||
return opts, nil
|
||||
}
|
||||
data, err := ioutil.ReadFile(*credsFile)
|
||||
data, err := os.ReadFile(*credsFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ package grpcoptionaltls
|
|||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -51,7 +50,7 @@ type testCredentials struct {
|
|||
|
||||
func createCredentials() (*testCredentials, error) {
|
||||
// Create a temporary directory.
|
||||
certDir, err := ioutil.TempDir("", "optionaltls_grpc_test")
|
||||
certDir, err := os.MkdirTemp("", "optionaltls_grpc_test")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package logutil
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
@ -61,9 +61,9 @@ func testConsoleLogger(t *testing.T, tee bool, entrypoint string) {
|
|||
if err := cmd.Start(); err != nil {
|
||||
t.Fatalf("cmd.Start() error: %v", err)
|
||||
}
|
||||
out, err := ioutil.ReadAll(stderr)
|
||||
out, err := io.ReadAll(stderr)
|
||||
if err != nil {
|
||||
t.Fatalf("ioutil.ReadAll(sterr) error: %v", err)
|
||||
t.Fatalf("io.ReadAll(sterr) error: %v", err)
|
||||
}
|
||||
if err := cmd.Wait(); err != nil {
|
||||
t.Fatalf("cmd.Wait() error: %v", err)
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -73,7 +72,7 @@ func azInternalCredentials() (string, string, error) {
|
|||
var actKey string
|
||||
if *accountKeyFile != "" {
|
||||
log.Infof("Getting Azure Storage Account key from file: %s", *accountKeyFile)
|
||||
dat, err := ioutil.ReadFile(*accountKeyFile)
|
||||
dat, err := os.ReadFile(*accountKeyFile)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package mysqlctl
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
|
@ -26,7 +25,7 @@ import (
|
|||
)
|
||||
|
||||
func TestFindFilesToBackup(t *testing.T) {
|
||||
root, err := ioutil.TempDir("", "backuptest")
|
||||
root, err := os.MkdirTemp("", "backuptest")
|
||||
if err != nil {
|
||||
t.Fatalf("os.TempDir failed: %v", err)
|
||||
}
|
||||
|
@ -46,28 +45,28 @@ func TestFindFilesToBackup(t *testing.T) {
|
|||
t.Fatalf("failed to create directory %v: %v", s, err)
|
||||
}
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(innodbDataDir, "innodb_data_1"), []byte("innodb data 1 contents"), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(path.Join(innodbDataDir, "innodb_data_1"), []byte("innodb data 1 contents"), os.ModePerm); err != nil {
|
||||
t.Fatalf("failed to write file innodb_data_1: %v", err)
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(innodbLogDir, "innodb_log_1"), []byte("innodb log 1 contents"), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(path.Join(innodbLogDir, "innodb_log_1"), []byte("innodb log 1 contents"), os.ModePerm); err != nil {
|
||||
t.Fatalf("failed to write file innodb_log_1: %v", err)
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(dataDbDir, "db.opt"), []byte("db opt file"), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(path.Join(dataDbDir, "db.opt"), []byte("db opt file"), os.ModePerm); err != nil {
|
||||
t.Fatalf("failed to write file db.opt: %v", err)
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(extraDir, "extra.stuff"), []byte("extra file"), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(path.Join(extraDir, "extra.stuff"), []byte("extra file"), os.ModePerm); err != nil {
|
||||
t.Fatalf("failed to write file extra.stuff: %v", err)
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(outsideDbDir, "table1.frm"), []byte("frm file"), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(path.Join(outsideDbDir, "table1.frm"), []byte("frm file"), os.ModePerm); err != nil {
|
||||
t.Fatalf("failed to write file table1.opt: %v", err)
|
||||
}
|
||||
if err := os.Symlink(outsideDbDir, path.Join(dataDir, "vt_symlink")); err != nil {
|
||||
t.Fatalf("failed to symlink vt_symlink: %v", err)
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(rocksdbDir, "000011.sst"), []byte("rocksdb file"), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(path.Join(rocksdbDir, "000011.sst"), []byte("rocksdb file"), os.ModePerm); err != nil {
|
||||
t.Fatalf("failed to write file 000011.sst: %v", err)
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(sdiOnlyDir, "table1.sdi"), []byte("sdi file"), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(path.Join(sdiOnlyDir, "table1.sdi"), []byte("sdi file"), os.ModePerm); err != nil {
|
||||
t.Fatalf("failed to write file table1.sdi: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
@ -307,7 +306,7 @@ func isDbDir(p string) bool {
|
|||
}
|
||||
|
||||
// Look for at least one database file
|
||||
fis, err := ioutil.ReadDir(p)
|
||||
fis, err := os.ReadDir(p)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
@ -340,11 +339,16 @@ func addDirectory(fes []FileEntry, base string, baseDir string, subDir string) (
|
|||
p := path.Join(baseDir, subDir)
|
||||
var size int64
|
||||
|
||||
fis, err := ioutil.ReadDir(p)
|
||||
entries, err := os.ReadDir(p)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
for _, fi := range fis {
|
||||
for _, entry := range entries {
|
||||
fi, err := entry.Info()
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
fes = append(fes, FileEntry{
|
||||
Base: base,
|
||||
Name: path.Join(subDir, fi.Name()),
|
||||
|
@ -397,7 +401,7 @@ func findFilesToBackup(cnf *Mycnf) ([]FileEntry, int64, error) {
|
|||
totalSize = totalSize + size
|
||||
|
||||
// then add DB directories
|
||||
fis, err := ioutil.ReadDir(cnf.DataDir)
|
||||
fis, err := os.ReadDir(cnf.DataDir)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
|
@ -113,7 +112,7 @@ type FileBackupStorage struct{}
|
|||
func (fbs *FileBackupStorage) ListBackups(ctx context.Context, dir string) ([]backupstorage.BackupHandle, error) {
|
||||
// ReadDir already sorts the results
|
||||
p := path.Join(*FileBackupStorageRoot, dir)
|
||||
fi, err := ioutil.ReadDir(p)
|
||||
fi, err := os.ReadDir(p)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, nil
|
||||
|
|
|
@ -18,7 +18,6 @@ package filebackupstorage
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
@ -35,7 +34,7 @@ import (
|
|||
// setupFileBackupStorage creates a temporary directory, and
|
||||
// returns a FileBackupStorage based on it
|
||||
func setupFileBackupStorage(t *testing.T) *FileBackupStorage {
|
||||
root, err := ioutil.TempDir("", "fbstest")
|
||||
root, err := os.MkdirTemp("", "fbstest")
|
||||
if err != nil {
|
||||
t.Fatalf("os.TempDir failed: %v", err)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package mysqlctl
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -37,7 +36,7 @@ func TestMycnf(t *testing.T) {
|
|||
// Assigning ServerID to be different from tablet UID to make sure that there are no
|
||||
// assumptions in the code that those IDs are the same.
|
||||
cnf.ServerID = 22222
|
||||
f, _ := ioutil.ReadFile("../../../config/mycnf/default.cnf")
|
||||
f, _ := os.ReadFile("../../../config/mycnf/default.cnf")
|
||||
myTemplateSource.Write(f)
|
||||
data, err := cnf.makeMycnf(myTemplateSource.String())
|
||||
if err != nil {
|
||||
|
@ -45,11 +44,11 @@ func TestMycnf(t *testing.T) {
|
|||
} else {
|
||||
t.Logf("data: %v", data)
|
||||
}
|
||||
err = ioutil.WriteFile(MycnfPath, []byte(data), 0666)
|
||||
err = os.WriteFile(MycnfPath, []byte(data), 0666)
|
||||
if err != nil {
|
||||
t.Errorf("failed creating my.cnf %v", err)
|
||||
}
|
||||
_, err = ioutil.ReadFile(MycnfPath)
|
||||
_, err = os.ReadFile(MycnfPath)
|
||||
if err != nil {
|
||||
t.Errorf("failed reading, err %v", err)
|
||||
return
|
||||
|
@ -106,7 +105,7 @@ func NoTestMycnfHook(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("err: %v", err)
|
||||
}
|
||||
_, err = ioutil.ReadFile(cnf.path)
|
||||
_, err = os.ReadFile(cnf.path)
|
||||
if err != nil {
|
||||
t.Errorf("failed reading, err %v", err)
|
||||
return
|
||||
|
|
|
@ -30,7 +30,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -795,12 +794,12 @@ func (mysqld *Mysqld) initConfig(cnf *Mycnf, outFile string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(outFile, []byte(configData), 0664)
|
||||
return os.WriteFile(outFile, []byte(configData), 0664)
|
||||
}
|
||||
|
||||
func (mysqld *Mysqld) getMycnfTemplate() string {
|
||||
if *mycnfTemplateFile != "" {
|
||||
data, err := ioutil.ReadFile(*mycnfTemplateFile)
|
||||
data, err := os.ReadFile(*mycnfTemplateFile)
|
||||
if err != nil {
|
||||
log.Fatalf("template file specified by -mysqlctl_mycnf_template could not be read: %v", *mycnfTemplateFile)
|
||||
}
|
||||
|
@ -832,7 +831,7 @@ func (mysqld *Mysqld) getMycnfTemplate() string {
|
|||
if extraCnf := os.Getenv("EXTRA_MY_CNF"); extraCnf != "" {
|
||||
parts := strings.Split(extraCnf, ":")
|
||||
for _, path := range parts {
|
||||
data, dataErr := ioutil.ReadFile(path)
|
||||
data, dataErr := os.ReadFile(path)
|
||||
if dataErr != nil {
|
||||
log.Infof("could not open config file for mycnf: %v", path)
|
||||
continue
|
||||
|
@ -860,7 +859,7 @@ func (mysqld *Mysqld) RefreshConfig(ctx context.Context, cnf *Mycnf) error {
|
|||
}
|
||||
|
||||
log.Info("Checking for updates to my.cnf")
|
||||
f, err := ioutil.TempFile(path.Dir(cnf.path), "my.cnf")
|
||||
f, err := os.CreateTemp(path.Dir(cnf.path), "my.cnf")
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create temp file: %v", err)
|
||||
}
|
||||
|
@ -871,11 +870,11 @@ func (mysqld *Mysqld) RefreshConfig(ctx context.Context, cnf *Mycnf) error {
|
|||
return fmt.Errorf("could not initConfig in %v: %v", f.Name(), err)
|
||||
}
|
||||
|
||||
existing, err := ioutil.ReadFile(cnf.path)
|
||||
existing, err := os.ReadFile(cnf.path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not read existing file %v: %v", cnf.path, err)
|
||||
}
|
||||
updated, err := ioutil.ReadFile(f.Name())
|
||||
updated, err := os.ReadFile(f.Name())
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not read updated file %v: %v", f.Name(), err)
|
||||
}
|
||||
|
@ -1053,7 +1052,7 @@ func (mysqld *Mysqld) executeMysqlScript(connParams *mysql.ConnParams, sql io.Re
|
|||
// defaultsExtraFile returns the filename for a temporary config file
|
||||
// that contains the user, password and socket file to connect to
|
||||
// mysqld. We write a temporary config file so the password is never
|
||||
// passed as a command line parameter. Note ioutil.TempFile uses 0600
|
||||
// passed as a command line parameter. Note os.CreateTemp uses 0600
|
||||
// as permissions, so only the local user can read the file. The
|
||||
// returned temporary file should be removed after use, typically in a
|
||||
// 'defer os.Remove()' statement.
|
||||
|
@ -1077,7 +1076,7 @@ socket=%v
|
|||
`, connParams.Uname, connParams.Pass, connParams.UnixSocket)
|
||||
}
|
||||
|
||||
tmpfile, err := ioutil.TempFile("", "example")
|
||||
tmpfile, err := os.CreateTemp("", "example")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -221,7 +221,7 @@ func (s3ServerSideEncryption *S3ServerSideEncryption) init() error {
|
|||
|
||||
if strings.HasPrefix(*sse, sseCustomerPrefix) {
|
||||
sseCustomerKeyFile := strings.TrimPrefix(*sse, sseCustomerPrefix)
|
||||
base64CodedKey, err := ioutil.ReadFile(sseCustomerKeyFile)
|
||||
base64CodedKey, err := os.ReadFile(sseCustomerKeyFile)
|
||||
if err != nil {
|
||||
log.Errorf(err.Error())
|
||||
return err
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -82,7 +81,7 @@ func TestSSEAws(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSSECustomerFileNotFound(t *testing.T) {
|
||||
tempFile, err := ioutil.TempFile("", "filename")
|
||||
tempFile, err := os.CreateTemp("", "filename")
|
||||
require.NoErrorf(t, err, "TempFile() expected to succeed")
|
||||
defer os.Remove(tempFile.Name())
|
||||
|
||||
|
@ -99,7 +98,7 @@ func TestSSECustomerFileNotFound(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSSECustomerFileBinaryKey(t *testing.T) {
|
||||
tempFile, err := ioutil.TempFile("", "filename")
|
||||
tempFile, err := os.CreateTemp("", "filename")
|
||||
require.NoErrorf(t, err, "TempFile() expected to succeed")
|
||||
defer os.Remove(tempFile.Name())
|
||||
|
||||
|
@ -132,7 +131,7 @@ func TestSSECustomerFileBinaryKey(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSSECustomerFileBase64Key(t *testing.T) {
|
||||
tempFile, err := ioutil.TempFile("", "filename")
|
||||
tempFile, err := os.CreateTemp("", "filename")
|
||||
require.NoErrorf(t, err, "TempFile() expected to succeed")
|
||||
defer os.Remove(tempFile.Name())
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package os
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
@ -74,12 +73,12 @@ func generateShellScript(commandText string, env []string, arguments ...string)
|
|||
shell := config.Config.ProcessesShellCommand
|
||||
|
||||
commandBytes := []byte(commandText)
|
||||
tmpFile, err := ioutil.TempFile("", "orchestrator-process-cmd-")
|
||||
tmpFile, err := os.CreateTemp("", "orchestrator-process-cmd-")
|
||||
if err != nil {
|
||||
return nil, "", log.Errorf("generateShellScript() failed to create TempFile: %v", err.Error())
|
||||
}
|
||||
// write commandText to temporary file
|
||||
ioutil.WriteFile(tmpFile.Name(), commandBytes, 0640)
|
||||
os.WriteFile(tmpFile.Name(), commandBytes, 0640)
|
||||
shellArguments := append([]string{}, tmpFile.Name())
|
||||
shellArguments = append(shellArguments, arguments...)
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
nethttp "net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/go-martini/martini"
|
||||
|
@ -68,7 +68,7 @@ func NewTLSConfig(caFile string, verifyCert bool) (*tls.Config, error) {
|
|||
func ReadCAFile(caFile string) (*x509.CertPool, error) {
|
||||
var caCertPool *x509.CertPool
|
||||
if caFile != "" {
|
||||
data, err := ioutil.ReadFile(caFile)
|
||||
data, err := os.ReadFile(caFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ func AppendKeyPairWithPassword(tlsConfig *tls.Config, certFile string, keyFile s
|
|||
|
||||
// Read a PEM file and ask for a password to decrypt it if needed
|
||||
func ReadPEMData(pemFile string, pemPass []byte) ([]byte, error) {
|
||||
pemData, err := ioutil.ReadFile(pemFile)
|
||||
pemData, err := os.ReadFile(pemFile)
|
||||
if err != nil {
|
||||
return pemData, err
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ func GetPEMPassword(pemFile string) []byte {
|
|||
|
||||
// Determine if PEM file is encrypted
|
||||
func IsEncryptedPEM(pemFile string) bool {
|
||||
pemData, err := ioutil.ReadFile(pemFile)
|
||||
pemData, err := os.ReadFile(pemFile)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
nethttp "net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
@ -184,11 +184,11 @@ func TestIsEncryptedPEM(t *testing.T) {
|
|||
}
|
||||
|
||||
func writeFakeFile(content string) string {
|
||||
f, err := ioutil.TempFile("", "ssl_test")
|
||||
f, err := os.CreateTemp("", "ssl_test")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
ioutil.WriteFile(f.Name(), []byte(content), 0644)
|
||||
os.WriteFile(f.Name(), []byte(content), 0644)
|
||||
return f.Name()
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package schemamanager
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
@ -77,7 +76,7 @@ func NewLocalController(schemaChangeDir string) *LocalController {
|
|||
// schema change.
|
||||
func (controller *LocalController) Open(ctx context.Context) error {
|
||||
// find all keyspace directories.
|
||||
fileInfos, err := ioutil.ReadDir(controller.schemaChangeDir)
|
||||
fileInfos, err := os.ReadDir(controller.schemaChangeDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -86,7 +85,7 @@ func (controller *LocalController) Open(ctx context.Context) error {
|
|||
continue
|
||||
}
|
||||
dirpath := path.Join(controller.schemaChangeDir, fileinfo.Name())
|
||||
schemaChanges, err := ioutil.ReadDir(path.Join(dirpath, "input"))
|
||||
schemaChanges, err := os.ReadDir(path.Join(dirpath, "input"))
|
||||
if err != nil {
|
||||
log.Warningf("there is no input dir in %s", dirpath)
|
||||
continue
|
||||
|
@ -119,7 +118,7 @@ func (controller *LocalController) Read(ctx context.Context) ([]string, error) {
|
|||
if controller.keyspace == "" || controller.sqlPath == "" {
|
||||
return []string{}, nil
|
||||
}
|
||||
data, err := ioutil.ReadFile(controller.sqlPath)
|
||||
data, err := os.ReadFile(controller.sqlPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package schemamanager
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
|
@ -31,7 +30,7 @@ import (
|
|||
)
|
||||
|
||||
func TestLocalControllerNoSchemaChanges(t *testing.T) {
|
||||
schemaChangeDir, err := ioutil.TempDir("", "localcontroller-test")
|
||||
schemaChangeDir, err := os.MkdirTemp("", "localcontroller-test")
|
||||
defer os.RemoveAll(schemaChangeDir)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temp schema change dir, error: %v", err)
|
||||
|
@ -59,7 +58,7 @@ func TestLocalControllerOpen(t *testing.T) {
|
|||
t.Fatalf("Open should fail, no such dir, but got: %v", err)
|
||||
}
|
||||
|
||||
schemaChangeDir, _ := ioutil.TempDir("", "localcontroller-test")
|
||||
schemaChangeDir, _ := os.MkdirTemp("", "localcontroller-test")
|
||||
defer os.RemoveAll(schemaChangeDir)
|
||||
|
||||
// create a file under schema change dir
|
||||
|
@ -101,7 +100,7 @@ func TestLocalControllerOpen(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLocalControllerSchemaChange(t *testing.T) {
|
||||
schemaChangeDir, err := ioutil.TempDir("", "localcontroller-test")
|
||||
schemaChangeDir, err := os.MkdirTemp("", "localcontroller-test")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temp schema change dir, error: %v", err)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package servenv
|
|||
import (
|
||||
"expvar"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
@ -91,7 +91,7 @@ func httpGet(t *testing.T, url string) string {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -78,7 +78,7 @@ func staticAuthPluginInitializer() (Authenticator, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadFile(*credsFile)
|
||||
data, err := os.ReadFile(*credsFile)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("failed to load static auth plugin %v", err)
|
||||
return nil, err
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package servenv
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
@ -34,9 +34,9 @@ func TestLivenessHandler(t *testing.T) {
|
|||
defer resp.Body.Close()
|
||||
|
||||
// Make sure we can read the body, even though it's empty.
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("ioutil.ReadAll: %v", err)
|
||||
t.Fatalf("io.ReadAll: %v", err)
|
||||
}
|
||||
t.Logf("body: %q", body)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
|
@ -176,7 +175,7 @@ func (prof *profile) mkprofile() io.WriteCloser {
|
|||
path = prof.path
|
||||
err = os.MkdirAll(path, 0777)
|
||||
} else {
|
||||
path, err = ioutil.TempDir("", "profile")
|
||||
path, err = os.MkdirTemp("", "profile")
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("pprof: could not create initial output directory: %v", err)
|
||||
|
|
|
@ -18,7 +18,7 @@ package servenv
|
|||
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"regexp"
|
||||
|
@ -51,7 +51,7 @@ func TestStatus(t *testing.T) {
|
|||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
cases := []string{
|
||||
|
@ -90,7 +90,7 @@ func TestNamedStatus(t *testing.T) {
|
|||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
cases := []string{
|
||||
|
|
|
@ -51,7 +51,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"regexp"
|
||||
"sort"
|
||||
|
@ -3411,7 +3410,7 @@ func exit(status int) {
|
|||
}
|
||||
|
||||
func gofmt() {
|
||||
src, err := ioutil.ReadFile(oflag)
|
||||
src, err := os.ReadFile(oflag)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -3419,7 +3418,7 @@ func gofmt() {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
ioutil.WriteFile(oflag, src, 0666)
|
||||
os.WriteFile(oflag, src, 0666)
|
||||
}
|
||||
|
||||
var yaccpar string // will be processed version of yaccpartext: s/$$/prefix/g
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -3531,7 +3530,7 @@ func BenchmarkParse3(b *testing.B) {
|
|||
}
|
||||
|
||||
func TestValidUnionCases(t *testing.T) {
|
||||
testOutputTempDir, err := ioutil.TempDir("", "parse_test")
|
||||
testOutputTempDir, err := os.MkdirTemp("", "parse_test")
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
if !t.Failed() {
|
||||
|
@ -3543,7 +3542,7 @@ func TestValidUnionCases(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestValidSelectCases(t *testing.T) {
|
||||
testOutputTempDir, err := ioutil.TempDir("", "parse_test")
|
||||
testOutputTempDir, err := os.MkdirTemp("", "parse_test")
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
if !t.Failed() {
|
||||
|
@ -3607,7 +3606,7 @@ func testFile(t *testing.T, filename, tempDir string) {
|
|||
|
||||
if fail && tempDir != "" {
|
||||
gotFile := fmt.Sprintf("%s/%s", tempDir, filename)
|
||||
_ = ioutil.WriteFile(gotFile, []byte(strings.TrimSpace(expected.String())+"\n"), 0644)
|
||||
_ = os.WriteFile(gotFile, []byte(strings.TrimSpace(expected.String())+"\n"), 0644)
|
||||
fmt.Println(fmt.Sprintf("Errors found in parse tests. If the output is correct, run `cp %s/* testdata/` to update test expectations", tempDir)) // nolint
|
||||
}
|
||||
})
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -107,7 +107,7 @@ func (tacl *tableACL) init(configFile string, aclCB func()) error {
|
|||
if configFile == "" {
|
||||
return nil
|
||||
}
|
||||
data, err := ioutil.ReadFile(configFile)
|
||||
data, err := os.ReadFile(configFile)
|
||||
if err != nil {
|
||||
log.Infof("unable to read tableACL config file: %v Error: %v", configFile, err)
|
||||
return err
|
||||
|
|
|
@ -19,7 +19,6 @@ package tableacl
|
|||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
@ -59,7 +58,7 @@ var aclJSON = `{
|
|||
|
||||
func TestInitWithValidConfig(t *testing.T) {
|
||||
tacl := tableACL{factory: &simpleacl.Factory{}}
|
||||
f, err := ioutil.TempFile("", "tableacl")
|
||||
f, err := os.CreateTemp("", "tableacl")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package tlstest
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -108,7 +107,7 @@ func CreateCA(root string) {
|
|||
openssl("genrsa", "-out", key)
|
||||
|
||||
config := path.Join(root, "ca.config")
|
||||
if err := ioutil.WriteFile(config, []byte(caConfig), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(config, []byte(caConfig), os.ModePerm); err != nil {
|
||||
log.Fatalf("cannot write file %v: %v", config, err)
|
||||
}
|
||||
openssl("req", "-new", "-x509", "-nodes", "-days", "3600", "-batch",
|
||||
|
@ -129,7 +128,7 @@ func CreateSignedCert(root, parent, serial, name, commonName string) {
|
|||
req := path.Join(root, name+"-req.pem")
|
||||
|
||||
config := path.Join(root, name+".config")
|
||||
if err := ioutil.WriteFile(config, []byte(fmt.Sprintf(certConfig, commonName, commonName)), os.ModePerm); err != nil {
|
||||
if err := os.WriteFile(config, []byte(fmt.Sprintf(certConfig, commonName, commonName)), os.ModePerm); err != nil {
|
||||
log.Fatalf("cannot write file %v: %v", config, err)
|
||||
}
|
||||
openssl("req", "-newkey", "rsa:2048", "-days", "3600", "-nodes",
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"crypto/x509"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -49,7 +48,7 @@ func TestClientServerWithCombineCerts(t *testing.T) {
|
|||
// And then performs a few tests on them.
|
||||
func testClientServer(t *testing.T, combineCerts bool) {
|
||||
// Our test root.
|
||||
root, err := ioutil.TempDir("", "tlstest")
|
||||
root, err := os.MkdirTemp("", "tlstest")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
@ -234,7 +233,7 @@ func TestClientTLSConfigCaching(t *testing.T) {
|
|||
|
||||
func testConfigGeneration(t *testing.T, rootPrefix string, generateConfig func(ClientServerKeyPairs) (*tls.Config, error), getCertPool func(tlsConfig *tls.Config) *x509.CertPool) {
|
||||
// Our test root.
|
||||
root, err := ioutil.TempDir("", rootPrefix)
|
||||
root, err := os.MkdirTemp("", rootPrefix)
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
@ -281,7 +280,7 @@ func testConfigGeneration(t *testing.T, rootPrefix string, generateConfig func(C
|
|||
|
||||
func testNumberOfCertsWithOrWithoutCombining(t *testing.T, numCertsExpected int, combine bool) {
|
||||
// Our test root.
|
||||
root, err := ioutil.TempDir("", "tlstest")
|
||||
root, err := os.MkdirTemp("", "tlstest")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir failed: %v", err)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -72,7 +72,7 @@ func getClientCreds() (creds map[string]*ClientAuthCred, err error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadFile(*consulAuthClientStaticFile)
|
||||
data, err := os.ReadFile(*consulAuthClientStaticFile)
|
||||
if err != nil {
|
||||
err = vterrors.Wrapf(err, "Failed to read consul_auth_static_file file")
|
||||
return creds, err
|
||||
|
|
|
@ -19,7 +19,6 @@ package consultopo
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -46,7 +45,7 @@ func startConsul(t *testing.T, authToken string) (*exec.Cmd, string, string) {
|
|||
// Create a temporary config file, as ports cannot all be set
|
||||
// via command line. The file name has to end with '.json' so
|
||||
// we're not using TempFile.
|
||||
configDir, err := ioutil.TempDir("", "consul")
|
||||
configDir, err := os.MkdirTemp("", "consul")
|
||||
if err != nil {
|
||||
t.Fatalf("cannot create temp dir: %v", err)
|
||||
}
|
||||
|
@ -236,7 +235,7 @@ func TestConsulTopoWithAuth(t *testing.T) {
|
|||
|
||||
// Run the TopoServerTestSuite tests.
|
||||
testIndex := 0
|
||||
tmpFile, err := ioutil.TempFile("", "consul_auth_client_static_file.json")
|
||||
tmpFile, err := os.CreateTemp("", "consul_auth_client_static_file.json")
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't create temp file: %v", err)
|
||||
|
@ -246,7 +245,7 @@ func TestConsulTopoWithAuth(t *testing.T) {
|
|||
*consulAuthClientStaticFile = tmpFile.Name()
|
||||
|
||||
jsonConfig := "{\"global\":{\"acl_token\":\"123456\"}, \"test\":{\"acl_token\":\"123456\"}}"
|
||||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
if err := os.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
t.Fatalf("couldn't write temp file: %v", err)
|
||||
}
|
||||
|
||||
|
@ -285,7 +284,7 @@ func TestConsulTopoWithAuthFailure(t *testing.T) {
|
|||
os.Remove(configFilename)
|
||||
}()
|
||||
|
||||
tmpFile, err := ioutil.TempFile("", "consul_auth_client_static_file.json")
|
||||
tmpFile, err := os.CreateTemp("", "consul_auth_client_static_file.json")
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't create temp file: %v", err)
|
||||
|
@ -295,7 +294,7 @@ func TestConsulTopoWithAuthFailure(t *testing.T) {
|
|||
*consulAuthClientStaticFile = tmpFile.Name()
|
||||
|
||||
jsonConfig := "{\"global\":{\"acl_token\":\"badtoken\"}}"
|
||||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
if err := os.WriteFile(tmpFile.Name(), []byte(jsonConfig), 0600); err != nil {
|
||||
t.Fatalf("couldn't write temp file: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package etcd2topo
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -39,7 +38,7 @@ import (
|
|||
// startEtcd starts an etcd subprocess, and waits for it to be ready.
|
||||
func startEtcd(t *testing.T) (*exec.Cmd, string, string) {
|
||||
// Create a temporary directory.
|
||||
dataDir, err := ioutil.TempDir("", "etcd")
|
||||
dataDir, err := os.MkdirTemp("", "etcd")
|
||||
if err != nil {
|
||||
t.Fatalf("cannot create tempdir: %v", err)
|
||||
}
|
||||
|
@ -93,7 +92,7 @@ func startEtcd(t *testing.T) (*exec.Cmd, string, string) {
|
|||
// startEtcdWithTLS starts an etcd subprocess with TLS setup, and waits for it to be ready.
|
||||
func startEtcdWithTLS(t *testing.T) (string, *tlstest.ClientServerKeyPairs, func()) {
|
||||
// Create a temporary directory.
|
||||
dataDir, err := ioutil.TempDir("", "etcd")
|
||||
dataDir, err := os.MkdirTemp("", "etcd")
|
||||
if err != nil {
|
||||
t.Fatalf("cannot create tempdir: %v", err)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ package k8stopo
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
@ -161,7 +161,7 @@ func NewServer(_, root string) (*Server, error) {
|
|||
}
|
||||
|
||||
// When running in the cluster, use the namespace file to detect the current namespace
|
||||
nsBytes, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
||||
nsBytes, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
|
@ -46,14 +45,14 @@ func TestKubernetesTopo(t *testing.T) {
|
|||
}
|
||||
|
||||
// Create a data dir for test data
|
||||
testDataDir, err := ioutil.TempDir("", "vt-test-k3s")
|
||||
testDataDir, err := os.MkdirTemp("", "vt-test-k3s")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(testDataDir) // clean up
|
||||
|
||||
// Gen a temp file name for the config
|
||||
testConfig, err := ioutil.TempFile("", "vt-test-k3s-config")
|
||||
testConfig, err := os.CreateTemp("", "vt-test-k3s-config")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ import (
|
|||
"crypto/x509"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -291,7 +291,7 @@ func (c *ZkConn) maybeAddAuth(ctx context.Context) {
|
|||
if *authFile == "" {
|
||||
return
|
||||
}
|
||||
authInfoBytes, err := ioutil.ReadFile(*authFile)
|
||||
authInfoBytes, err := os.ReadFile(*authFile)
|
||||
if err != nil {
|
||||
log.Errorf("failed to read topo_zk_auth_file: %v", err)
|
||||
return
|
||||
|
@ -358,7 +358,7 @@ func dialZk(ctx context.Context, addr string) (*zk.Conn, <-chan zk.Event, error)
|
|||
log.Fatalf("Unable to load cert %v and key %v, err %v", *certPath, *keyPath, err)
|
||||
}
|
||||
|
||||
clientCACert, err := ioutil.ReadFile(*caPath)
|
||||
clientCACert, err := os.ReadFile(*caPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to open ca cert %v, err %v", *caPath, err)
|
||||
}
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче