Kaynağa Gözat

integration-cli: remove uses of pkg/system.Stat()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 yıl önce
ebeveyn
işleme
0242fef89c

+ 5 - 4
integration-cli/docker_cli_cp_to_container_unix_test.go

@@ -10,9 +10,9 @@ import (
 	"path/filepath"
 	"path/filepath"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
+	"syscall"
 	"testing"
 	"testing"
 
 
-	"github.com/docker/docker/pkg/system"
 	"gotest.tools/v3/assert"
 	"gotest.tools/v3/assert"
 )
 )
 
 
@@ -59,12 +59,13 @@ func (s *DockerCLICpSuite) TestCpCheckDestOwnership(c *testing.T) {
 
 
 	assert.NilError(c, runDockerCp(c, srcPath, dstPath))
 	assert.NilError(c, runDockerCp(c, srcPath, dstPath))
 
 
-	stat, err := system.Stat(filepath.Join(tmpVolDir, "file1"))
+	stat, err := os.Stat(filepath.Join(tmpVolDir, "file1"))
 	assert.NilError(c, err)
 	assert.NilError(c, err)
 	uid, gid, err := getRootUIDGID()
 	uid, gid, err := getRootUIDGID()
 	assert.NilError(c, err)
 	assert.NilError(c, err)
-	assert.Equal(c, stat.UID(), uint32(uid), "Copied file not owned by container root UID")
-	assert.Equal(c, stat.GID(), uint32(gid), "Copied file not owned by container root GID")
+	fi := stat.Sys().(*syscall.Stat_t)
+	assert.Equal(c, fi.Uid, uint32(uid), "Copied file not owned by container root UID")
+	assert.Equal(c, fi.Gid, uint32(gid), "Copied file not owned by container root GID")
 }
 }
 
 
 func getRootUIDGID() (int, int, error) {
 func getRootUIDGID() (int, int, error) {

+ 9 - 7
integration-cli/docker_cli_userns_test.go

@@ -11,10 +11,10 @@ import (
 	"path/filepath"
 	"path/filepath"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
+	"syscall"
 	"testing"
 	"testing"
 
 
 	"github.com/docker/docker/pkg/stringid"
 	"github.com/docker/docker/pkg/stringid"
-	"github.com/docker/docker/pkg/system"
 	"gotest.tools/v3/assert"
 	"gotest.tools/v3/assert"
 )
 )
 
 
@@ -53,10 +53,11 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
 	assert.Equal(c, uidgid[0], user)
 	assert.Equal(c, uidgid[0], user)
 
 
 	// check that the created directory is owned by remapped uid:gid
 	// check that the created directory is owned by remapped uid:gid
-	statNotExists, err := system.Stat(tmpDirNotExists)
+	statNotExists, err := os.Stat(tmpDirNotExists)
 	assert.NilError(c, err)
 	assert.NilError(c, err)
-	assert.Equal(c, statNotExists.UID(), uint32(uid), "Created directory not owned by remapped root UID")
-	assert.Equal(c, statNotExists.GID(), uint32(gid), "Created directory not owned by remapped root GID")
+	fi := statNotExists.Sys().(*syscall.Stat_t)
+	assert.Equal(c, fi.Uid, uint32(uid), "Created directory not owned by remapped root UID")
+	assert.Equal(c, fi.Gid, uint32(gid), "Created directory not owned by remapped root GID")
 
 
 	pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns")
 	pid, err := s.d.Cmd("inspect", "--format={{.State.Pid}}", "userns")
 	assert.Assert(c, err == nil, "Could not inspect running container: out: %q", pid)
 	assert.Assert(c, err == nil, "Could not inspect running container: out: %q", pid)
@@ -73,10 +74,11 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
 	assert.NilError(c, err)
 	assert.NilError(c, err)
 
 
 	// check that the touched file is owned by remapped uid:gid
 	// check that the touched file is owned by remapped uid:gid
-	stat, err := system.Stat(filepath.Join(tmpDir, "testfile"))
+	stat, err := os.Stat(filepath.Join(tmpDir, "testfile"))
 	assert.NilError(c, err)
 	assert.NilError(c, err)
-	assert.Equal(c, stat.UID(), uint32(uid), "Touched file not owned by remapped root UID")
-	assert.Equal(c, stat.GID(), uint32(gid), "Touched file not owned by remapped root GID")
+	fi = stat.Sys().(*syscall.Stat_t)
+	assert.Equal(c, fi.Uid, uint32(uid), "Touched file not owned by remapped root UID")
+	assert.Equal(c, fi.Gid, uint32(gid), "Touched file not owned by remapped root GID")
 
 
 	// use host usernamespace
 	// use host usernamespace
 	out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; exec top")
 	out, err = s.d.Cmd("run", "-d", "--name", "userns_skip", "--userns", "host", "busybox", "sh", "-c", "touch /goofy/testfile; exec top")