mirror of https://github.com/ceph/go-ceph
rgw: remove refs to deprecated io/ioutil
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
parent
8638693136
commit
ce4031e218
|
@ -3,7 +3,7 @@ package admin
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
@ -98,12 +98,12 @@ func (api *API) call(ctx context.Context, httpMethod, path string, args url.Valu
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
// Decode HTTP response
|
// Decode HTTP response
|
||||||
decodedResponse, err := ioutil.ReadAll(resp.Body)
|
decodedResponse, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Body = ioutil.NopCloser(bytes.NewBuffer(decodedResponse))
|
resp.Body = io.NopCloser(bytes.NewBuffer(decodedResponse))
|
||||||
|
|
||||||
// Handle error in response
|
// Handle error in response
|
||||||
if resp.StatusCode >= 300 {
|
if resp.StatusCode >= 300 {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ func TestCreateSubuserMockAPI(t *testing.T) {
|
||||||
|
|
||||||
// mockClient is defined in user_test.go
|
// mockClient is defined in user_test.go
|
||||||
func returnMockClientCreateSubuser() *mockClient {
|
func returnMockClientCreateSubuser() *mockClient {
|
||||||
r := ioutil.NopCloser(bytes.NewReader([]byte("")))
|
r := io.NopCloser(bytes.NewReader([]byte("")))
|
||||||
return &mockClient{
|
return &mockClient{
|
||||||
mockDo: func(req *http.Request) (*http.Response, error) {
|
mockDo: func(req *http.Request) (*http.Response, error) {
|
||||||
if req.Method == http.MethodPut && req.URL.Path == "127.0.0.1/admin/user" {
|
if req.Method == http.MethodPut && req.URL.Path == "127.0.0.1/admin/user" {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -248,7 +248,7 @@ func TestGetUserMockAPI(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func returnMockClient() *mockClient {
|
func returnMockClient() *mockClient {
|
||||||
r := ioutil.NopCloser(bytes.NewReader(fakeUserResponse))
|
r := io.NopCloser(bytes.NewReader(fakeUserResponse))
|
||||||
return &mockClient{
|
return &mockClient{
|
||||||
mockDo: func(req *http.Request) (*http.Response, error) {
|
mockDo: func(req *http.Request) (*http.Response, error) {
|
||||||
if req.Method == http.MethodGet && req.URL.Path == "127.0.0.1/admin/user" {
|
if req.Method == http.MethodGet && req.URL.Path == "127.0.0.1/admin/user" {
|
||||||
|
|
Loading…
Reference in New Issue