summaryrefslogtreecommitdiff
path: root/integration/plugin/authz
diff options
context:
space:
mode:
authorEng Zer Jun <engzerjun@gmail.com>2021-08-24 18:10:50 +0800
committerEng Zer Jun <engzerjun@gmail.com>2021-08-27 14:56:57 +0800
commitc55a4ac7795c7606b548b38e24673733481e2167 (patch)
tree8ea03bdc842959cd3d04a3e37a4ce2a71fa77dbb /integration/plugin/authz
parent2b70006e3bfa492b8641ff443493983d832955f4 (diff)
downloaddocker-c55a4ac7795c7606b548b38e24673733481e2167.tar.gz
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>
Diffstat (limited to 'integration/plugin/authz')
-rw-r--r--integration/plugin/authz/authz_plugin_test.go11
-rw-r--r--integration/plugin/authz/authz_plugin_v2_test.go4
-rw-r--r--integration/plugin/authz/main_test.go6
3 files changed, 10 insertions, 11 deletions
diff --git a/integration/plugin/authz/authz_plugin_test.go b/integration/plugin/authz/authz_plugin_test.go
index 6cce66cd6c..3c8cfc6a65 100644
--- a/integration/plugin/authz/authz_plugin_test.go
+++ b/integration/plugin/authz/authz_plugin_test.go
@@ -7,7 +7,6 @@ import (
"context"
"fmt"
"io"
- "io/ioutil"
"net"
"net/http"
"net/http/httputil"
@@ -61,7 +60,7 @@ func setupTestV1(t *testing.T) func() {
assert.NilError(t, err)
fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", testAuthZPlugin)
- err = ioutil.WriteFile(fileName, []byte(server.URL), 0644)
+ err = os.WriteFile(fileName, []byte(server.URL), 0644)
assert.NilError(t, err)
return func() {
@@ -336,7 +335,7 @@ func TestAuthZPluginEnsureLoadImportWorking(t *testing.T) {
c := d.NewClientT(t)
ctx := context.Background()
- tmp, err := ioutil.TempDir("", "test-authz-load-import")
+ tmp, err := os.MkdirTemp("", "test-authz-load-import")
assert.NilError(t, err)
defer os.RemoveAll(tmp)
@@ -370,11 +369,11 @@ func TestAuthzPluginEnsureContainerCopyToFrom(t *testing.T) {
ctrl.resRes.Allow = true
d.StartWithBusybox(t, "--authorization-plugin="+testAuthZPlugin, "--authorization-plugin="+testAuthZPlugin)
- dir, err := ioutil.TempDir("", t.Name())
+ dir, err := os.MkdirTemp("", t.Name())
assert.NilError(t, err)
defer os.RemoveAll(dir)
- f, err := ioutil.TempFile(dir, "send")
+ f, err := os.CreateTemp(dir, "send")
assert.NilError(t, err)
defer f.Close()
@@ -409,7 +408,7 @@ func TestAuthzPluginEnsureContainerCopyToFrom(t *testing.T) {
rdr, _, err := c.CopyFromContainer(ctx, cID, "/test")
assert.NilError(t, err)
- _, err = io.Copy(ioutil.Discard, rdr)
+ _, err = io.Copy(io.Discard, rdr)
assert.NilError(t, err)
}
diff --git a/integration/plugin/authz/authz_plugin_v2_test.go b/integration/plugin/authz/authz_plugin_v2_test.go
index f567f5a448..173d0a5df6 100644
--- a/integration/plugin/authz/authz_plugin_v2_test.go
+++ b/integration/plugin/authz/authz_plugin_v2_test.go
@@ -6,7 +6,7 @@ package authz // import "github.com/docker/docker/integration/plugin/authz"
import (
"context"
"fmt"
- "io/ioutil"
+ "io"
"os"
"strings"
"testing"
@@ -166,6 +166,6 @@ func pluginInstallGrantAllPermissions(client client.APIClient, name string) erro
// we have to read the response out here because the client API
// actually starts a goroutine which we can only be sure has
// completed when we get EOF from reading responseBody
- _, err = ioutil.ReadAll(responseReader)
+ _, err = io.ReadAll(responseReader)
return err
}
diff --git a/integration/plugin/authz/main_test.go b/integration/plugin/authz/main_test.go
index ff39d61372..b4e6564081 100644
--- a/integration/plugin/authz/main_test.go
+++ b/integration/plugin/authz/main_test.go
@@ -6,7 +6,7 @@ package authz // import "github.com/docker/docker/integration/plugin/authz"
import (
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"net/http/httptest"
"os"
@@ -77,7 +77,7 @@ func setupSuite() {
mux.HandleFunc("/AuthZPlugin.AuthZReq", func(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
- body, err := ioutil.ReadAll(r.Body)
+ body, err := io.ReadAll(r.Body)
if err != nil {
panic("could not read body for /AuthZPlugin.AuthZReq: " + err.Error())
}
@@ -115,7 +115,7 @@ func setupSuite() {
mux.HandleFunc("/AuthZPlugin.AuthZRes", func(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
- body, err := ioutil.ReadAll(r.Body)
+ body, err := io.ReadAll(r.Body)
if err != nil {
panic("could not read body for /AuthZPlugin.AuthZRes: " + err.Error())
}