diff --git a/pkg/controller/scheduler_daemonset_test.go b/pkg/controller/scheduler_daemonset_test.go index e76776691..1551a7bf0 100644 --- a/pkg/controller/scheduler_daemonset_test.go +++ b/pkg/controller/scheduler_daemonset_test.go @@ -20,7 +20,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -445,7 +445,7 @@ func TestScheduler_DaemonSetTargetPortName(t *testing.T) { func TestScheduler_DaemonSetAlerts(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) require.NoError(t, err) var payload = notifier.SlackPayload{} err = json.Unmarshal(b, &payload) diff --git a/pkg/controller/scheduler_deployment_test.go b/pkg/controller/scheduler_deployment_test.go index cf1fd0ff1..3095821f3 100644 --- a/pkg/controller/scheduler_deployment_test.go +++ b/pkg/controller/scheduler_deployment_test.go @@ -20,7 +20,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -596,7 +596,7 @@ func TestScheduler_DeploymentTargetPortName(t *testing.T) { func TestScheduler_DeploymentAlerts(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) require.NoError(t, err) var payload = notifier.SlackPayload{} err = json.Unmarshal(b, &payload) diff --git a/pkg/controller/webhook.go b/pkg/controller/webhook.go index f8182f659..a9e1f9f9f 100644 --- a/pkg/controller/webhook.go +++ b/pkg/controller/webhook.go @@ -22,7 +22,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strconv" @@ -67,7 +67,7 @@ func callWebhook(webhook string, payload interface{}, timeout string) error { } defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return fmt.Errorf("error reading body: %s", err.Error()) } diff --git a/pkg/loadtester/concord.go b/pkg/loadtester/concord.go index b392e97a2..aa0c47ba4 100644 --- a/pkg/loadtester/concord.go +++ b/pkg/loadtester/concord.go @@ -23,7 +23,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "mime/multipart" "net/http" "net/url" @@ -189,7 +188,7 @@ func (task *ConcordTask) newRequest(method, path string, contentType string, bod } apiKey := "" - dat, err := ioutil.ReadFile(task.APIKeyPath) + dat, err := os.ReadFile(task.APIKeyPath) if err != nil { return req, err } diff --git a/pkg/loadtester/concord_test.go b/pkg/loadtester/concord_test.go index 9f2940a1a..5d95c5d10 100644 --- a/pkg/loadtester/concord_test.go +++ b/pkg/loadtester/concord_test.go @@ -19,7 +19,7 @@ package loadtester import ( "bytes" "fmt" - "io/ioutil" + "io" "mime/multipart" "testing" @@ -94,7 +94,7 @@ func assertNextPartHasKeyAndValue(t *testing.T, r *multipart.Reader, key string, } // assert.Equal(t, 1, part) - slurp, err := ioutil.ReadAll(part) + slurp, err := io.ReadAll(part) if err != nil { fmt.Printf("Part: %+v", part) t.Fatalf("Couldn't read part: %v", err) diff --git a/pkg/loadtester/server.go b/pkg/loadtester/server.go index e485018e2..b1bad4eea 100644 --- a/pkg/loadtester/server.go +++ b/pkg/loadtester/server.go @@ -20,7 +20,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "time" @@ -44,7 +44,7 @@ func ListenAndServe(port string, timeout time.Duration, logger *zap.SugaredLogge w.Write([]byte("Forbidden")) }) mux.HandleFunc("/gate/check", func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { logger.Error("reading the request body failed", zap.Error(err)) w.WriteHeader(http.StatusBadRequest) @@ -74,7 +74,7 @@ func ListenAndServe(port string, timeout time.Duration, logger *zap.SugaredLogge }) mux.HandleFunc("/gate/open", func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { logger.Error("reading the request body failed", zap.Error(err)) w.WriteHeader(http.StatusBadRequest) @@ -99,7 +99,7 @@ func ListenAndServe(port string, timeout time.Duration, logger *zap.SugaredLogge }) mux.HandleFunc("/gate/close", func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { logger.Error("reading the request body failed", zap.Error(err)) w.WriteHeader(http.StatusBadRequest) @@ -124,7 +124,7 @@ func ListenAndServe(port string, timeout time.Duration, logger *zap.SugaredLogge }) mux.HandleFunc("/rollback/check", func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { logger.Error("reading the request body failed", zap.Error(err)) w.WriteHeader(http.StatusBadRequest) @@ -153,7 +153,7 @@ func ListenAndServe(port string, timeout time.Duration, logger *zap.SugaredLogge logger.Infof("%s rollback check: approved %v", canaryName, approved) }) mux.HandleFunc("/rollback/open", func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { logger.Error("reading the request body failed", zap.Error(err)) w.WriteHeader(http.StatusBadRequest) @@ -177,7 +177,7 @@ func ListenAndServe(port string, timeout time.Duration, logger *zap.SugaredLogge logger.Infof("%s rollback opened", canaryName) }) mux.HandleFunc("/rollback/close", func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { logger.Error("reading the request body failed", zap.Error(err)) w.WriteHeader(http.StatusBadRequest) @@ -235,7 +235,7 @@ func HandleHealthz(w http.ResponseWriter, r *http.Request) { // HandleNewTask handles task creation requests func HandleNewTask(logger *zap.SugaredLogger, taskRunner TaskRunnerInterface) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { logger.Error("reading the request body failed", zap.Error(err)) w.WriteHeader(http.StatusBadRequest) diff --git a/pkg/loadtester/task_ngrinder.go b/pkg/loadtester/task_ngrinder.go index 0ee155b01..f5dde7c91 100644 --- a/pkg/loadtester/task_ngrinder.go +++ b/pkg/loadtester/task_ngrinder.go @@ -22,7 +22,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strconv" @@ -167,7 +167,7 @@ func (task *NGrinderTask) request(method, url string, ctx context.Context) (map[ } defer resp.Body.Close() - respBytes, err := ioutil.ReadAll(resp.Body) + respBytes, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("reading response body failed: %w", err) } diff --git a/pkg/metrics/providers/datadog.go b/pkg/metrics/providers/datadog.go index 759e660be..496f25689 100644 --- a/pkg/metrics/providers/datadog.go +++ b/pkg/metrics/providers/datadog.go @@ -20,7 +20,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "time" @@ -125,7 +125,7 @@ func (p *DatadogProvider) RunQuery(query string) (float64, error) { } defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return 0, fmt.Errorf("error reading body: %w", err) } @@ -176,7 +176,7 @@ func (p *DatadogProvider) IsOnline() (bool, error) { defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return false, fmt.Errorf("error reading body: %w", err) } diff --git a/pkg/metrics/providers/graphite.go b/pkg/metrics/providers/graphite.go index a89646811..b2fc54f10 100644 --- a/pkg/metrics/providers/graphite.go +++ b/pkg/metrics/providers/graphite.go @@ -21,7 +21,7 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io/ioutil" + "io" "math" "net/http" "net/url" @@ -183,7 +183,7 @@ func (g *GraphiteProvider) RunQuery(query string) (float64, error) { } defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return 0, fmt.Errorf("error reading body: %w", err) } diff --git a/pkg/metrics/providers/newrelic.go b/pkg/metrics/providers/newrelic.go index 5f90369ea..8ec9b5407 100644 --- a/pkg/metrics/providers/newrelic.go +++ b/pkg/metrics/providers/newrelic.go @@ -20,7 +20,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "time" @@ -105,7 +105,7 @@ func (p *NewRelicProvider) RunQuery(query string) (float64, error) { } defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return 0, fmt.Errorf("error reading body: %w", err) } @@ -147,7 +147,7 @@ func (p *NewRelicProvider) IsOnline() (bool, error) { defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return false, fmt.Errorf("error reading body: %w", err) } diff --git a/pkg/metrics/providers/prometheus.go b/pkg/metrics/providers/prometheus.go index 834baa456..e0660369f 100644 --- a/pkg/metrics/providers/prometheus.go +++ b/pkg/metrics/providers/prometheus.go @@ -21,7 +21,7 @@ import ( "crypto/tls" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -121,7 +121,7 @@ func (p *PrometheusProvider) RunQuery(query string) (float64, error) { } defer r.Body.Close() - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) if err != nil { return 0, fmt.Errorf("error reading body: %w", err) } diff --git a/pkg/notifier/client.go b/pkg/notifier/client.go index cdcbb64ae..5499534a9 100644 --- a/pkg/notifier/client.go +++ b/pkg/notifier/client.go @@ -21,7 +21,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net" "net/http" "net/url" @@ -75,7 +75,7 @@ func postMessage(address string, proxy string, payload interface{}) error { defer res.Body.Close() statusCode := res.StatusCode if statusCode != 200 { - body, _ := ioutil.ReadAll(res.Body) + body, _ := io.ReadAll(res.Body) return fmt.Errorf("sending notification failed: %s", string(body)) } diff --git a/pkg/notifier/client_test.go b/pkg/notifier/client_test.go index 086cf83b8..b3df87374 100644 --- a/pkg/notifier/client_test.go +++ b/pkg/notifier/client_test.go @@ -18,7 +18,7 @@ package notifier import ( "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -28,7 +28,7 @@ import ( func Test_postMessage(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) require.NoError(t, err) var payload = make(map[string]string) diff --git a/pkg/notifier/discord_test.go b/pkg/notifier/discord_test.go index 95dd7ac68..fcfc778dc 100644 --- a/pkg/notifier/discord_test.go +++ b/pkg/notifier/discord_test.go @@ -18,7 +18,7 @@ package notifier import ( "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "strings" @@ -35,7 +35,7 @@ func TestDiscord_Post(t *testing.T) { } ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) require.NoError(t, err) var payload = SlackPayload{} err = json.Unmarshal(b, &payload) diff --git a/pkg/notifier/rocket_test.go b/pkg/notifier/rocket_test.go index 84a7a0008..ca4ead895 100644 --- a/pkg/notifier/rocket_test.go +++ b/pkg/notifier/rocket_test.go @@ -18,7 +18,7 @@ package notifier import ( "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -33,7 +33,7 @@ func TestRocket_Post(t *testing.T) { } ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) require.NoError(t, err) var payload = SlackPayload{} diff --git a/pkg/notifier/slack_test.go b/pkg/notifier/slack_test.go index ac0d9698f..1d9c7022e 100644 --- a/pkg/notifier/slack_test.go +++ b/pkg/notifier/slack_test.go @@ -18,7 +18,7 @@ package notifier import ( "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -33,7 +33,7 @@ func TestSlack_Post(t *testing.T) { } ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) require.NoError(t, err) var payload = SlackPayload{} diff --git a/pkg/notifier/teams_test.go b/pkg/notifier/teams_test.go index ad439a238..47a9c41d5 100644 --- a/pkg/notifier/teams_test.go +++ b/pkg/notifier/teams_test.go @@ -18,7 +18,7 @@ package notifier import ( "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -34,7 +34,7 @@ func TestTeams_Post(t *testing.T) { } ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) require.NoError(t, err) var payload = MSTeamsPayload{} err = json.Unmarshal(b, &payload)