mirror of
https://github.com/moby/moby.git
synced 2025-07-30 18:23:29 +03:00
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated in Go 1.16. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@ -9,7 +9,6 @@ import (
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@ -63,7 +62,7 @@ func (s *DockerSwarmSuite) TestSwarmUpdate(c *testing.T) {
|
||||
"--external-ca", "protocol=cfssl,url=https://somethingelse.org,cacert=fixtures/https/ca.pem"),
|
||||
cli.Daemon(d)).Assert(c, icmd.Success)
|
||||
|
||||
expected, err := ioutil.ReadFile("fixtures/https/ca.pem")
|
||||
expected, err := os.ReadFile("fixtures/https/ca.pem")
|
||||
assert.NilError(c, err)
|
||||
|
||||
spec = getSpec()
|
||||
@ -109,7 +108,7 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *testing.T) {
|
||||
"--external-ca", "protocol=cfssl,url=https://somethingelse.org,cacert=fixtures/https/ca.pem"),
|
||||
cli.Daemon(d)).Assert(c, icmd.Success)
|
||||
|
||||
expected, err := ioutil.ReadFile("fixtures/https/ca.pem")
|
||||
expected, err := os.ReadFile("fixtures/https/ca.pem")
|
||||
assert.NilError(c, err)
|
||||
|
||||
spec := getSpec()
|
||||
@ -781,11 +780,11 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
||||
assert.NilError(c, err)
|
||||
|
||||
fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv)
|
||||
err = ioutil.WriteFile(fileName, []byte(url), 0644)
|
||||
err = os.WriteFile(fileName, []byte(url), 0644)
|
||||
assert.NilError(c, err)
|
||||
|
||||
ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv)
|
||||
err = ioutil.WriteFile(ipamFileName, []byte(url), 0644)
|
||||
err = os.WriteFile(ipamFileName, []byte(url), 0644)
|
||||
assert.NilError(c, err)
|
||||
}
|
||||
|
||||
@ -812,7 +811,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *testing.T) {
|
||||
d := s.AddDaemon(c, true, true)
|
||||
|
||||
path := filepath.Join(d.Folder, "env.txt")
|
||||
err := ioutil.WriteFile(path, []byte("VAR1=A\nVAR2=A\n"), 0644)
|
||||
err := os.WriteFile(path, []byte("VAR1=A\nVAR2=A\n"), 0644)
|
||||
assert.NilError(c, err)
|
||||
|
||||
name := "worker"
|
||||
@ -986,7 +985,7 @@ func getNodeStatus(c *testing.T, d *daemon.Daemon) swarm.LocalNodeState {
|
||||
|
||||
func checkKeyIsEncrypted(d *daemon.Daemon) func(*testing.T) (interface{}, string) {
|
||||
return func(c *testing.T) (interface{}, string) {
|
||||
keyBytes, err := ioutil.ReadFile(filepath.Join(d.Folder, "root", "swarm", "certificates", "swarm-node.key"))
|
||||
keyBytes, err := os.ReadFile(filepath.Join(d.Folder, "root", "swarm", "certificates", "swarm-node.key"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading key: %v", err), ""
|
||||
}
|
||||
@ -1216,7 +1215,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
|
||||
// is set to autolock)
|
||||
poll.WaitOn(c, pollCheck(c, d3.CheckControlAvailable, checker.False()), poll.WithTimeout(defaultReconciliationTimeout))
|
||||
poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
||||
certBytes, err := ioutil.ReadFile(filepath.Join(d3.Folder, "root", "swarm", "certificates", "swarm-node.crt"))
|
||||
certBytes, err := os.ReadFile(filepath.Join(d3.Folder, "root", "swarm", "certificates", "swarm-node.crt"))
|
||||
if err != nil {
|
||||
return "", fmt.Sprintf("error: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user