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

@@ -19,7 +19,7 @@ package aliyunidaas
import (
"encoding/json"
"errors"
"io/ioutil"
"io"
"net/http"
"github.com/mitchellh/mapstructure"
@@ -134,7 +134,7 @@ func (a *aliyunIDaaS) IdentityExchangeCallback(req *http.Request) (identityprovi
return nil, err
}
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

View File

@@ -20,7 +20,7 @@ import (
"context"
"crypto/tls"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"time"
@@ -190,7 +190,7 @@ func (g *github) IdentityExchangeCallback(req *http.Request) (identityprovider.I
return nil, err
}
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

View File

@@ -21,7 +21,7 @@ import (
"crypto/x509"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"time"
"github.com/go-ldap/ldap"
@@ -186,7 +186,7 @@ func (l *ldapProvider) newConn() (*ldap.Conn, error) {
var err error
// Load CA cert
if l.RootCA != "" {
if caCert, err = ioutil.ReadFile(l.RootCA); err != nil {
if caCert, err = os.ReadFile(l.RootCA); err != nil {
klog.Error(err)
return nil, err
}

View File

@@ -17,7 +17,6 @@ limitations under the License.
package ldap
import (
"io/ioutil"
"os"
"testing"
@@ -74,7 +73,7 @@ func TestLdapProvider_Authenticate(t *testing.T) {
if configFile == "" {
t.Skip("Skipped")
}
options, err := ioutil.ReadFile(configFile)
options, err := os.ReadFile(configFile)
if err != nil {
t.Fatal(err)
}

View File

@@ -23,7 +23,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
@@ -251,7 +251,7 @@ func (o *oidcProvider) IdentityExchangeCallback(req *http.Request) (identityprov
if err != nil {
return nil, fmt.Errorf("failed to fetch userinfo: %v", err)
}
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to fetch userinfo: %v", err)
}