chore: Drop deprecated io/ioutil

Signed-off-by: shuheiktgw <shuheiktgw@users.noreply.github.com>
This commit is contained in:
shuheiktgw
2021-07-31 08:25:46 +09:00
parent df459c5fe6
commit 38d3ca1022
17 changed files with 41 additions and 42 deletions
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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())
}
+1 -2
View File
@@ -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
}
+2 -2
View File
@@ -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)
+8 -8
View File
@@ -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)
+2 -2
View File
@@ -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)
}
+3 -3
View File
@@ -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)
}
+2 -2
View File
@@ -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)
}
+3 -3
View File
@@ -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)
}
+2 -2
View File
@@ -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)
}
+2 -2
View File
@@ -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))
}
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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{}
+2 -2
View File
@@ -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{}
+2 -2
View File
@@ -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)