diff --git a/pkg/clients/docker/docker_client.go b/pkg/clients/docker/docker_client.go index 2e59baf586..130d006154 100755 --- a/pkg/clients/docker/docker_client.go +++ b/pkg/clients/docker/docker_client.go @@ -3,7 +3,7 @@ package docker import ( "context" "fmt" - "io/ioutil" + "os" "path/filepath" "time" @@ -215,7 +215,7 @@ type Compose struct { // CheckBindMounts returns information about whether bind mounts if they are being used contain relative file names or not func (idc *internalDockerClient) CheckBindMounts(filePath string) bool { - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { idc.logger.Error("error reading file", zap.Any("filePath", filePath), zap.Error(err)) return false @@ -260,7 +260,7 @@ func (idc *internalDockerClient) CheckBindMounts(filePath string) bool { // CheckNetworkInfo returns information about network name and also about whether the network is external or not in a docker-compose file. func (idc *internalDockerClient) CheckNetworkInfo(filePath string) (bool, bool, string) { - data, err := ioutil.ReadFile(filePath) + data, err := os.ReadFile(filePath) if err != nil { idc.logger.Error("error reading file", zap.Any("filePath", filePath), zap.Error(err)) return false, false, "" @@ -359,7 +359,7 @@ func (idc *internalDockerClient) GetHostWorkingDirectory() (string, error) { // ReplaceRelativePaths replaces relative paths in bind mounts with absolute paths func (idc *internalDockerClient) ReplaceRelativePaths(dockerComposefilePath, newComposeFile string) error { - data, err := ioutil.ReadFile(dockerComposefilePath) + data, err := os.ReadFile(dockerComposefilePath) if err != nil { return err } @@ -419,7 +419,7 @@ func (idc *internalDockerClient) ReplaceRelativePaths(dockerComposefilePath, new } newFilePath := filepath.Join(filepath.Dir(dockerComposefilePath), newComposeFile) - err = ioutil.WriteFile(newFilePath, newData, 0644) + err = os.WriteFile(newFilePath, newData, 0644) if err != nil { return err } @@ -429,7 +429,7 @@ func (idc *internalDockerClient) ReplaceRelativePaths(dockerComposefilePath, new // MakeNetworkExternal makes the existing network of the user docker compose file external and save it to a new file func (idc *internalDockerClient) MakeNetworkExternal(dockerComposefilePath, newComposeFile string) error { - data, err := ioutil.ReadFile(dockerComposefilePath) + data, err := os.ReadFile(dockerComposefilePath) if err != nil { return err } @@ -486,7 +486,7 @@ func (idc *internalDockerClient) MakeNetworkExternal(dockerComposefilePath, newC } newFilePath := filepath.Join(filepath.Dir(dockerComposefilePath), newComposeFile) - err = ioutil.WriteFile(newFilePath, newData, 0644) + err = os.WriteFile(newFilePath, newData, 0644) if err != nil { return err } @@ -497,7 +497,7 @@ func (idc *internalDockerClient) MakeNetworkExternal(dockerComposefilePath, newC // AddNetworkToCompose adds the keploy-network network to the new docker compose file and copy rest of the contents from // existing user docker compose file func (idc *internalDockerClient) AddNetworkToCompose(dockerComposefilePath, newComposeFile string) error { - data, err := ioutil.ReadFile(dockerComposefilePath) + data, err := os.ReadFile(dockerComposefilePath) if err != nil { return err } @@ -572,7 +572,7 @@ func (idc *internalDockerClient) AddNetworkToCompose(dockerComposefilePath, newC } newFilePath := filepath.Join(filepath.Dir(dockerComposefilePath), newComposeFile) - err = ioutil.WriteFile(newFilePath, newData, 0644) + err = os.WriteFile(newFilePath, newData, 0644) if err != nil { return err } diff --git a/pkg/platform/telemetry/utils.go b/pkg/platform/telemetry/utils.go index f94592eeec..a1022fdbeb 100644 --- a/pkg/platform/telemetry/utils.go +++ b/pkg/platform/telemetry/utils.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "io" - "io/ioutil" "net/http" "go.keploy.io/server/pkg/models" @@ -31,7 +30,7 @@ func unmarshalResp(resp *http.Response, log *zap.Logger) (id string, err error) }(resp.Body) var res map[string]string - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { log.Debug("failed to read response from telemetry server", zap.String("url", "https://telemetry.keploy.io/analytics"), zap.Error(err)) return diff --git a/pkg/proxy/integrations/httpparser/httpparser.go b/pkg/proxy/integrations/httpparser/httpparser.go index 81a6e86555..f5c763c07d 100755 --- a/pkg/proxy/integrations/httpparser/httpparser.go +++ b/pkg/proxy/integrations/httpparser/httpparser.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net" "net/http" "net/url" @@ -344,7 +343,7 @@ func decodeOutgoingHttp(requestBuffer []byte, clientConn, destConn net.Conn, h * return } - reqBody, err := ioutil.ReadAll(req.Body) + reqBody, err := io.ReadAll(req.Body) if err != nil { logger.Error("failed to read from request body", zap.Error(err)) diff --git a/pkg/proxy/proxy.go b/pkg/proxy/proxy.go index 95e5bd7b71..7d1063ef8f 100755 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -10,7 +10,6 @@ import ( "embed" "fmt" "io" - "io/ioutil" "log" "net" "os" @@ -153,7 +152,7 @@ func isJavaInstalled() bool { // to extract ca certificate to temp func ExtractCertToTemp() (string, error) { - tempFile, err := ioutil.TempFile("", "ca.crt") + tempFile, err := os.CreateTemp("", "ca.crt") if err != nil { return "", err } diff --git a/utils/utils.go b/utils/utils.go index 8f2802e3aa..0630851174 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -4,7 +4,7 @@ import ( "bufio" "errors" "fmt" - "io/ioutil" + "io" "os" "runtime/debug" "strings" @@ -58,7 +58,7 @@ func attachLogFileToSentry(logFilePath string) { } defer file.Close() - content, _ := ioutil.ReadAll(file) + content, _ := io.ReadAll(file) sentry.ConfigureScope(func(scope *sentry.Scope) { scope.SetExtra("logfile", string(content))