refactor: move from io/ioutil to io and os packages (#5266)

The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

[1]: https://golang.org/doc/go1.16#ioutil
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2022-10-18 15:47:38 +08:00
committed by GitHub
parent 08b8069647
commit d1fec72a32
45 changed files with 113 additions and 127 deletions

View File

@@ -22,7 +22,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
@@ -423,10 +422,10 @@ func validateKubeSphereAPIServer(config *rest.Config) (*version.Info, error) {
}
defer response.Body.Close()
responseBytes, _ := ioutil.ReadAll(response.Body)
responseBytes, _ := io.ReadAll(response.Body)
responseBody := string(responseBytes)
response.Body = ioutil.NopCloser(bytes.NewBuffer(responseBytes))
response.Body = io.NopCloser(bytes.NewBuffer(responseBytes))
if response.StatusCode != http.StatusOK {
return nil, fmt.Errorf("invalid response: %s , please make sure %s.%s.svc of member cluster is up and running", KubeSphereApiServer, constants.KubeSphereNamespace, responseBody)