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:
Eng Zer Jun 2021-08-24 18:10:50 +08:00
parent 2b70006e3b
commit c55a4ac779
No known key found for this signature in database
GPG key ID: DAEBBD2E34C111E6
397 changed files with 1371 additions and 1606 deletions

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"path" "path"
"runtime" "runtime"
"sync" "sync"
@ -640,7 +639,7 @@ func (ld *layerDescriptor) Download(ctx context.Context, progressOutput pkgprogr
return nil, 0, err return nil, 0, err
} }
return ioutil.NopCloser(content.NewReader(ra)), ld.desc.Size, nil return io.NopCloser(content.NewReader(ra)), ld.desc.Size, nil
} }
func (ld *layerDescriptor) Close() { func (ld *layerDescriptor) Close() {

View file

@ -4,7 +4,6 @@
package buildkit package buildkit
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -35,7 +34,7 @@ func newExecutor(root, cgroupParent string, net libnetwork.NetworkController, dn
} }
// make sure net state directory is cleared from previous state // make sure net state directory is cleared from previous state
fis, err := ioutil.ReadDir(netRoot) fis, err := os.ReadDir(netRoot)
if err == nil { if err == nil {
for _, fi := range fis { for _, fi := range fis {
fp := filepath.Join(netRoot, fi.Name()) fp := filepath.Join(netRoot, fi.Name())

View file

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
nethttp "net/http" nethttp "net/http"
"runtime" "runtime"
"strings" "strings"
@ -445,7 +444,7 @@ func (ld *layerDescriptor) Download(ctx context.Context, progressOutput pkgprogr
return nil, 0, err return nil, 0, err
} }
return ioutil.NopCloser(content.NewReader(ra)), ld.desc.Size, nil return io.NopCloser(content.NewReader(ra)), ld.desc.Size, nil
} }
func (ld *layerDescriptor) Close() { func (ld *layerDescriptor) Close() {

View file

@ -5,7 +5,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"sort" "sort"
"strings" "strings"
@ -346,8 +345,8 @@ func BuildFromConfig(config *container.Config, changes []string, os string) (*co
} }
} }
b.Stdout = ioutil.Discard b.Stdout = io.Discard
b.Stderr = ioutil.Discard b.Stderr = io.Discard
b.disableCommit = true b.disableCommit = true
var commands []instructions.Command var commands []instructions.Command

View file

@ -1,7 +1,6 @@
package dockerfile // import "github.com/docker/docker/builder/dockerfile" package dockerfile // import "github.com/docker/docker/builder/dockerfile"
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -11,7 +10,7 @@ import (
// It returns the created path and a cleanup function which is meant to be used as deferred call. // It returns the created path and a cleanup function which is meant to be used as deferred call.
// When an error occurs, it terminates the test. // When an error occurs, it terminates the test.
func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) { func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) {
path, err := ioutil.TempDir(dir, prefix) path, err := os.MkdirTemp(dir, prefix)
if err != nil { if err != nil {
t.Fatalf("Error when creating directory %s with prefix %s: %s", dir, prefix, err) t.Fatalf("Error when creating directory %s with prefix %s: %s", dir, prefix, err)
@ -30,7 +29,7 @@ func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) {
// When an error occurs, it terminates the test // When an error occurs, it terminates the test
func createTestTempFile(t *testing.T, dir, filename, contents string, perm os.FileMode) string { func createTestTempFile(t *testing.T, dir, filename, contents string, perm os.FileMode) string {
filePath := filepath.Join(dir, filename) filePath := filepath.Join(dir, filename)
err := ioutil.WriteFile(filePath, []byte(contents), perm) err := os.WriteFile(filePath, []byte(contents), perm)
if err != nil { if err != nil {
t.Fatalf("Error when creating %s file: %s", filename, err) t.Fatalf("Error when creating %s file: %s", filename, err)

View file

@ -2,7 +2,6 @@ package remotecontext // import "github.com/docker/docker/builder/remotecontext"
import ( import (
"errors" "errors"
"io/ioutil"
"log" "log"
"os" "os"
"sort" "sort"
@ -20,7 +19,7 @@ const (
const shouldStayFilename = "should_stay" const shouldStayFilename = "should_stay"
func extractFilenames(files []os.FileInfo) []string { func extractFilenames(files []os.DirEntry) []string {
filenames := make([]string, len(files)) filenames := make([]string, len(files))
for i, file := range files { for i, file := range files {
@ -31,7 +30,7 @@ func extractFilenames(files []os.FileInfo) []string {
} }
func checkDirectory(t *testing.T, dir string, expectedFiles []string) { func checkDirectory(t *testing.T, dir string, expectedFiles []string) {
files, err := ioutil.ReadDir(dir) files, err := os.ReadDir(dir)
if err != nil { if err != nil {
t.Fatalf("Could not read directory: %s", err) t.Fatalf("Could not read directory: %s", err)

View file

@ -1,7 +1,6 @@
package git // import "github.com/docker/docker/builder/remotecontext/git" package git // import "github.com/docker/docker/builder/remotecontext/git"
import ( import (
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@ -34,7 +33,7 @@ func Clone(remoteURL string) (string, error) {
func cloneGitRepo(repo gitRepo) (checkoutDir string, err error) { func cloneGitRepo(repo gitRepo) (checkoutDir string, err error) {
fetch := fetchArgs(repo.remote, repo.ref) fetch := fetchArgs(repo.remote, repo.ref)
root, err := ioutil.TempDir("", "docker-build-git") root, err := os.MkdirTemp("", "docker-build-git")
if err != nil { if err != nil {
return "", err return "", err
} }

View file

@ -2,7 +2,6 @@ package git // import "github.com/docker/docker/builder/remotecontext/git"
import ( import (
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
@ -171,7 +170,7 @@ func gitGetConfig(name string) string {
} }
func TestCheckoutGit(t *testing.T) { func TestCheckoutGit(t *testing.T) {
root, err := ioutil.TempDir("", "docker-build-git-checkout") root, err := os.MkdirTemp("", "docker-build-git-checkout")
assert.NilError(t, err) assert.NilError(t, err)
defer os.RemoveAll(root) defer os.RemoveAll(root)
@ -195,13 +194,13 @@ func TestCheckoutGit(t *testing.T) {
_, err = gitWithinDir(gitDir, "config", "user.name", "Docker test") _, err = gitWithinDir(gitDir, "config", "user.name", "Docker test")
assert.NilError(t, err) assert.NilError(t, err)
err = ioutil.WriteFile(filepath.Join(gitDir, "Dockerfile"), []byte("FROM scratch"), 0644) err = os.WriteFile(filepath.Join(gitDir, "Dockerfile"), []byte("FROM scratch"), 0644)
assert.NilError(t, err) assert.NilError(t, err)
subDir := filepath.Join(gitDir, "subdir") subDir := filepath.Join(gitDir, "subdir")
assert.NilError(t, os.Mkdir(subDir, 0755)) assert.NilError(t, os.Mkdir(subDir, 0755))
err = ioutil.WriteFile(filepath.Join(subDir, "Dockerfile"), []byte("FROM scratch\nEXPOSE 5000"), 0644) err = os.WriteFile(filepath.Join(subDir, "Dockerfile"), []byte("FROM scratch\nEXPOSE 5000"), 0644)
assert.NilError(t, err) assert.NilError(t, err)
if runtime.GOOS != "windows" { if runtime.GOOS != "windows" {
@ -223,10 +222,10 @@ func TestCheckoutGit(t *testing.T) {
_, err = gitWithinDir(gitDir, "checkout", "-b", "test") _, err = gitWithinDir(gitDir, "checkout", "-b", "test")
assert.NilError(t, err) assert.NilError(t, err)
err = ioutil.WriteFile(filepath.Join(gitDir, "Dockerfile"), []byte("FROM scratch\nEXPOSE 3000"), 0644) err = os.WriteFile(filepath.Join(gitDir, "Dockerfile"), []byte("FROM scratch\nEXPOSE 3000"), 0644)
assert.NilError(t, err) assert.NilError(t, err)
err = ioutil.WriteFile(filepath.Join(subDir, "Dockerfile"), []byte("FROM busybox\nEXPOSE 5000"), 0644) err = os.WriteFile(filepath.Join(subDir, "Dockerfile"), []byte("FROM busybox\nEXPOSE 5000"), 0644)
assert.NilError(t, err) assert.NilError(t, err)
_, err = gitWithinDir(gitDir, "add", "-A") _, err = gitWithinDir(gitDir, "add", "-A")
@ -249,7 +248,7 @@ func TestCheckoutGit(t *testing.T) {
_, err = gitWithinDir(subrepoDir, "config", "user.name", "Docker test") _, err = gitWithinDir(subrepoDir, "config", "user.name", "Docker test")
assert.NilError(t, err) assert.NilError(t, err)
err = ioutil.WriteFile(filepath.Join(subrepoDir, "subfile"), []byte("subcontents"), 0644) err = os.WriteFile(filepath.Join(subrepoDir, "subfile"), []byte("subcontents"), 0644)
assert.NilError(t, err) assert.NilError(t, err)
_, err = gitWithinDir(subrepoDir, "add", "-A") _, err = gitWithinDir(subrepoDir, "add", "-A")
@ -310,7 +309,7 @@ func TestCheckoutGit(t *testing.T) {
assert.NilError(t, err) assert.NilError(t, err)
defer os.RemoveAll(r) defer os.RemoveAll(r)
if c.submodule { if c.submodule {
b, err := ioutil.ReadFile(filepath.Join(r, "sub/subfile")) b, err := os.ReadFile(filepath.Join(r, "sub/subfile"))
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Equal("subcontents", string(b))) assert.Check(t, is.Equal("subcontents", string(b)))
} else { } else {
@ -319,7 +318,7 @@ func TestCheckoutGit(t *testing.T) {
assert.Assert(t, os.IsNotExist(err)) assert.Assert(t, os.IsNotExist(err))
} }
b, err := ioutil.ReadFile(filepath.Join(r, "Dockerfile")) b, err := os.ReadFile(filepath.Join(r, "Dockerfile"))
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Equal(c.exp, string(b))) assert.Check(t, is.Equal(c.exp, string(b)))
} }

View file

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
@ -58,7 +57,7 @@ func GetWithStatusError(address string) (resp *http.Response, err error) {
return resp, nil return resp, nil
} }
msg := fmt.Sprintf("failed to GET %s with status %s", address, resp.Status) msg := fmt.Sprintf("failed to GET %s with status %s", address, resp.Status)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
resp.Body.Close() resp.Body.Close()
if err != nil { if err != nil {
return nil, errdefs.System(errors.New(msg + ": error reading body")) return nil, errdefs.System(errors.New(msg + ": error reading body"))

View file

@ -3,7 +3,6 @@ package remotecontext // import "github.com/docker/docker/builder/remotecontext"
import ( import (
"bytes" "bytes"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/url" "net/url"
@ -52,7 +51,7 @@ func TestSelectAcceptableMIME(t *testing.T) {
func TestInspectEmptyResponse(t *testing.T) { func TestInspectEmptyResponse(t *testing.T) {
ct := "application/octet-stream" ct := "application/octet-stream"
br := ioutil.NopCloser(bytes.NewReader([]byte(""))) br := io.NopCloser(bytes.NewReader([]byte("")))
contentType, bReader, err := inspectResponse(ct, br, 0) contentType, bReader, err := inspectResponse(ct, br, 0)
if err == nil { if err == nil {
t.Fatal("Should have generated an error for an empty response") t.Fatal("Should have generated an error for an empty response")
@ -60,7 +59,7 @@ func TestInspectEmptyResponse(t *testing.T) {
if contentType != "application/octet-stream" { if contentType != "application/octet-stream" {
t.Fatalf("Content type should be 'application/octet-stream' but is %q", contentType) t.Fatalf("Content type should be 'application/octet-stream' but is %q", contentType)
} }
body, err := ioutil.ReadAll(bReader) body, err := io.ReadAll(bReader)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -71,7 +70,7 @@ func TestInspectEmptyResponse(t *testing.T) {
func TestInspectResponseBinary(t *testing.T) { func TestInspectResponseBinary(t *testing.T) {
ct := "application/octet-stream" ct := "application/octet-stream"
br := ioutil.NopCloser(bytes.NewReader(binaryContext)) br := io.NopCloser(bytes.NewReader(binaryContext))
contentType, bReader, err := inspectResponse(ct, br, int64(len(binaryContext))) contentType, bReader, err := inspectResponse(ct, br, int64(len(binaryContext)))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -79,7 +78,7 @@ func TestInspectResponseBinary(t *testing.T) {
if contentType != "application/octet-stream" { if contentType != "application/octet-stream" {
t.Fatalf("Content type should be 'application/octet-stream' but is %q", contentType) t.Fatalf("Content type should be 'application/octet-stream' but is %q", contentType)
} }
body, err := ioutil.ReadAll(bReader) body, err := io.ReadAll(bReader)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -96,7 +95,7 @@ func TestInspectResponseBinary(t *testing.T) {
func TestResponseUnsupportedContentType(t *testing.T) { func TestResponseUnsupportedContentType(t *testing.T) {
content := []byte(dockerfileContents) content := []byte(dockerfileContents)
ct := "application/json" ct := "application/json"
br := ioutil.NopCloser(bytes.NewReader(content)) br := io.NopCloser(bytes.NewReader(content))
contentType, bReader, err := inspectResponse(ct, br, int64(len(dockerfileContents))) contentType, bReader, err := inspectResponse(ct, br, int64(len(dockerfileContents)))
if err == nil { if err == nil {
@ -105,7 +104,7 @@ func TestResponseUnsupportedContentType(t *testing.T) {
if contentType != ct { if contentType != ct {
t.Fatalf("Should not have altered content-type: orig: %s, altered: %s", ct, contentType) t.Fatalf("Should not have altered content-type: orig: %s, altered: %s", ct, contentType)
} }
body, err := ioutil.ReadAll(bReader) body, err := io.ReadAll(bReader)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -117,7 +116,7 @@ func TestResponseUnsupportedContentType(t *testing.T) {
func TestInspectResponseTextSimple(t *testing.T) { func TestInspectResponseTextSimple(t *testing.T) {
content := []byte(dockerfileContents) content := []byte(dockerfileContents)
ct := "text/plain" ct := "text/plain"
br := ioutil.NopCloser(bytes.NewReader(content)) br := io.NopCloser(bytes.NewReader(content))
contentType, bReader, err := inspectResponse(ct, br, int64(len(content))) contentType, bReader, err := inspectResponse(ct, br, int64(len(content)))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -125,7 +124,7 @@ func TestInspectResponseTextSimple(t *testing.T) {
if contentType != "text/plain" { if contentType != "text/plain" {
t.Fatalf("Content type should be 'text/plain' but is %q", contentType) t.Fatalf("Content type should be 'text/plain' but is %q", contentType)
} }
body, err := ioutil.ReadAll(bReader) body, err := io.ReadAll(bReader)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -136,7 +135,7 @@ func TestInspectResponseTextSimple(t *testing.T) {
func TestInspectResponseEmptyContentType(t *testing.T) { func TestInspectResponseEmptyContentType(t *testing.T) {
content := []byte(dockerfileContents) content := []byte(dockerfileContents)
br := ioutil.NopCloser(bytes.NewReader(content)) br := io.NopCloser(bytes.NewReader(content))
contentType, bodyReader, err := inspectResponse("", br, int64(len(content))) contentType, bodyReader, err := inspectResponse("", br, int64(len(content)))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -144,7 +143,7 @@ func TestInspectResponseEmptyContentType(t *testing.T) {
if contentType != "text/plain" { if contentType != "text/plain" {
t.Fatalf("Content type should be 'text/plain' but is %q", contentType) t.Fatalf("Content type should be 'text/plain' but is %q", contentType)
} }
body, err := ioutil.ReadAll(bodyReader) body, err := io.ReadAll(bodyReader)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -156,7 +155,7 @@ func TestInspectResponseEmptyContentType(t *testing.T) {
func TestUnknownContentLength(t *testing.T) { func TestUnknownContentLength(t *testing.T) {
content := []byte(dockerfileContents) content := []byte(dockerfileContents)
ct := "text/plain" ct := "text/plain"
br := ioutil.NopCloser(bytes.NewReader(content)) br := io.NopCloser(bytes.NewReader(content))
contentType, bReader, err := inspectResponse(ct, br, -1) contentType, bReader, err := inspectResponse(ct, br, -1)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -164,7 +163,7 @@ func TestUnknownContentLength(t *testing.T) {
if contentType != "text/plain" { if contentType != "text/plain" {
t.Fatalf("Content type should be 'text/plain' but is %q", contentType) t.Fatalf("Content type should be 'text/plain' but is %q", contentType)
} }
body, err := ioutil.ReadAll(bReader) body, err := io.ReadAll(bReader)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -191,7 +190,7 @@ func TestDownloadRemote(t *testing.T) {
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Equal(mimeTypes.TextPlain, contentType)) assert.Check(t, is.Equal(mimeTypes.TextPlain, contentType))
raw, err := ioutil.ReadAll(content) raw, err := io.ReadAll(content)
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Equal(dockerfileContents, string(raw))) assert.Check(t, is.Equal(dockerfileContents, string(raw)))
} }
@ -238,5 +237,5 @@ func TestGetWithStatusError(t *testing.T) {
func readBody(b io.ReadCloser) ([]byte, error) { func readBody(b io.ReadCloser) ([]byte, error) {
defer b.Close() defer b.Close()
return ioutil.ReadAll(b) return io.ReadAll(b)
} }

View file

@ -1,7 +1,6 @@
package remotecontext // import "github.com/docker/docker/builder/remotecontext" package remotecontext // import "github.com/docker/docker/builder/remotecontext"
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -23,7 +22,7 @@ func init() {
} }
func TestCloseRootDirectory(t *testing.T) { func TestCloseRootDirectory(t *testing.T) {
contextDir, err := ioutil.TempDir("", "builder-tarsum-test") contextDir, err := os.MkdirTemp("", "builder-tarsum-test")
defer os.RemoveAll(contextDir) defer os.RemoveAll(contextDir)
if err != nil { if err != nil {
t.Fatalf("Error with creating temporary directory: %s", err) t.Fatalf("Error with creating temporary directory: %s", err)

View file

@ -1,7 +1,6 @@
package remotecontext // import "github.com/docker/docker/builder/remotecontext" package remotecontext // import "github.com/docker/docker/builder/remotecontext"
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -11,7 +10,7 @@ import (
// It returns the created path and a cleanup function which is meant to be used as deferred call. // It returns the created path and a cleanup function which is meant to be used as deferred call.
// When an error occurs, it terminates the test. // When an error occurs, it terminates the test.
func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) { func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) {
path, err := ioutil.TempDir(dir, prefix) path, err := os.MkdirTemp(dir, prefix)
if err != nil { if err != nil {
t.Fatalf("Error when creating directory %s with prefix %s: %s", dir, prefix, err) t.Fatalf("Error when creating directory %s with prefix %s: %s", dir, prefix, err)
@ -32,7 +31,7 @@ func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) {
// whose parent directories are properly cleaned up. // whose parent directories are properly cleaned up.
// When an error occurs, it terminates the test. // When an error occurs, it terminates the test.
func createTestTempSubdir(t *testing.T, dir, prefix string) string { func createTestTempSubdir(t *testing.T, dir, prefix string) string {
path, err := ioutil.TempDir(dir, prefix) path, err := os.MkdirTemp(dir, prefix)
if err != nil { if err != nil {
t.Fatalf("Error when creating directory %s with prefix %s: %s", dir, prefix, err) t.Fatalf("Error when creating directory %s with prefix %s: %s", dir, prefix, err)
@ -45,7 +44,7 @@ func createTestTempSubdir(t *testing.T, dir, prefix string) string {
// When an error occurs, it terminates the test // When an error occurs, it terminates the test
func createTestTempFile(t *testing.T, dir, filename, contents string, perm os.FileMode) string { func createTestTempFile(t *testing.T, dir, filename, contents string, perm os.FileMode) string {
filePath := filepath.Join(dir, filename) filePath := filepath.Join(dir, filename)
err := ioutil.WriteFile(filePath, []byte(contents), perm) err := os.WriteFile(filePath, []byte(contents), perm)
if err != nil { if err != nil {
t.Fatalf("Error when creating %s file: %s", filename, err) t.Fatalf("Error when creating %s file: %s", filename, err)

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -58,7 +58,7 @@ func TestCheckpointCreate(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -40,7 +40,7 @@ func TestCheckpointDelete(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -43,7 +43,7 @@ func TestCheckpointList(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -3,7 +3,7 @@ package client // import "github.com/docker/docker/client"
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"net/http" "net/http"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
@ -37,7 +37,7 @@ func errorMock(statusCode int, message string) func(req *http.Request) (*http.Re
return &http.Response{ return &http.Response{
StatusCode: statusCode, StatusCode: statusCode,
Body: ioutil.NopCloser(bytes.NewReader(body)), Body: io.NopCloser(bytes.NewReader(body)),
Header: header, Header: header,
}, nil }, nil
} }
@ -47,7 +47,7 @@ func plainTextErrorMock(statusCode int, message string) func(req *http.Request)
return func(req *http.Request) (*http.Response, error) { return func(req *http.Request) (*http.Response, error) {
return &http.Response{ return &http.Response{
StatusCode: statusCode, StatusCode: statusCode,
Body: ioutil.NopCloser(bytes.NewReader([]byte(message))), Body: io.NopCloser(bytes.NewReader([]byte(message))),
}, nil }, nil
} }
} }

View file

@ -3,7 +3,7 @@ package client // import "github.com/docker/docker/client"
import ( import (
"bytes" "bytes"
"context" "context"
"io/ioutil" "io"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@ -274,7 +274,7 @@ func TestNegotiateAPIVersionAutomatic(t *testing.T) {
httpClient := newMockClient(func(req *http.Request) (*http.Response, error) { httpClient := newMockClient(func(req *http.Request) (*http.Response, error) {
resp := &http.Response{StatusCode: http.StatusOK, Header: http.Header{}} resp := &http.Response{StatusCode: http.StatusOK, Header: http.Header{}}
resp.Header.Set("API-Version", pingVersion) resp.Header.Set("API-Version", pingVersion)
resp.Body = ioutil.NopCloser(strings.NewReader("OK")) resp.Body = io.NopCloser(strings.NewReader("OK"))
return resp, nil return resp, nil
}) })

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -56,7 +56,7 @@ func TestConfigCreate(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusCreated, StatusCode: http.StatusCreated,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
) )
@ -23,7 +23,7 @@ func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.C
return swarm.Config{}, nil, wrapResponseError(err, resp, "config", id) return swarm.Config{}, nil, wrapResponseError(err, resp, "config", id)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return swarm.Config{}, nil, err return swarm.Config{}, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -89,7 +89,7 @@ func TestConfigInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -92,7 +92,7 @@ func TestConfigList(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -49,7 +49,7 @@ func TestConfigRemove(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -50,7 +50,7 @@ func TestConfigUpdate(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -76,7 +76,7 @@ func TestContainerCommit(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -6,7 +6,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -40,7 +40,7 @@ func TestContainerStatPathNoHeaderError(t *testing.T) {
client: newMockClient(func(req *http.Request) (*http.Response, error) { client: newMockClient(func(req *http.Request) (*http.Response, error) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }
@ -76,7 +76,7 @@ func TestContainerStatPath(t *testing.T) {
base64PathStat := base64.StdEncoding.EncodeToString(content) base64PathStat := base64.StdEncoding.EncodeToString(content)
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
Header: http.Header{ Header: http.Header{
"X-Docker-Container-Path-Stat": []string{base64PathStat}, "X-Docker-Container-Path-Stat": []string{base64PathStat},
}, },
@ -147,7 +147,7 @@ func TestCopyToContainer(t *testing.T) {
return nil, fmt.Errorf("noOverwriteDirNonDir not set in URL query properly, expected true, got %s", noOverwriteDirNonDir) return nil, fmt.Errorf("noOverwriteDirNonDir not set in URL query properly, expected true, got %s", noOverwriteDirNonDir)
} }
content, err := ioutil.ReadAll(req.Body) content, err := io.ReadAll(req.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -160,7 +160,7 @@ func TestCopyToContainer(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }
@ -208,7 +208,7 @@ func TestCopyFromContainerNoHeaderError(t *testing.T) {
client: newMockClient(func(req *http.Request) (*http.Response, error) { client: newMockClient(func(req *http.Request) (*http.Response, error) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }
@ -246,7 +246,7 @@ func TestCopyFromContainer(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("content"))), Body: io.NopCloser(bytes.NewReader([]byte("content"))),
Header: http.Header{ Header: http.Header{
"X-Docker-Container-Path-Stat": []string{base64PathStat}, "X-Docker-Container-Path-Stat": []string{base64PathStat},
}, },
@ -263,7 +263,7 @@ func TestCopyFromContainer(t *testing.T) {
if stat.Mode != 0700 { if stat.Mode != 0700 {
t.Fatalf("expected container path stat mode to be 0700, got '%v'", stat.Mode) t.Fatalf("expected container path stat mode to be 0700, got '%v'", stat.Mode)
} }
content, err := ioutil.ReadAll(r) content, err := io.ReadAll(r)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -62,7 +62,7 @@ func TestContainerCreateWithName(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }
@ -97,7 +97,7 @@ func TestContainerCreateAutoRemove(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
} }
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -46,7 +46,7 @@ func TestContainerDiff(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -53,7 +53,7 @@ func TestContainerExecCreate(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }
@ -99,7 +99,7 @@ func TestContainerExecStart(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }
@ -139,7 +139,7 @@ func TestContainerExecInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -32,7 +32,7 @@ func TestContainerExport(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("response"))), Body: io.NopCloser(bytes.NewReader([]byte("response"))),
}, nil }, nil
}), }),
} }
@ -41,7 +41,7 @@ func TestContainerExport(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
defer body.Close() defer body.Close()
content, err := ioutil.ReadAll(body) content, err := io.ReadAll(body)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
@ -41,7 +41,7 @@ func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID stri
return types.ContainerJSON{}, nil, wrapResponseError(err, serverResp, "container", containerID) return types.ContainerJSON{}, nil, wrapResponseError(err, serverResp, "container", containerID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return types.ContainerJSON{}, nil, err return types.ContainerJSON{}, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -68,7 +68,7 @@ func TestContainerInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }
@ -110,7 +110,7 @@ func TestContainerInspectNode(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -35,7 +35,7 @@ func TestContainerKill(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -73,7 +73,7 @@ func TestContainerList(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"net/http" "net/http"
"os" "os"
@ -135,7 +134,7 @@ func TestContainerLogs(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("response"))), Body: io.NopCloser(bytes.NewReader([]byte("response"))),
}, nil }, nil
}), }),
} }
@ -146,7 +145,7 @@ func TestContainerLogs(t *testing.T) {
} }
assert.NilError(t, err) assert.NilError(t, err)
defer body.Close() defer body.Close()
content, err := ioutil.ReadAll(body) content, err := io.ReadAll(body)
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Contains(string(content), "response")) assert.Check(t, is.Contains(string(content), "response"))
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -31,7 +31,7 @@ func TestContainerPause(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -114,7 +114,7 @@ func TestContainersPrune(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
version: "1.25", version: "1.25",

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -56,7 +56,7 @@ func TestContainerRemove(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -35,7 +35,7 @@ func TestContainerRename(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -77,7 +77,7 @@ func resizeTransport(expectedURL string) func(req *http.Request) (*http.Response
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
} }
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -37,7 +37,7 @@ func TestContainerRestart(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -46,7 +46,7 @@ func TestContainerStart(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -51,7 +51,7 @@ func TestContainerStats(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("response"))), Body: io.NopCloser(bytes.NewReader([]byte("response"))),
}, nil }, nil
}), }),
} }
@ -60,7 +60,7 @@ func TestContainerStats(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
defer resp.Body.Close() defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body) content, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -37,7 +37,7 @@ func TestContainerStop(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"reflect" "reflect"
"strings" "strings"
@ -57,7 +57,7 @@ func TestContainerTop(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -31,7 +31,7 @@ func TestContainerUnpause(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -40,7 +40,7 @@ func TestContainerUpdate(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"log" "log"
"net/http" "net/http"
"strings" "strings"
@ -46,7 +46,7 @@ func TestContainerWait(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -46,7 +46,7 @@ func TestDiskUsage(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -138,7 +137,7 @@ func TestEvents(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(buffer), Body: io.NopCloser(buffer),
}, nil }, nil
}), }),
} }

View file

@ -3,7 +3,7 @@ package client
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net" "net"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -92,7 +92,7 @@ func TestTLSCloseWriter(t *testing.T) {
_, err = resp.Conn.Write([]byte("hello")) _, err = resp.Conn.Write([]byte("hello"))
assert.NilError(t, err) assert.NilError(t, err)
b, err := ioutil.ReadAll(resp.Reader) b, err := io.ReadAll(resp.Reader)
assert.NilError(t, err) assert.NilError(t, err)
assert.Assert(t, string(b) == "hello") assert.Assert(t, string(b) == "hello")
assert.Assert(t, resp.CloseWrite()) assert.Assert(t, resp.CloseWrite())

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"reflect" "reflect"
"strings" "strings"
@ -195,7 +195,7 @@ func TestImageBuild(t *testing.T) {
headers.Add("Server", "Docker/v1.23 (MyOS)") headers.Add("Server", "Docker/v1.23 (MyOS)")
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
Header: headers, Header: headers,
}, nil }, nil
}), }),
@ -207,7 +207,7 @@ func TestImageBuild(t *testing.T) {
if buildResponse.OSType != "MyOS" { if buildResponse.OSType != "MyOS" {
t.Fatalf("expected OSType to be 'MyOS', got %s", buildResponse.OSType) t.Fatalf("expected OSType to be 'MyOS', got %s", buildResponse.OSType)
} }
response, err := ioutil.ReadAll(buildResponse.Body) response, err := io.ReadAll(buildResponse.Body)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -52,7 +52,7 @@ func TestImageCreate(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
}, nil }, nil
}), }),
} }
@ -63,7 +63,7 @@ func TestImageCreate(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
response, err := ioutil.ReadAll(createResponse) response, err := io.ReadAll(createResponse)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -47,7 +47,7 @@ func TestImageHistory(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"reflect" "reflect"
"strings" "strings"
@ -56,7 +56,7 @@ func TestImageImport(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("response"))), Body: io.NopCloser(bytes.NewReader([]byte("response"))),
}, nil }, nil
}), }),
} }
@ -71,7 +71,7 @@ func TestImageImport(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
response, err := ioutil.ReadAll(importResponse) response, err := io.ReadAll(importResponse)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
) )
@ -20,7 +20,7 @@ func (cli *Client) ImageInspectWithRaw(ctx context.Context, imageID string) (typ
return types.ImageInspect{}, nil, wrapResponseError(err, serverResp, "image", imageID) return types.ImageInspect{}, nil, wrapResponseError(err, serverResp, "image", imageID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return types.ImageInspect{}, nil, err return types.ImageInspect{}, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"reflect" "reflect"
"strings" "strings"
@ -67,7 +67,7 @@ func TestImageInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -96,7 +96,7 @@ func TestImageList(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }
@ -137,7 +137,7 @@ func TestImageListApiBefore125(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
version: "1.24", version: "1.24",

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -71,7 +71,7 @@ func TestImageLoad(t *testing.T) {
headers.Add("Content-Type", loadCase.responseContentType) headers.Add("Content-Type", loadCase.responseContentType)
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(expectedOutput))), Body: io.NopCloser(bytes.NewReader([]byte(expectedOutput))),
Header: headers, Header: headers,
}, nil }, nil
}), }),
@ -85,7 +85,7 @@ func TestImageLoad(t *testing.T) {
if imageLoadResponse.JSON != loadCase.expectedResponseJSON { if imageLoadResponse.JSON != loadCase.expectedResponseJSON {
t.Fatalf("expected a JSON response, was not.") t.Fatalf("expected a JSON response, was not.")
} }
body, err := ioutil.ReadAll(imageLoadResponse.Body) body, err := io.ReadAll(imageLoadResponse.Body)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -108,7 +108,7 @@ func TestImagesPrune(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
version: "1.25", version: "1.25",

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -87,7 +87,7 @@ func TestImagePullWithPrivilegedFuncNoError(t *testing.T) {
if auth == "NotValid" { if auth == "NotValid" {
return &http.Response{ return &http.Response{
StatusCode: http.StatusUnauthorized, StatusCode: http.StatusUnauthorized,
Body: ioutil.NopCloser(bytes.NewReader([]byte("Invalid credentials"))), Body: io.NopCloser(bytes.NewReader([]byte("Invalid credentials"))),
}, nil }, nil
} }
if auth != "IAmValid" { if auth != "IAmValid" {
@ -104,7 +104,7 @@ func TestImagePullWithPrivilegedFuncNoError(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("hello world"))), Body: io.NopCloser(bytes.NewReader([]byte("hello world"))),
}, nil }, nil
}), }),
} }
@ -118,7 +118,7 @@ func TestImagePullWithPrivilegedFuncNoError(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
body, err := ioutil.ReadAll(resp) body, err := io.ReadAll(resp)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -178,7 +178,7 @@ func TestImagePullWithoutErrors(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(expectedOutput))), Body: io.NopCloser(bytes.NewReader([]byte(expectedOutput))),
}, nil }, nil
}), }),
} }
@ -188,7 +188,7 @@ func TestImagePullWithoutErrors(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
body, err := ioutil.ReadAll(resp) body, err := io.ReadAll(resp)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -92,7 +92,7 @@ func TestImagePushWithPrivilegedFuncNoError(t *testing.T) {
if auth == "NotValid" { if auth == "NotValid" {
return &http.Response{ return &http.Response{
StatusCode: http.StatusUnauthorized, StatusCode: http.StatusUnauthorized,
Body: ioutil.NopCloser(bytes.NewReader([]byte("Invalid credentials"))), Body: io.NopCloser(bytes.NewReader([]byte("Invalid credentials"))),
}, nil }, nil
} }
if auth != "IAmValid" { if auth != "IAmValid" {
@ -105,7 +105,7 @@ func TestImagePushWithPrivilegedFuncNoError(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("hello world"))), Body: io.NopCloser(bytes.NewReader([]byte("hello world"))),
}, nil }, nil
}), }),
} }
@ -119,7 +119,7 @@ func TestImagePushWithPrivilegedFuncNoError(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
body, err := ioutil.ReadAll(resp) body, err := io.ReadAll(resp)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -178,7 +178,7 @@ func TestImagePushWithoutErrors(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(expectedOutput))), Body: io.NopCloser(bytes.NewReader([]byte(expectedOutput))),
}, nil }, nil
}), }),
} }
@ -188,7 +188,7 @@ func TestImagePushWithoutErrors(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
body, err := ioutil.ReadAll(resp) body, err := io.ReadAll(resp)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -90,7 +90,7 @@ func TestImageRemove(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"reflect" "reflect"
"strings" "strings"
@ -39,7 +39,7 @@ func TestImageSave(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("response"))), Body: io.NopCloser(bytes.NewReader([]byte("response"))),
}, nil }, nil
}), }),
} }
@ -47,7 +47,7 @@ func TestImageSave(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
response, err := ioutil.ReadAll(saveResponse) response, err := io.ReadAll(saveResponse)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -77,7 +77,7 @@ func TestImageSearchWithPrivilegedFuncNoError(t *testing.T) {
if auth == "NotValid" { if auth == "NotValid" {
return &http.Response{ return &http.Response{
StatusCode: http.StatusUnauthorized, StatusCode: http.StatusUnauthorized,
Body: ioutil.NopCloser(bytes.NewReader([]byte("Invalid credentials"))), Body: io.NopCloser(bytes.NewReader([]byte("Invalid credentials"))),
}, nil }, nil
} }
if auth != "IAmValid" { if auth != "IAmValid" {
@ -98,7 +98,7 @@ func TestImageSearchWithPrivilegedFuncNoError(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }
@ -149,7 +149,7 @@ func TestImageSearchWithoutErrors(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -132,7 +132,7 @@ func TestImageTag(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -29,7 +29,7 @@ func TestInfoInvalidResponseJSONError(t *testing.T) {
client: newMockClient(func(req *http.Request) (*http.Response, error) { client: newMockClient(func(req *http.Request) (*http.Response, error) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("invalid json"))), Body: io.NopCloser(bytes.NewReader([]byte("invalid json"))),
}, nil }, nil
}), }),
} }
@ -57,7 +57,7 @@ func TestInfo(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -54,7 +54,7 @@ func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }
@ -97,7 +97,7 @@ func TestNetworkConnect(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -47,7 +47,7 @@ func TestNetworkCreate(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -53,7 +53,7 @@ func TestNetworkDisconnect(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
@ -39,7 +39,7 @@ func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string,
return networkResource, nil, wrapResponseError(err, resp, "network", networkID) return networkResource, nil, wrapResponseError(err, resp, "network", networkID)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return networkResource, nil, err return networkResource, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -69,7 +69,7 @@ func TestNetworkInspect(t *testing.T) {
if strings.Contains(req.URL.RawQuery, "scope=global") { if strings.Contains(req.URL.RawQuery, "scope=global") {
return &http.Response{ return &http.Response{
StatusCode: http.StatusNotFound, StatusCode: http.StatusNotFound,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
} }
@ -91,7 +91,7 @@ func TestNetworkInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -93,7 +93,7 @@ func TestNetworkList(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -101,7 +101,7 @@ func TestNetworksPrune(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
version: "1.25", version: "1.25",

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -36,7 +36,7 @@ func TestNetworkRemove(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
) )
@ -20,7 +20,7 @@ func (cli *Client) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm
return swarm.Node{}, nil, wrapResponseError(err, serverResp, "node", nodeID) return swarm.Node{}, nil, wrapResponseError(err, serverResp, "node", nodeID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return swarm.Node{}, nil, err return swarm.Node{}, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -64,7 +64,7 @@ func TestNodeInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -79,7 +79,7 @@ func TestNodeList(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -56,7 +56,7 @@ func TestNodeRemove(t *testing.T) {
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -37,7 +37,7 @@ func TestNodeUpdate(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
}, nil }, nil
}), }),
} }

View file

@ -3,7 +3,7 @@ package client // import "github.com/docker/docker/client"
import ( import (
"context" "context"
"errors" "errors"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -26,7 +26,7 @@ func TestPingFail(t *testing.T) {
resp.Header.Set("API-Version", "awesome") resp.Header.Set("API-Version", "awesome")
resp.Header.Set("Docker-Experimental", "true") resp.Header.Set("Docker-Experimental", "true")
} }
resp.Body = ioutil.NopCloser(strings.NewReader("some error with the server")) resp.Body = io.NopCloser(strings.NewReader("some error with the server"))
return resp, nil return resp, nil
}), }),
} }
@ -52,7 +52,7 @@ func TestPingWithError(t *testing.T) {
resp.Header = http.Header{} resp.Header = http.Header{}
resp.Header.Set("API-Version", "awesome") resp.Header.Set("API-Version", "awesome")
resp.Header.Set("Docker-Experimental", "true") resp.Header.Set("Docker-Experimental", "true")
resp.Body = ioutil.NopCloser(strings.NewReader("some error with the server")) resp.Body = io.NopCloser(strings.NewReader("some error with the server"))
return resp, errors.New("some error") return resp, errors.New("some error")
}), }),
} }
@ -72,7 +72,7 @@ func TestPingSuccess(t *testing.T) {
resp.Header = http.Header{} resp.Header = http.Header{}
resp.Header.Set("API-Version", "awesome") resp.Header.Set("API-Version", "awesome")
resp.Header.Set("Docker-Experimental", "true") resp.Header.Set("Docker-Experimental", "true")
resp.Body = ioutil.NopCloser(strings.NewReader("OK")) resp.Body = io.NopCloser(strings.NewReader("OK"))
return resp, nil return resp, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -37,7 +37,7 @@ func TestPluginDisable(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -37,7 +37,7 @@ func TestPluginEnable(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
) )
@ -20,7 +20,7 @@ func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*type
return nil, nil, wrapResponseError(err, resp, "plugin", name) return nil, nil, wrapResponseError(err, resp, "plugin", name)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -53,7 +53,7 @@ func TestPluginInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -92,7 +92,7 @@ func TestPluginList(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -40,7 +40,7 @@ func TestPluginPush(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -37,7 +37,7 @@ func TestPluginRemove(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -36,7 +36,7 @@ func TestPluginSet(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
} }

View file

@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
@ -206,7 +205,7 @@ func (cli *Client) checkResponseErr(serverResp serverResponse) error {
R: serverResp.body, R: serverResp.body,
N: int64(bodyMax), N: int64(bodyMax),
} }
body, err = ioutil.ReadAll(bodyR) body, err = io.ReadAll(bodyR)
if err != nil { if err != nil {
return err return err
} }
@ -266,7 +265,7 @@ func encodeData(data interface{}) (*bytes.Buffer, error) {
func ensureReaderClosed(response serverResponse) { func ensureReaderClosed(response serverResponse) {
if response.body != nil { if response.body != nil {
// Drain up to 512 bytes and close the body to let the Transport reuse the connection // Drain up to 512 bytes and close the body to let the Transport reuse the connection
io.CopyN(ioutil.Discard, response.body, 512) io.CopyN(io.Discard, response.body, 512)
response.body.Close() response.body.Close()
} }
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"math/rand" "math/rand"
"net/http" "net/http"
"strings" "strings"
@ -66,7 +66,7 @@ func TestSetHostHeader(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), Body: io.NopCloser(bytes.NewReader([]byte(""))),
}, nil }, nil
}), }),
@ -99,7 +99,7 @@ func TestInfiniteError(t *testing.T) {
client: newMockClient(func(req *http.Request) (*http.Response, error) { client: newMockClient(func(req *http.Request) (*http.Response, error) {
resp := &http.Response{StatusCode: http.StatusInternalServerError} resp := &http.Response{StatusCode: http.StatusInternalServerError}
resp.Header = http.Header{} resp.Header = http.Header{}
resp.Body = ioutil.NopCloser(infinitR) resp.Body = io.NopCloser(infinitR)
return resp, nil return resp, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -56,7 +56,7 @@ func TestSecretCreate(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusCreated, StatusCode: http.StatusCreated,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
) )
@ -23,7 +23,7 @@ func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.S
return swarm.Secret{}, nil, wrapResponseError(err, resp, "secret", id) return swarm.Secret{}, nil, wrapResponseError(err, resp, "secret", id)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return swarm.Secret{}, nil, err return swarm.Secret{}, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -78,7 +78,7 @@ func TestSecretInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -92,7 +92,7 @@ func TestSecretList(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -49,7 +49,7 @@ func TestSecretRemove(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
}, nil }, nil
}), }),
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -50,7 +50,7 @@ func TestSecretUpdate(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("body"))), Body: io.NopCloser(bytes.NewReader([]byte("body"))),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -48,7 +48,7 @@ func TestServiceCreate(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
}), }),
} }
@ -87,7 +87,7 @@ func TestServiceCreateCompatiblePlatforms(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
} else if strings.HasPrefix(req.URL.Path, "/v1.30/distribution/") { } else if strings.HasPrefix(req.URL.Path, "/v1.30/distribution/") {
b, err := json.Marshal(registrytypes.DistributionInspect{ b, err := json.Marshal(registrytypes.DistributionInspect{
@ -106,7 +106,7 @@ func TestServiceCreateCompatiblePlatforms(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
} else { } else {
return nil, fmt.Errorf("unexpected URL '%s'", req.URL.Path) return nil, fmt.Errorf("unexpected URL '%s'", req.URL.Path)
@ -163,7 +163,7 @@ func TestServiceCreateDigestPinning(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
} else if strings.HasPrefix(req.URL.Path, "/v1.30/distribution/cannotresolve") { } else if strings.HasPrefix(req.URL.Path, "/v1.30/distribution/cannotresolve") {
// unresolvable image // unresolvable image
@ -180,7 +180,7 @@ func TestServiceCreateDigestPinning(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(b)), Body: io.NopCloser(bytes.NewReader(b)),
}, nil }, nil
} }
return nil, fmt.Errorf("unexpected URL '%s'", req.URL.Path) return nil, fmt.Errorf("unexpected URL '%s'", req.URL.Path)

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
@ -25,7 +25,7 @@ func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string,
return swarm.Service{}, nil, wrapResponseError(err, serverResp, "service", serviceID) return swarm.Service{}, nil, wrapResponseError(err, serverResp, "service", serviceID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return swarm.Service{}, nil, err return swarm.Service{}, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -65,7 +65,7 @@ func TestServiceInspect(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"strings" "strings"
"testing" "testing"
@ -79,7 +79,7 @@ func TestServiceList(t *testing.T) {
} }
return &http.Response{ return &http.Response{
StatusCode: http.StatusOK, StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(content)), Body: io.NopCloser(bytes.NewReader(content)),
}, nil }, nil
}), }),
} }

Some files were not shown because too many files have changed in this diff Show more