diff --git a/acceptanceTests/config_test.go b/acceptanceTests/config_test.go index 00b8be371..e0054d8e7 100644 --- a/acceptanceTests/config_test.go +++ b/acceptanceTests/config_test.go @@ -2,7 +2,6 @@ package acceptanceTests import ( "fmt" - "io/ioutil" "os" "os/exec" "testing" @@ -58,7 +57,7 @@ func TestConfigRegenerate(t *testing.T) { return } - _, readFileErr := ioutil.ReadFile(configPath) + _, readFileErr := os.ReadFile(configPath) if readFileErr != nil { t.Errorf("failed to read config file, err: %v", readFileErr) return @@ -95,7 +94,7 @@ func TestConfigGuiPort(t *testing.T) { return } - if writeErr := ioutil.WriteFile(configPath, configBytes, 0644); writeErr != nil { + if writeErr := os.WriteFile(configPath, configBytes, 0644); writeErr != nil { t.Errorf("failed to write config to file, err: %v", writeErr) return } @@ -168,7 +167,7 @@ func TestConfigSetGuiPort(t *testing.T) { return } - if writeErr := ioutil.WriteFile(configPath, configBytes, 0644); writeErr != nil { + if writeErr := os.WriteFile(configPath, configBytes, 0644); writeErr != nil { t.Errorf("failed to write config to file, err: %v", writeErr) return } @@ -243,7 +242,7 @@ func TestConfigFlagGuiPort(t *testing.T) { return } - if writeErr := ioutil.WriteFile(configPath, configBytes, 0644); writeErr != nil { + if writeErr := os.WriteFile(configPath, configBytes, 0644); writeErr != nil { t.Errorf("failed to write config to file, err: %v", writeErr) return } diff --git a/acceptanceTests/tap_test.go b/acceptanceTests/tap_test.go index 03e49bcef..0aa33e686 100644 --- a/acceptanceTests/tap_test.go +++ b/acceptanceTests/tap_test.go @@ -3,7 +3,7 @@ package acceptanceTests import ( "archive/zip" "fmt" - "io/ioutil" + "os" "os/exec" "path" "strings" @@ -532,7 +532,7 @@ func TestTapDumpLogs(t *testing.T) { return } - files, readErr := ioutil.ReadDir(kubesharkFolderPath) + files, readErr := os.ReadDir(kubesharkFolderPath) if readErr != nil { t.Errorf("failed to read kubeshark folder files, err: %v", readErr) return diff --git a/acceptanceTests/testsUtils.go b/acceptanceTests/testsUtils.go index 1f0222424..68fa91670 100644 --- a/acceptanceTests/testsUtils.go +++ b/acceptanceTests/testsUtils.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "os/exec" @@ -330,7 +330,7 @@ func ExecuteHttpRequest(response *http.Response, requestErr error) (interface{}, defer func() { response.Body.Close() }() - data, readErr := ioutil.ReadAll(response.Body) + data, readErr := io.ReadAll(response.Body) if readErr != nil { return nil, readErr } diff --git a/agent/main.go b/agent/main.go index 110f8952b..afbb392fc 100644 --- a/agent/main.go +++ b/agent/main.go @@ -5,7 +5,6 @@ import ( "errors" "flag" "fmt" - "io/ioutil" "net/http" "os" "os/signal" @@ -223,7 +222,7 @@ func disableRootStaticCache() gin.HandlerFunc { } func setUIFlags(uiIndexPath string) error { - read, err := ioutil.ReadFile(uiIndexPath) + read, err := os.ReadFile(uiIndexPath) if err != nil { return err } @@ -231,7 +230,7 @@ func setUIFlags(uiIndexPath string) error { replacedContent := strings.Replace(string(read), "__IS_OAS_ENABLED__", strconv.FormatBool(config.Config.OAS.Enable), 1) replacedContent = strings.Replace(replacedContent, "__IS_SERVICE_MAP_ENABLED__", strconv.FormatBool(config.Config.ServiceMap), 1) - err = ioutil.WriteFile(uiIndexPath, []byte(replacedContent), 0) + err = os.WriteFile(uiIndexPath, []byte(replacedContent), 0) if err != nil { return err } diff --git a/agent/pkg/config/config.go b/agent/pkg/config/config.go index 3065c4875..c41eda785 100644 --- a/agent/pkg/config/config.go +++ b/agent/pkg/config/config.go @@ -3,7 +3,6 @@ package config import ( "encoding/json" "fmt" - "io/ioutil" "os" "github.com/kubeshark/kubeshark/shared" @@ -23,7 +22,7 @@ func LoadConfig() error { } filePath := fmt.Sprintf("%s%s", shared.ConfigDirPath, shared.ConfigFileName) - content, err := ioutil.ReadFile(filePath) + content, err := os.ReadFile(filePath) if err != nil { if os.IsNotExist(err) { return applyDefaultConfig() diff --git a/agent/pkg/oas/feeder_test.go b/agent/pkg/oas/feeder_test.go index 05cb61b19..04be4e09e 100644 --- a/agent/pkg/oas/feeder_test.go +++ b/agent/pkg/oas/feeder_test.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/url" "os" "path/filepath" @@ -111,7 +110,7 @@ func feedFromHAR(file string, isSync bool, gen *defaultOasGenerator) (uint, erro defer fd.Close() - data, err := ioutil.ReadAll(fd) + data, err := io.ReadAll(fd) if err != nil { return 0, err } diff --git a/agent/pkg/oas/specgen.go b/agent/pkg/oas/specgen.go index b680f67ff..dfbff977d 100644 --- a/agent/pkg/oas/specgen.go +++ b/agent/pkg/oas/specgen.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "io" - "io/ioutil" "mime" "mime/multipart" "net/textproto" @@ -615,7 +614,7 @@ func handleFormDataMultipart(text string, content *openapi.MediaType, ctypeParam } defer part.Close() - body, err := ioutil.ReadAll(part) + body, err := io.ReadAll(part) if err != nil { logger.Log.Errorf("Error reading multipart Part %s: %v", part.Header, err) } diff --git a/agent/pkg/oas/specgen_test.go b/agent/pkg/oas/specgen_test.go index 4a5c78a80..3073108f6 100644 --- a/agent/pkg/oas/specgen_test.go +++ b/agent/pkg/oas/specgen_test.go @@ -2,7 +2,7 @@ package oas import ( "encoding/json" - "io/ioutil" + "io" "os" "regexp" "strings" @@ -29,7 +29,7 @@ func outputSpec(label string, spec *openapi.OpenAPI, t *testing.T) string { if err != nil { panic(err) } - err = ioutil.WriteFile(path+"/"+label+".json", content, 0644) + err = os.WriteFile(path+"/"+label+".json", content, 0644) if err != nil { panic(err) } @@ -150,7 +150,7 @@ func TestFileSingle(t *testing.T) { t.FailNow() } - expected, err := ioutil.ReadFile(file + ".spec.json") + expected, err := os.ReadFile(file + ".spec.json") if err != nil { t.Errorf(err.Error()) t.FailNow() @@ -170,7 +170,7 @@ func TestFileSingle(t *testing.T) { } if os.Getenv("KUBESHARK_OAS_WRITE_FILES") != "" { - err = ioutil.WriteFile(file+".spec.json", []byte(specText), 0644) + err = os.WriteFile(file+".spec.json", []byte(specText), 0644) if err != nil { panic(err) } @@ -194,7 +194,7 @@ func loadStartingOAS(file string, label string, specs *sync.Map) { defer fd.Close() - data, err := ioutil.ReadAll(fd) + data, err := io.ReadAll(fd) if err != nil { panic(err) } @@ -252,7 +252,7 @@ func TestLoadValid3_1(t *testing.T) { defer fd.Close() - data, err := ioutil.ReadAll(fd) + data, err := io.ReadAll(fd) if err != nil { t.Log(err) t.FailNow() diff --git a/agent/pkg/utils/utils.go b/agent/pkg/utils/utils.go index 83e17b0d3..ac8917318 100644 --- a/agent/pkg/utils/utils.go +++ b/agent/pkg/utils/utils.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/http" "os" "os/signal" @@ -59,7 +58,7 @@ func CheckErr(e error) { } func ReadJsonFile(filePath string, value interface{}) error { - if content, err := ioutil.ReadFile(filePath); err != nil { + if content, err := os.ReadFile(filePath); err != nil { return err } else { if err = json.Unmarshal(content, value); err != nil { @@ -74,7 +73,7 @@ func SaveJsonFile(filePath string, value interface{}) error { if data, err := json.Marshal(value); err != nil { return err } else { - if err = ioutil.WriteFile(filePath, data, 0644); err != nil { + if err = os.WriteFile(filePath, data, 0644); err != nil { return err } } diff --git a/cli/bucket/provider.go b/cli/bucket/provider.go index 0e223854f..6114fcc1d 100644 --- a/cli/bucket/provider.go +++ b/cli/bucket/provider.go @@ -2,10 +2,11 @@ package bucket import ( "fmt" - "github.com/kubeshark/kubeshark/cli/utils" - "io/ioutil" + "io" "net/http" "time" + + "github.com/kubeshark/kubeshark/cli/utils" ) type Provider struct { @@ -33,7 +34,7 @@ func (provider *Provider) GetInstallTemplate(templateName string) (string, error defer response.Body.Close() - installTemplate, err := ioutil.ReadAll(response.Body) + installTemplate, err := io.ReadAll(response.Body) if err != nil { return "", err } diff --git a/cli/config/config.go b/cli/config/config.go index 718db5d59..e5fd0c5c2 100644 --- a/cli/config/config.go +++ b/cli/config/config.go @@ -3,7 +3,7 @@ package config import ( "errors" "fmt" - "io/ioutil" + "io" "os" "reflect" "strconv" @@ -78,7 +78,7 @@ func WriteConfig(config *ConfigStruct) error { } data := []byte(template) - if err := ioutil.WriteFile(Config.ConfigFilePath, data, 0644); err != nil { + if err := os.WriteFile(Config.ConfigFilePath, data, 0644); err != nil { return fmt.Errorf("failed writing config, err: %v", err) } @@ -91,7 +91,7 @@ func loadConfigFile(configFilePath string, config *ConfigStruct) error { return openErr } - buf, readErr := ioutil.ReadAll(reader) + buf, readErr := io.ReadAll(reader) if readErr != nil { return readErr } diff --git a/cli/config/configStructs/tapConfig.go b/cli/config/configStructs/tapConfig.go index 70cb75fa1..8a7d27cdd 100644 --- a/cli/config/configStructs/tapConfig.go +++ b/cli/config/configStructs/tapConfig.go @@ -3,7 +3,6 @@ package configStructs import ( "fmt" "io/fs" - "io/ioutil" "os" "regexp" "strings" @@ -70,7 +69,7 @@ func (config *TapConfig) GetInsertionFilter() string { insertionFilter := config.InsertionFilter if fs.ValidPath(insertionFilter) { if _, err := os.Stat(insertionFilter); err == nil { - b, err := ioutil.ReadFile(insertionFilter) + b, err := os.ReadFile(insertionFilter) if err != nil { logger.Log.Warningf(uiUtils.Warning, fmt.Sprintf("Couldn't read the file on path: %s, err: %v", insertionFilter, err)) } else { diff --git a/cli/kubeshark/version/versionCheck.go b/cli/kubeshark/version/versionCheck.go index af43d1307..42976face 100644 --- a/cli/kubeshark/version/versionCheck.go +++ b/cli/kubeshark/version/versionCheck.go @@ -3,7 +3,7 @@ package version import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "runtime" "strings" @@ -47,7 +47,7 @@ func CheckNewerVersion(versionChan chan string) { return } - data, err := ioutil.ReadAll(res.Body) + data, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { logger.Log.Debugf("[ERROR] Failed to read the version file -> %v", err) diff --git a/cli/utils/httpUtils.go b/cli/utils/httpUtils.go index 0d35f8899..68aeb7dce 100644 --- a/cli/utils/httpUtils.go +++ b/cli/utils/httpUtils.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net/http" "strings" ) @@ -32,7 +31,7 @@ func checkError(response *http.Response, errInOperation error) (*http.Response, return response, errInOperation // Check only if status != 200 (and not status >= 300). Agent APIs return only 200 on success. } else if response.StatusCode != http.StatusOK { - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) response.Body.Close() response.Body = io.NopCloser(bytes.NewBuffer(body)) // rewind if err != nil { diff --git a/tap/extensions/amqp/main_test.go b/tap/extensions/amqp/main_test.go index c68a1d05d..7d7427b71 100644 --- a/tap/extensions/amqp/main_test.go +++ b/tap/extensions/amqp/main_test.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "os" "path" @@ -192,7 +191,7 @@ func TestDissect(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, items, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -222,7 +221,7 @@ func TestAnalyze(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgAnalyzing, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var items []*api.OutputChannelItem @@ -249,7 +248,7 @@ func TestAnalyze(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, items, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -279,7 +278,7 @@ func TestSummarize(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgSummarizing, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var entries []*api.Entry @@ -306,7 +305,7 @@ func TestSummarize(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, entries, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -336,7 +335,7 @@ func TestRepresent(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgRepresenting, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var entries []*api.Entry @@ -364,7 +363,7 @@ func TestRepresent(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, objects, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) diff --git a/tap/extensions/http/handlers.go b/tap/extensions/http/handlers.go index fa3efdacc..e6c355c7f 100644 --- a/tap/extensions/http/handlers.go +++ b/tap/extensions/http/handlers.go @@ -5,7 +5,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net/http" "strings" "time" @@ -124,7 +123,7 @@ func handleHTTP1ClientStream(b *bufio.Reader, progress *api.ReadProgress, captur } var body []byte - body, err = ioutil.ReadAll(req.Body) + body, err = io.ReadAll(req.Body) req.Body = io.NopCloser(bytes.NewBuffer(body)) // rewind ident := fmt.Sprintf( @@ -168,7 +167,7 @@ func handleHTTP1ServerStream(b *bufio.Reader, progress *api.ReadProgress, captur } var body []byte - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) res.Body = io.NopCloser(bytes.NewBuffer(body)) // rewind ident := fmt.Sprintf( diff --git a/tap/extensions/http/main_test.go b/tap/extensions/http/main_test.go index 30af39e5d..a2a910e40 100644 --- a/tap/extensions/http/main_test.go +++ b/tap/extensions/http/main_test.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "os" "path" @@ -195,7 +194,7 @@ func TestDissect(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, items, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -225,7 +224,7 @@ func TestAnalyze(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgAnalyzing, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var items []*api.OutputChannelItem @@ -252,7 +251,7 @@ func TestAnalyze(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, items, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -282,7 +281,7 @@ func TestSummarize(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgSummarizing, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var entries []*api.Entry @@ -309,7 +308,7 @@ func TestSummarize(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, entries, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -339,7 +338,7 @@ func TestRepresent(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgRepresenting, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var entries []*api.Entry @@ -367,7 +366,7 @@ func TestRepresent(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, objects, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) diff --git a/tap/extensions/kafka/decode.go b/tap/extensions/kafka/decode.go index c27bd0f77..f9728d019 100644 --- a/tap/extensions/kafka/decode.go +++ b/tap/extensions/kafka/decode.go @@ -5,7 +5,6 @@ import ( "fmt" "hash/crc32" "io" - "io/ioutil" "reflect" "strings" ) @@ -166,7 +165,7 @@ func (d *decoder) discard(n int) { n, err = r.Discard(n) d.remain -= n } else { - _, err = io.Copy(ioutil.Discard, d) + _, err = io.Copy(io.Discard, d) } d.setError(err) } diff --git a/tap/extensions/kafka/main_test.go b/tap/extensions/kafka/main_test.go index 00d216f1c..86b8580f5 100644 --- a/tap/extensions/kafka/main_test.go +++ b/tap/extensions/kafka/main_test.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "os" "path" @@ -193,7 +192,7 @@ func TestDissect(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, items, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -223,7 +222,7 @@ func TestAnalyze(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgAnalyzing, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var items []*api.OutputChannelItem @@ -250,7 +249,7 @@ func TestAnalyze(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, items, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -280,7 +279,7 @@ func TestSummarize(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgSummarizing, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var entries []*api.Entry @@ -307,7 +306,7 @@ func TestSummarize(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, entries, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -337,7 +336,7 @@ func TestRepresent(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgRepresenting, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var entries []*api.Entry @@ -365,7 +364,7 @@ func TestRepresent(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, objects, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) diff --git a/tap/extensions/redis/main_test.go b/tap/extensions/redis/main_test.go index 392be51cd..386cb48ae 100644 --- a/tap/extensions/redis/main_test.go +++ b/tap/extensions/redis/main_test.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "os" "path" @@ -193,7 +192,7 @@ func TestDissect(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, items, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -223,7 +222,7 @@ func TestAnalyze(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgAnalyzing, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var items []*api.OutputChannelItem @@ -250,7 +249,7 @@ func TestAnalyze(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, items, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -280,7 +279,7 @@ func TestSummarize(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgSummarizing, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var entries []*api.Entry @@ -307,7 +306,7 @@ func TestSummarize(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, entries, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) @@ -337,7 +336,7 @@ func TestRepresent(t *testing.T) { for _, _path := range paths { fmt.Printf("%s %s\n", msgRepresenting, _path) - bytes, err := ioutil.ReadFile(_path) + bytes, err := os.ReadFile(_path) assert.Nil(t, err) var entries []*api.Entry @@ -365,7 +364,7 @@ func TestRepresent(t *testing.T) { if _, err := os.Stat(pathExpect); errors.Is(err, os.ErrNotExist) { assert.Len(t, objects, 0) } else { - expectedBytes, err := ioutil.ReadFile(pathExpect) + expectedBytes, err := os.ReadFile(pathExpect) assert.Nil(t, err) assert.JSONEq(t, string(expectedBytes), string(marshaled)) diff --git a/tap/source/discoverer_util.go b/tap/source/discoverer_util.go index 5221e6779..260a4513f 100644 --- a/tap/source/discoverer_util.go +++ b/tap/source/discoverer_util.go @@ -1,7 +1,7 @@ package source import ( - "io/ioutil" + "os" "regexp" "strings" @@ -11,7 +11,7 @@ import ( var numberRegex = regexp.MustCompile("[0-9]+") func getSingleValueFromEnvironmentVariableFile(filePath string, variableName string) (string, error) { - bytes, err := ioutil.ReadFile(filePath) + bytes, err := os.ReadFile(filePath) if err != nil { logger.Log.Warningf("Error reading environment file %v - %v", filePath, err) diff --git a/tap/source/envoy_discoverer.go b/tap/source/envoy_discoverer.go index 69ad6749b..0c7f71a4c 100644 --- a/tap/source/envoy_discoverer.go +++ b/tap/source/envoy_discoverer.go @@ -2,7 +2,6 @@ package source import ( "fmt" - "io/ioutil" "os" "strings" @@ -15,7 +14,7 @@ const envoyBinary = "/envoy" func discoverRelevantEnvoyPids(procfs string, pods []v1.Pod) ([]string, error) { result := make([]string, 0) - pids, err := ioutil.ReadDir(procfs) + pids, err := os.ReadDir(procfs) if err != nil { return result, err diff --git a/tap/source/linkerd_discoverer.go b/tap/source/linkerd_discoverer.go index 68ba93de0..158193bf5 100644 --- a/tap/source/linkerd_discoverer.go +++ b/tap/source/linkerd_discoverer.go @@ -2,7 +2,6 @@ package source import ( "fmt" - "io/ioutil" "os" "strings" @@ -15,7 +14,7 @@ const linkerdBinary = "/linkerd2-proxy" func discoverRelevantLinkerdPids(procfs string, pods []v1.Pod) ([]string, error) { result := make([]string, 0) - pids, err := ioutil.ReadDir(procfs) + pids, err := os.ReadDir(procfs) if err != nil { return result, err diff --git a/tap/tlstapper/tls_process_discoverer.go b/tap/tlstapper/tls_process_discoverer.go index 465f02739..a49576ff8 100644 --- a/tap/tlstapper/tls_process_discoverer.go +++ b/tap/tlstapper/tls_process_discoverer.go @@ -2,8 +2,8 @@ package tlstapper import ( "fmt" - "io/ioutil" "net/url" + "os" "path" "path/filepath" "regexp" @@ -43,7 +43,7 @@ func UpdateTapTargets(tls *TlsTapper, pods *[]v1.Pod, procfs string) error { func findContainerPids(procfs string, containerIds map[string]v1.Pod) (map[uint32]v1.Pod, error) { result := make(map[uint32]v1.Pod) - pids, err := ioutil.ReadDir(procfs) + pids, err := os.ReadDir(procfs) if err != nil { return result, err @@ -107,7 +107,7 @@ func buildContainerIdsMap(pods *[]v1.Pod) map[string]v1.Pod { func getProcessCgroup(procfs string, pid string) (string, error) { filePath := fmt.Sprintf("%s/%s/cgroup", procfs, pid) - bytes, err := ioutil.ReadFile(filePath) + bytes, err := os.ReadFile(filePath) if err != nil { logger.Log.Warningf("Error reading cgroup file %s - %v", filePath, err)