This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 10977923 chore: replace io/ioutil package (#1485)
10977923 is described below

commit 109779232f607f13307de52f2f667f8d060ec25c
Author: Ashing Zheng <[email protected]>
AuthorDate: Mon Dec 5 09:42:31 2022 +0800

    chore: replace io/ioutil package (#1485)
    
    * chore: use io.ReadAll instead of ioutil.ReadAll
    
    * chore: use os.ReadFile intead of ioutil.ReadFile
    
    * chore: use os.CreateTemp instead of ioutil.TempFile
---
 cmd/ingress/ingress_test.go                               |  3 +--
 go.sum                                                    |  5 -----
 pkg/api/server_test.go                                    |  5 ++---
 pkg/apisix/cluster.go                                     |  5 ++---
 pkg/apisix/consumer_test.go                               |  6 +++---
 pkg/apisix/global_rule_test.go                            |  6 +++---
 pkg/apisix/pluginconfig_test.go                           |  6 +++---
 pkg/apisix/route_test.go                                  |  6 +++---
 pkg/apisix/ssl_test.go                                    |  6 +++---
 pkg/apisix/stream_route_test.go                           |  6 +++---
 pkg/apisix/upstream_test.go                               |  6 +++---
 pkg/config/config.go                                      |  3 +--
 pkg/config/config_test.go                                 | 15 +++++++--------
 test/e2e/scaffold/k8s.go                                  |  4 ++--
 test/e2e/scaffold/scaffold.go                             |  3 +--
 test/e2e/suite-features/scheme.go                         |  8 ++++----
 .../suite-ingress/suite-ingress-resource/upstream_tls.go  | 12 ++++++------
 test/e2e/testbackend/main.go                              |  3 +--
 18 files changed, 48 insertions(+), 60 deletions(-)

diff --git a/cmd/ingress/ingress_test.go b/cmd/ingress/ingress_test.go
index 7b5e5341..fb12781c 100644
--- a/cmd/ingress/ingress_test.go
+++ b/cmd/ingress/ingress_test.go
@@ -19,7 +19,6 @@ import (
        "bytes"
        "encoding/json"
        "fmt"
-       "io/ioutil"
        "math/rand"
        "os"
        "strings"
@@ -207,7 +206,7 @@ func TestRotateLog(t *testing.T) {
        assert.Nil(t, syscall.Kill(os.Getpid(), syscall.SIGINT))
        <-stopCh
 
-       files, err := ioutil.ReadDir("./testlog")
+       files, err := os.ReadDir("./testlog")
 
        if err != nil {
                t.Fatalf("Unable to read log dir: %v", err)
diff --git a/go.sum b/go.sum
index a951e2c8..2ae1e6b2 100644
--- a/go.sum
+++ b/go.sum
@@ -184,12 +184,9 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod 
h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod 
h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
 github.com/hashicorp/errwrap v1.0.0 
h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
 github.com/hashicorp/errwrap v1.0.0/go.mod 
h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
-github.com/hashicorp/go-immutable-radix v1.3.0 
h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE=
 github.com/hashicorp/go-immutable-radix v1.3.0/go.mod 
h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
 github.com/hashicorp/go-immutable-radix v1.3.1 
h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
 github.com/hashicorp/go-immutable-radix v1.3.1/go.mod 
h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
-github.com/hashicorp/go-memdb v1.3.3 
h1:oGfEWrFuxtIUF3W2q/Jzt6G85TrMk9ey6XfYLvVe1Wo=
-github.com/hashicorp/go-memdb v1.3.3/go.mod 
h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg=
 github.com/hashicorp/go-memdb v1.3.4 
h1:XSL3NR682X/cVk2IeV0d70N4DZ9ljI885xAEU8IoK3c=
 github.com/hashicorp/go-memdb v1.3.4/go.mod 
h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg=
 github.com/hashicorp/go-multierror v1.1.1 
h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
@@ -271,8 +268,6 @@ github.com/prometheus/client_golang v1.0.0/go.mod 
h1:db9x61etRT2tGnBNRi70OPL5Fsn
 github.com/prometheus/client_golang v1.7.1/go.mod 
h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
 github.com/prometheus/client_golang v1.11.0/go.mod 
h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
 github.com/prometheus/client_golang v1.12.1/go.mod 
h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
-github.com/prometheus/client_golang v1.13.0 
h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU=
-github.com/prometheus/client_golang v1.13.0/go.mod 
h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
 github.com/prometheus/client_golang v1.14.0 
h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw=
 github.com/prometheus/client_golang v1.14.0/go.mod 
h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y=
 github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod 
h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
diff --git a/pkg/api/server_test.go b/pkg/api/server_test.go
index 071f2699..243fe227 100644
--- a/pkg/api/server_test.go
+++ b/pkg/api/server_test.go
@@ -15,7 +15,6 @@
 package api
 
 import (
-       "io/ioutil"
        "net/http"
        "net/url"
        "os"
@@ -79,11 +78,11 @@ bKS1uxKukPFp6zxFwR7YZIiwo3tGkcudpHdTNurNMQiSTN97LTo8KL8y
 )
 
 func generateCertFiles() (certFileName string, keyFileName string) {
-       certFile, _ := ioutil.TempFile("", "cert.*.pem")
+       certFile, _ := os.CreateTemp("", "cert.*.pem")
        certFileName = certFile.Name()
        _, _ = certFile.Write([]byte(_tlsCert))
 
-       keyFile, _ := ioutil.TempFile("", "key.*.pem")
+       keyFile, _ := os.CreateTemp("", "key.*.pem")
        keyFileName = keyFile.Name()
        _, _ = keyFile.Write([]byte(_tlsKey))
        return
diff --git a/pkg/apisix/cluster.go b/pkg/apisix/cluster.go
index 4aefc124..8f19a2a8 100644
--- a/pkg/apisix/cluster.go
+++ b/pkg/apisix/cluster.go
@@ -22,7 +22,6 @@ import (
        "errors"
        "fmt"
        "io"
-       "io/ioutil"
        "net"
        "net/http"
        "net/url"
@@ -780,7 +779,7 @@ func (c *cluster) deleteResource(ctx context.Context, url, 
resource string) erro
 
 // drainBody reads whole data until EOF from r, then close it.
 func drainBody(r io.ReadCloser, url string) {
-       _, err := io.Copy(ioutil.Discard, r)
+       _, err := io.Copy(io.Discard, r)
        if err != nil {
                if err.Error() != _errReadOnClosedResBody.Error() {
                        log.Warnw("failed to drain body (read)",
@@ -804,7 +803,7 @@ func readBody(r io.ReadCloser, url string) string {
                        log.Warnw("failed to close body", zap.String("url", 
url), zap.Error(err))
                }
        }()
-       data, err := ioutil.ReadAll(r)
+       data, err := io.ReadAll(r)
        if err != nil {
                log.Warnw("failed to read body", zap.String("url", url), 
zap.Error(err))
                return ""
diff --git a/pkg/apisix/consumer_test.go b/pkg/apisix/consumer_test.go
index cb306537..4367e670 100644
--- a/pkg/apisix/consumer_test.go
+++ b/pkg/apisix/consumer_test.go
@@ -18,7 +18,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "io/ioutil"
+       "io"
        "net/http"
        "net/url"
        "sort"
@@ -83,7 +83,7 @@ func (srv *fakeAPISIXConsumerSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Reque
        if r.Method == http.MethodPut {
                paths := strings.Split(r.URL.Path, "/")
                key := fmt.Sprintf("/apisix/admin/consumers/%s", 
paths[len(paths)-1])
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.consumer[key] = data
                w.WriteHeader(http.StatusCreated)
                resp := fakeCreateResp{
@@ -106,7 +106,7 @@ func (srv *fakeAPISIXConsumerSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Reque
                        return
                }
 
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.consumer[id] = data
 
                w.WriteHeader(http.StatusOK)
diff --git a/pkg/apisix/global_rule_test.go b/pkg/apisix/global_rule_test.go
index ecd9c635..6647c1f4 100644
--- a/pkg/apisix/global_rule_test.go
+++ b/pkg/apisix/global_rule_test.go
@@ -18,7 +18,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "io/ioutil"
+       "io"
        "net/http"
        "net/url"
        "sort"
@@ -83,7 +83,7 @@ func (srv *fakeAPISIXGlobalRuleSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Req
        if r.Method == http.MethodPut {
                paths := strings.Split(r.URL.Path, "/")
                key := fmt.Sprintf("/apisix/admin/global_rules/%s", 
paths[len(paths)-1])
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.globalRule[key] = data
                w.WriteHeader(http.StatusCreated)
                resp := fakeCreateResp{
@@ -106,7 +106,7 @@ func (srv *fakeAPISIXGlobalRuleSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Req
                        return
                }
 
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.globalRule[id] = data
 
                w.WriteHeader(http.StatusOK)
diff --git a/pkg/apisix/pluginconfig_test.go b/pkg/apisix/pluginconfig_test.go
index ffc9c095..80c947e2 100644
--- a/pkg/apisix/pluginconfig_test.go
+++ b/pkg/apisix/pluginconfig_test.go
@@ -18,7 +18,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "io/ioutil"
+       "io"
        "net/http"
        "net/url"
        "sort"
@@ -83,7 +83,7 @@ func (srv *fakeAPISIXPluginConfigSrv) ServeHTTP(w 
http.ResponseWriter, r *http.R
        if r.Method == http.MethodPut {
                paths := strings.Split(r.URL.Path, "/")
                key := fmt.Sprintf("/apisix/plugin_configs/%s", 
paths[len(paths)-1])
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.pluginConfig[key] = data
                w.WriteHeader(http.StatusCreated)
                resp := fakeCreateResp{
@@ -106,7 +106,7 @@ func (srv *fakeAPISIXPluginConfigSrv) ServeHTTP(w 
http.ResponseWriter, r *http.R
                        return
                }
 
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.pluginConfig[id] = data
 
                w.WriteHeader(http.StatusOK)
diff --git a/pkg/apisix/route_test.go b/pkg/apisix/route_test.go
index 26482934..ec4a1db4 100644
--- a/pkg/apisix/route_test.go
+++ b/pkg/apisix/route_test.go
@@ -18,7 +18,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "io/ioutil"
+       "io"
        "net/http"
        "net/url"
        "sort"
@@ -103,7 +103,7 @@ func (srv *fakeAPISIXRouteSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Request)
        if r.Method == http.MethodPut {
                paths := strings.Split(r.URL.Path, "/")
                key := fmt.Sprintf("/apisix/routes/%s", paths[len(paths)-1])
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.route[key] = data
                w.WriteHeader(http.StatusCreated)
                resp := fakeCreateResp{
@@ -126,7 +126,7 @@ func (srv *fakeAPISIXRouteSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Request)
                        return
                }
 
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.route[id] = data
 
                w.WriteHeader(http.StatusOK)
diff --git a/pkg/apisix/ssl_test.go b/pkg/apisix/ssl_test.go
index ca62282f..6d47593c 100644
--- a/pkg/apisix/ssl_test.go
+++ b/pkg/apisix/ssl_test.go
@@ -19,7 +19,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "io/ioutil"
+       "io"
        "net/http"
        "net/url"
        "sort"
@@ -84,7 +84,7 @@ func (srv *fakeAPISIXSSLSrv) ServeHTTP(w http.ResponseWriter, 
r *http.Request) {
        if r.Method == http.MethodPut {
                paths := strings.Split(r.URL.Path, "/")
                key := fmt.Sprintf("/apisix/ssl/%s", paths[len(paths)-1])
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.ssl[key] = data
                w.WriteHeader(http.StatusCreated)
                resp := fakeCreateResp{
@@ -107,7 +107,7 @@ func (srv *fakeAPISIXSSLSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Request) {
                        return
                }
 
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.ssl[id] = data
 
                w.WriteHeader(http.StatusOK)
diff --git a/pkg/apisix/stream_route_test.go b/pkg/apisix/stream_route_test.go
index 7cc3a89c..d7bb8b24 100644
--- a/pkg/apisix/stream_route_test.go
+++ b/pkg/apisix/stream_route_test.go
@@ -18,7 +18,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "io/ioutil"
+       "io"
        "net/http"
        "net/url"
        "sort"
@@ -83,7 +83,7 @@ func (srv *fakeAPISIXStreamRouteSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Re
        if r.Method == http.MethodPut {
                paths := strings.Split(r.URL.Path, "/")
                key := fmt.Sprintf("/apisix/stream_routes/%s", 
paths[len(paths)-1])
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.streamRoute[key] = data
                w.WriteHeader(http.StatusCreated)
                resp := fakeCreateResp{
@@ -106,7 +106,7 @@ func (srv *fakeAPISIXStreamRouteSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Re
                        return
                }
 
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.streamRoute[id] = data
 
                w.WriteHeader(http.StatusOK)
diff --git a/pkg/apisix/upstream_test.go b/pkg/apisix/upstream_test.go
index d5667a04..d2a536ab 100644
--- a/pkg/apisix/upstream_test.go
+++ b/pkg/apisix/upstream_test.go
@@ -18,7 +18,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "io/ioutil"
+       "io"
        "net/http"
        "net/url"
        "sort"
@@ -83,7 +83,7 @@ func (srv *fakeAPISIXUpstreamSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Reque
        if r.Method == http.MethodPut {
                paths := strings.Split(r.URL.Path, "/")
                key := fmt.Sprintf("/apisix/upstreams/%s", paths[len(paths)-1])
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.upstream[key] = data
                w.WriteHeader(http.StatusCreated)
                resp := fakeCreateResp{
@@ -106,7 +106,7 @@ func (srv *fakeAPISIXUpstreamSrv) ServeHTTP(w 
http.ResponseWriter, r *http.Reque
                        return
                }
 
-               data, _ := ioutil.ReadAll(r.Body)
+               data, _ := io.ReadAll(r.Body)
                srv.upstream[id] = data
 
                w.WriteHeader(http.StatusOK)
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 88f65841..fd255c79 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -19,7 +19,6 @@ import (
        "encoding/json"
        "errors"
        "fmt"
-       "io/ioutil"
        "os"
        "strings"
        "text/template"
@@ -151,7 +150,7 @@ func NewDefaultConfig() *Config {
 // distinguished according to the file suffix.
 func NewConfigFromFile(filename string) (*Config, error) {
        cfg := NewDefaultConfig()
-       data, err := ioutil.ReadFile(filename)
+       data, err := os.ReadFile(filename)
        if err != nil {
                return nil, err
        }
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 594dcfce..b26c3575 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -16,7 +16,6 @@ package config
 
 import (
        "encoding/json"
-       "io/ioutil"
        "os"
        "testing"
        "time"
@@ -60,7 +59,7 @@ func TestNewConfigFromFile(t *testing.T) {
        jsonData, err := json.Marshal(cfg)
        assert.Nil(t, err, "failed to marshal config to json: %s", err)
 
-       tmpJSON, err := ioutil.TempFile("/tmp", "config-*.json")
+       tmpJSON, err := os.CreateTemp("/tmp", "config-*.json")
        assert.Nil(t, err, "failed to create temporary json configuration file: 
", err)
        defer os.Remove(tmpJSON.Name())
 
@@ -99,7 +98,7 @@ apisix:
   default_cluster_admin_key: "123456"
   default_cluster_name: "apisix"
 `
-       tmpYAML, err := ioutil.TempFile("/tmp", "config-*.yaml")
+       tmpYAML, err := os.CreateTemp("/tmp", "config-*.yaml")
        assert.Nil(t, err, "failed to create temporary yaml configuration file: 
", err)
        defer os.Remove(tmpYAML.Name())
 
@@ -180,7 +179,7 @@ func TestConfigWithEnvVar(t *testing.T) {
     }
 }
 `
-       tmpJSON, err := ioutil.TempFile("/tmp", "config-*.json")
+       tmpJSON, err := os.CreateTemp("/tmp", "config-*.json")
        assert.Nil(t, err, "failed to create temporary json configuration file: 
", err)
        defer os.Remove(tmpJSON.Name())
 
@@ -214,7 +213,7 @@ apisix:
   default_cluster_admin_key: "{{.DEFAULT_CLUSTER_ADMIN_KEY}}"
   default_cluster_name: "{{.DEFAULT_CLUSTER_NAME}}"
 `
-       tmpYAML, err := ioutil.TempFile("/tmp", "config-*.yaml")
+       tmpYAML, err := os.CreateTemp("/tmp", "config-*.yaml")
        assert.Nil(t, err, "failed to create temporary yaml configuration file: 
", err)
        defer os.Remove(tmpYAML.Name())
 
@@ -242,7 +241,7 @@ func TestConfigDefaultValue(t *testing.T) {
 apisix:
   default_cluster_base_url: http://127.0.0.1:8080/apisix
 `
-       tmpYAML, err := ioutil.TempFile("/tmp", "config-*.yaml")
+       tmpYAML, err := os.CreateTemp("/tmp", "config-*.yaml")
        assert.Nil(t, err, "failed to create temporary yaml configuration file: 
", err)
        defer os.Remove(tmpYAML.Name())
 
@@ -263,7 +262,7 @@ apisix:
 
 func TestConfigInvalidation(t *testing.T) {
        yamlData := ``
-       tmpYAML, err := ioutil.TempFile("/tmp", "config-*.yaml")
+       tmpYAML, err := os.CreateTemp("/tmp", "config-*.yaml")
        assert.Nil(t, err, "failed to create temporary yaml configuration file: 
", err)
        defer os.Remove(tmpYAML.Name())
 
@@ -283,7 +282,7 @@ kubernetes:
 apisix:
   default_cluster_base_url: http://127.0.0.1:1234/apisix
 `
-       tmpYAML, err = ioutil.TempFile("/tmp", "config-*.yaml")
+       tmpYAML, err = os.CreateTemp("/tmp", "config-*.yaml")
        assert.Nil(t, err, "failed to create temporary yaml configuration file: 
", err)
        defer os.Remove(tmpYAML.Name())
 
diff --git a/test/e2e/scaffold/k8s.go b/test/e2e/scaffold/k8s.go
index 6179195e..3f208b8c 100644
--- a/test/e2e/scaffold/k8s.go
+++ b/test/e2e/scaffold/k8s.go
@@ -19,7 +19,7 @@ import (
        "context"
        "encoding/json"
        "fmt"
-       "io/ioutil"
+       "io"
        "net/http"
        "net/url"
        "strconv"
@@ -207,7 +207,7 @@ func (s *Scaffold) ensureNumApisixCRDsCreated(url string, 
desired int) error {
                        return false, nil
                }
                var count int
-               b, err := ioutil.ReadAll(resp.Body)
+               b, err := io.ReadAll(resp.Body)
                if err != nil {
                        return false, err
                }
diff --git a/test/e2e/scaffold/scaffold.go b/test/e2e/scaffold/scaffold.go
index 1db6e8e2..f8be5f44 100644
--- a/test/e2e/scaffold/scaffold.go
+++ b/test/e2e/scaffold/scaffold.go
@@ -20,7 +20,6 @@ import (
        "crypto/tls"
        "crypto/x509"
        "fmt"
-       "io/ioutil"
        "net"
        "net/http"
        "net/url"
@@ -572,7 +571,7 @@ func (s *Scaffold) addFinalizers(f func()) {
 }
 
 func (s *Scaffold) renderConfig(path string) (string, error) {
-       data, err := ioutil.ReadFile(path)
+       data, err := os.ReadFile(path)
        if err != nil {
                return "", err
        }
diff --git a/test/e2e/suite-features/scheme.go 
b/test/e2e/suite-features/scheme.go
index 512575f7..e7a1b2d5 100644
--- a/test/e2e/suite-features/scheme.go
+++ b/test/e2e/suite-features/scheme.go
@@ -16,7 +16,7 @@
 package features
 
 import (
-       "io/ioutil"
+       "os"
        "time"
 
        ginkgo "github.com/onsi/ginkgo/v2"
@@ -118,11 +118,11 @@ spec:
 
                ginkgo.It("grpcs", func() {
                        grpcSecret := `grpc-secret`
-                       f, err := ioutil.ReadFile("testbackend/tls/server.pem")
+                       f, err := os.ReadFile("testbackend/tls/server.pem")
                        assert.NoError(ginkgo.GinkgoT(), err, "read server 
cert")
                        serverCert := string(f)
 
-                       f, err = ioutil.ReadFile("testbackend/tls/server.key")
+                       f, err = os.ReadFile("testbackend/tls/server.key")
                        assert.NoError(ginkgo.GinkgoT(), err, "read server key")
                        serverKey := string(f)
 
@@ -164,7 +164,7 @@ spec:
                        assert.Len(ginkgo.GinkgoT(), ups, 1)
                        assert.Equal(ginkgo.GinkgoT(), ups[0].Scheme, "grpcs")
 
-                       ca, err := ioutil.ReadFile("testbackend/tls/ca.pem")
+                       ca, err := os.ReadFile("testbackend/tls/ca.pem")
                        assert.NoError(ginkgo.GinkgoT(), err, "read ca cert")
                        assert.NoError(ginkgo.GinkgoT(), 
client.RequestHello(s.GetAPISIXHTTPSEndpoint(), ca), "request apisix using grpc 
protocol")
                })
diff --git a/test/e2e/suite-ingress/suite-ingress-resource/upstream_tls.go 
b/test/e2e/suite-ingress/suite-ingress-resource/upstream_tls.go
index 32a1ca89..1a739d06 100644
--- a/test/e2e/suite-ingress/suite-ingress-resource/upstream_tls.go
+++ b/test/e2e/suite-ingress/suite-ingress-resource/upstream_tls.go
@@ -16,8 +16,8 @@
 package ingress
 
 import (
-       "io/ioutil"
        "net/http"
+       "os"
 
        ginkgo "github.com/onsi/ginkgo/v2"
        "github.com/stretchr/testify/assert"
@@ -29,11 +29,11 @@ import (
 var _ = ginkgo.Describe("suite-ingress-resource: ApisixUpstreams mTLS test", 
func() {
        clientSecret := `client-secret`
 
-       f, err := ioutil.ReadFile("testbackend/tls/client.pem")
+       f, err := os.ReadFile("testbackend/tls/client.pem")
        assert.NoError(ginkgo.GinkgoT(), err, "read client cert")
        clientCert := string(f)
 
-       f, err = ioutil.ReadFile("testbackend/tls/client.key")
+       f, err = os.ReadFile("testbackend/tls/client.key")
        assert.NoError(ginkgo.GinkgoT(), err, "read client key")
        clientKey := string(f)
 
@@ -77,11 +77,11 @@ spec:
                ginkgo.It("create ApisixUpstreams with grpc mTLS", func() {
                        // create grpc secret for apisix grpc route
                        grpcSecret := `grpc-secret`
-                       f, err := ioutil.ReadFile("testbackend/tls/server.pem")
+                       f, err := os.ReadFile("testbackend/tls/server.pem")
                        assert.NoError(ginkgo.GinkgoT(), err, "read server 
cert")
                        serverCert := string(f)
 
-                       f, err = ioutil.ReadFile("testbackend/tls/server.key")
+                       f, err = os.ReadFile("testbackend/tls/server.key")
                        assert.NoError(ginkgo.GinkgoT(), err, "read server key")
                        serverKey := string(f)
 
@@ -117,7 +117,7 @@ spec:
 
                        assert.Nil(ginkgo.GinkgoT(), 
s.EnsureNumApisixRoutesCreated(1))
 
-                       ca, err := ioutil.ReadFile("testbackend/tls/ca.pem")
+                       ca, err := os.ReadFile("testbackend/tls/ca.pem")
                        assert.NoError(ginkgo.GinkgoT(), err, "read ca cert")
                        assert.NoError(ginkgo.GinkgoT(), 
client.RequestHello(s.GetAPISIXHTTPSEndpoint(), ca), "request apisix using grpc 
protocol")
                })
diff --git a/test/e2e/testbackend/main.go b/test/e2e/testbackend/main.go
index c265027a..5e2bccb7 100644
--- a/test/e2e/testbackend/main.go
+++ b/test/e2e/testbackend/main.go
@@ -19,7 +19,6 @@ import (
        "crypto/tls"
        "crypto/x509"
        "fmt"
-       "io/ioutil"
        "log"
        "net"
        "net/http"
@@ -58,7 +57,7 @@ func hello(w http.ResponseWriter, req *http.Request) {
 }
 
 func newDefaultCACertPool() *x509.CertPool {
-       caCert, err := ioutil.ReadFile("tls/ca.pem")
+       caCert, err := os.ReadFile("tls/ca.pem")
        if err != nil {
                log.Fatalf("failed to load ca cert: %v", err)
        }

Reply via email to