integration-cli: format code with gofumpt
Formatting the code with https://github.com/mvdan/gofumpt Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
a31411c679
commit
225e2562c9
34 changed files with 228 additions and 203 deletions
|
@ -342,8 +342,7 @@ func TestDockerHubPullSuite(t *testing.T) {
|
||||||
suite.Run(t, newDockerHubPullSuite())
|
suite.Run(t, newDockerHubPullSuite())
|
||||||
}
|
}
|
||||||
|
|
||||||
type DockerSuite struct {
|
type DockerSuite struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (s *DockerSuite) OnTimeout(c *testing.T) {
|
func (s *DockerSuite) OnTimeout(c *testing.T) {
|
||||||
if testEnv.IsRemoteDaemon() {
|
if testEnv.IsRemoteDaemon() {
|
||||||
|
@ -598,6 +597,7 @@ func (ps *DockerPluginSuite) registryHost() string {
|
||||||
func (ps *DockerPluginSuite) getPluginRepo() string {
|
func (ps *DockerPluginSuite) getPluginRepo() string {
|
||||||
return path.Join(ps.registryHost(), "plugin", "basic")
|
return path.Join(ps.registryHost(), "plugin", "basic")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *DockerPluginSuite) getPluginRepoWithTag() string {
|
func (ps *DockerPluginSuite) getPluginRepoWithTag() string {
|
||||||
return ps.getPluginRepo() + ":" + "latest"
|
return ps.getPluginRepo() + ":" + "latest"
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,7 @@ func (s *DockerAPISuite) TestBuildAddRemoteNoDecompress(c *testing.T) {
|
||||||
err := tw.WriteHeader(&tar.Header{
|
err := tw.WriteHeader(&tar.Header{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Size: int64(len(dt)),
|
Size: int64(len(dt)),
|
||||||
Mode: 0600,
|
Mode: 0o600,
|
||||||
Typeflag: tar.TypeReg,
|
Typeflag: tar.TypeReg,
|
||||||
})
|
})
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
@ -430,7 +430,7 @@ COPY file /file`
|
||||||
fakecontext.WithDockerfile(dockerfile),
|
fakecontext.WithDockerfile(dockerfile),
|
||||||
fakecontext.WithFile("file", "bar"))
|
fakecontext.WithFile("file", "bar"))
|
||||||
|
|
||||||
var build = func(ctx *fakecontext.Fake) string {
|
build := func(ctx *fakecontext.Fake) string {
|
||||||
res, body, err := request.Post("/build",
|
res, body, err := request.Post("/build",
|
||||||
request.RawContent(ctx.AsTarReader(c)),
|
request.RawContent(ctx.AsTarReader(c)),
|
||||||
request.ContentType("application/x-tar"))
|
request.ContentType("application/x-tar"))
|
||||||
|
@ -470,7 +470,7 @@ ADD file /file`
|
||||||
fakecontext.WithDockerfile(dockerfile),
|
fakecontext.WithDockerfile(dockerfile),
|
||||||
fakecontext.WithFile("file", "bar"))
|
fakecontext.WithFile("file", "bar"))
|
||||||
|
|
||||||
var build = func(ctx *fakecontext.Fake) string {
|
build := func(ctx *fakecontext.Fake) string {
|
||||||
res, body, err := request.Post("/build",
|
res, body, err := request.Post("/build",
|
||||||
request.RawContent(ctx.AsTarReader(c)),
|
request.RawContent(ctx.AsTarReader(c)),
|
||||||
request.ContentType("application/x-tar"))
|
request.ContentType("application/x-tar"))
|
||||||
|
|
|
@ -146,9 +146,7 @@ func (s *DockerAPISuite) TestContainerAPIGetChanges(c *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerAPISuite) TestGetContainerStats(c *testing.T) {
|
func (s *DockerAPISuite) TestGetContainerStats(c *testing.T) {
|
||||||
var (
|
const name = "statscontainer"
|
||||||
name = "statscontainer"
|
|
||||||
)
|
|
||||||
runSleepingContainer(c, "--name", name)
|
runSleepingContainer(c, "--name", name)
|
||||||
|
|
||||||
type b struct {
|
type b struct {
|
||||||
|
@ -476,7 +474,8 @@ func (s *DockerAPISuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
|
||||||
defer apiClient.Close()
|
defer apiClient.Close()
|
||||||
|
|
||||||
config := container.Config{
|
config := container.Config{
|
||||||
Labels: map[string]string{"key1": "value1", "key2": "value2"}}
|
Labels: map[string]string{"key1": "value1", "key2": "value2"},
|
||||||
|
}
|
||||||
|
|
||||||
options := types.ContainerCommitOptions{
|
options := types.ContainerCommitOptions{
|
||||||
Reference: "testcontainerapicommitwithconfig",
|
Reference: "testcontainerapicommitwithconfig",
|
||||||
|
@ -513,7 +512,8 @@ func (s *DockerAPISuite) TestContainerAPIBadPort(c *testing.T) {
|
||||||
"8080/tcp": []nat.PortBinding{
|
"8080/tcp": []nat.PortBinding{
|
||||||
{
|
{
|
||||||
HostIP: "",
|
HostIP: "",
|
||||||
HostPort: "aa80"},
|
HostPort: "aa80",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1662,8 +1662,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "notreal",
|
Type: "notreal",
|
||||||
Target: destPath,
|
Target: destPath,
|
||||||
},
|
}},
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
msg: "mount type unknown",
|
msg: "mount type unknown",
|
||||||
|
@ -1674,7 +1673,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
},
|
},
|
||||||
hostConfig: container.HostConfig{
|
hostConfig: container.HostConfig{
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "bind"}}},
|
Type: "bind",
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "Target must not be empty",
|
msg: "Target must not be empty",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1684,7 +1685,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
hostConfig: container.HostConfig{
|
hostConfig: container.HostConfig{
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Target: destPath}}},
|
Target: destPath,
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "Source must not be empty",
|
msg: "Source must not be empty",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1695,7 +1698,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: notExistPath,
|
Source: notExistPath,
|
||||||
Target: destPath}}},
|
Target: destPath,
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "source path does not exist",
|
msg: "source path does not exist",
|
||||||
// FIXME(vdemeester) fails into e2e, migrate to integration/container anyway
|
// FIXME(vdemeester) fails into e2e, migrate to integration/container anyway
|
||||||
// msg: "source path does not exist: " + notExistPath,
|
// msg: "source path does not exist: " + notExistPath,
|
||||||
|
@ -1706,7 +1711,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
},
|
},
|
||||||
hostConfig: container.HostConfig{
|
hostConfig: container.HostConfig{
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "volume"}}},
|
Type: "volume",
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "Target must not be empty",
|
msg: "Target must not be empty",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1717,7 +1724,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "volume",
|
Type: "volume",
|
||||||
Source: "hello",
|
Source: "hello",
|
||||||
Target: destPath}}},
|
Target: destPath,
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "",
|
msg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1731,7 +1740,11 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
Target: destPath,
|
Target: destPath,
|
||||||
VolumeOptions: &mount.VolumeOptions{
|
VolumeOptions: &mount.VolumeOptions{
|
||||||
DriverConfig: &mount.Driver{
|
DriverConfig: &mount.Driver{
|
||||||
Name: "local"}}}}},
|
Name: "local",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "",
|
msg: "",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1749,7 +1762,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: tmpDir,
|
Source: tmpDir,
|
||||||
Target: destPath}}},
|
Target: destPath,
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "",
|
msg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1761,7 +1776,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: tmpDir,
|
Source: tmpDir,
|
||||||
Target: destPath,
|
Target: destPath,
|
||||||
VolumeOptions: &mount.VolumeOptions{}}}},
|
VolumeOptions: &mount.VolumeOptions{},
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "VolumeOptions must not be specified",
|
msg: "VolumeOptions must not be specified",
|
||||||
},
|
},
|
||||||
}...)
|
}...)
|
||||||
|
@ -1886,7 +1903,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
hostConfig: container.HostConfig{
|
hostConfig: container.HostConfig{
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "tmpfs",
|
Type: "tmpfs",
|
||||||
Target: destPath}}},
|
Target: destPath,
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "",
|
msg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1899,8 +1918,10 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
Target: destPath,
|
Target: destPath,
|
||||||
TmpfsOptions: &mount.TmpfsOptions{
|
TmpfsOptions: &mount.TmpfsOptions{
|
||||||
SizeBytes: 4096 * 1024,
|
SizeBytes: 4096 * 1024,
|
||||||
Mode: 0700,
|
Mode: 0o700,
|
||||||
}}}},
|
},
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "",
|
msg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1911,7 +1932,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
|
||||||
Mounts: []mount.Mount{{
|
Mounts: []mount.Mount{{
|
||||||
Type: "tmpfs",
|
Type: "tmpfs",
|
||||||
Source: "/shouldnotbespecified",
|
Source: "/shouldnotbespecified",
|
||||||
Target: destPath}}},
|
Target: destPath,
|
||||||
|
}},
|
||||||
|
},
|
||||||
msg: "Source must not be specified",
|
msg: "Source must not be specified",
|
||||||
},
|
},
|
||||||
}...)
|
}...)
|
||||||
|
@ -1942,7 +1965,7 @@ func (s *DockerAPISuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
|
||||||
tmpDir, err := os.MkdirTemp("", "test-mounts-api-bind")
|
tmpDir, err := os.MkdirTemp("", "test-mounts-api-bind")
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0666)
|
err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0o666)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
config := container.Config{
|
config := container.Config{
|
||||||
Image: "busybox",
|
Image: "busybox",
|
||||||
|
@ -1969,9 +1992,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
||||||
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
|
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
|
||||||
destPath := prefix + slash + "foo"
|
destPath := prefix + slash + "foo"
|
||||||
|
|
||||||
var (
|
var testImg string
|
||||||
testImg string
|
|
||||||
)
|
|
||||||
if testEnv.DaemonInfo.OSType != "windows" {
|
if testEnv.DaemonInfo.OSType != "windows" {
|
||||||
testImg = "test-mount-config"
|
testImg = "test-mount-config"
|
||||||
buildImageSuccessfully(c, testImg, build.WithDockerfile(`
|
buildImageSuccessfully(c, testImg, build.WithDockerfile(`
|
||||||
|
@ -2184,7 +2205,8 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
|
||||||
{
|
{
|
||||||
cfg: mount.Mount{
|
cfg: mount.Mount{
|
||||||
Type: "tmpfs",
|
Type: "tmpfs",
|
||||||
Target: target},
|
Target: target,
|
||||||
|
},
|
||||||
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"},
|
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2192,7 +2214,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
|
||||||
Type: "tmpfs",
|
Type: "tmpfs",
|
||||||
Target: target,
|
Target: target,
|
||||||
TmpfsOptions: &mount.TmpfsOptions{
|
TmpfsOptions: &mount.TmpfsOptions{
|
||||||
SizeBytes: 4096 * 1024, Mode: 0700}},
|
SizeBytes: 4096 * 1024, Mode: 0o700,
|
||||||
|
},
|
||||||
|
},
|
||||||
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k", "mode=700"},
|
expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k", "mode=700"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,10 @@ func (s *DockerAPISuite) TestInspectAPIContainerResponse(c *testing.T) {
|
||||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
|
||||||
|
|
||||||
cleanedContainerID := strings.TrimSpace(out)
|
cleanedContainerID := strings.TrimSpace(out)
|
||||||
keysBase := []string{"Id", "State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings",
|
keysBase := []string{
|
||||||
"ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "MountLabel", "ProcessLabel", "GraphDriver"}
|
"Id", "State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings",
|
||||||
|
"ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "MountLabel", "ProcessLabel", "GraphDriver",
|
||||||
|
}
|
||||||
|
|
||||||
type acase struct {
|
type acase struct {
|
||||||
version string
|
version string
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (s *DockerAPISuite) TestAPIStatsNoStreamGetCpu(c *testing.T) {
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
body.Close()
|
body.Close()
|
||||||
|
|
||||||
var cpuPercent = 0.0
|
cpuPercent := 0.0
|
||||||
|
|
||||||
if testEnv.DaemonInfo.OSType != "windows" {
|
if testEnv.DaemonInfo.OSType != "windows" {
|
||||||
cpuDelta := float64(v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage)
|
cpuDelta := float64(v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage)
|
||||||
|
|
|
@ -732,9 +732,7 @@ func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerC
|
||||||
var totalMCount, totalWCount int
|
var totalMCount, totalWCount int
|
||||||
|
|
||||||
for _, d := range cl {
|
for _, d := range cl {
|
||||||
var (
|
var info swarm.Info
|
||||||
info swarm.Info
|
|
||||||
)
|
|
||||||
|
|
||||||
// check info in a poll.WaitOn(), because if the cluster doesn't have a leader, `info` will return an error
|
// check info in a poll.WaitOn(), because if the cluster doesn't have a leader, `info` will return an error
|
||||||
checkInfo := func(c *testing.T) (interface{}, string) {
|
checkInfo := func(c *testing.T) (interface{}, string) {
|
||||||
|
|
|
@ -933,9 +933,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddBadLinks(c *testing.T) {
|
||||||
ADD foo.txt /symlink/
|
ADD foo.txt /symlink/
|
||||||
`
|
`
|
||||||
targetFile := "foo.txt"
|
targetFile := "foo.txt"
|
||||||
var (
|
name := "test-link-absolute"
|
||||||
name = "test-link-absolute"
|
|
||||||
)
|
|
||||||
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(dockerfile))
|
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(dockerfile))
|
||||||
defer ctx.Close()
|
defer ctx.Close()
|
||||||
|
|
||||||
|
@ -974,7 +972,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddBadLinks(c *testing.T) {
|
||||||
Name: "symlink",
|
Name: "symlink",
|
||||||
Typeflag: tar.TypeSymlink,
|
Typeflag: tar.TypeSymlink,
|
||||||
Linkname: symlinkTarget,
|
Linkname: symlinkTarget,
|
||||||
Mode: 0755,
|
Mode: 0o755,
|
||||||
Uid: 0,
|
Uid: 0,
|
||||||
Gid: 0,
|
Gid: 0,
|
||||||
}
|
}
|
||||||
|
@ -1061,7 +1059,7 @@ func (s *DockerCLIBuildSuite) TestBuildWithInaccessibleFilesInContext(c *testing
|
||||||
if err := os.Chown(pathToFileWithoutReadAccess, 0, 0); err != nil {
|
if err := os.Chown(pathToFileWithoutReadAccess, 0, 0); err != nil {
|
||||||
c.Fatalf("failed to chown file to root: %s", err)
|
c.Fatalf("failed to chown file to root: %s", err)
|
||||||
}
|
}
|
||||||
if err := os.Chmod(pathToFileWithoutReadAccess, 0700); err != nil {
|
if err := os.Chmod(pathToFileWithoutReadAccess, 0o700); err != nil {
|
||||||
c.Fatalf("failed to chmod file to 700: %s", err)
|
c.Fatalf("failed to chmod file to 700: %s", err)
|
||||||
}
|
}
|
||||||
result := icmd.RunCmd(icmd.Cmd{
|
result := icmd.RunCmd(icmd.Cmd{
|
||||||
|
@ -1095,10 +1093,10 @@ func (s *DockerCLIBuildSuite) TestBuildWithInaccessibleFilesInContext(c *testing
|
||||||
if err := os.Chown(pathToDirectoryWithoutReadAccess, 0, 0); err != nil {
|
if err := os.Chown(pathToDirectoryWithoutReadAccess, 0, 0); err != nil {
|
||||||
c.Fatalf("failed to chown directory to root: %s", err)
|
c.Fatalf("failed to chown directory to root: %s", err)
|
||||||
}
|
}
|
||||||
if err := os.Chmod(pathToDirectoryWithoutReadAccess, 0444); err != nil {
|
if err := os.Chmod(pathToDirectoryWithoutReadAccess, 0o444); err != nil {
|
||||||
c.Fatalf("failed to chmod directory to 444: %s", err)
|
c.Fatalf("failed to chmod directory to 444: %s", err)
|
||||||
}
|
}
|
||||||
if err := os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0700); err != nil {
|
if err := os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0o700); err != nil {
|
||||||
c.Fatalf("failed to chmod file to 700: %s", err)
|
c.Fatalf("failed to chmod file to 700: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1149,17 +1147,19 @@ func (s *DockerCLIBuildSuite) TestBuildWithInaccessibleFilesInContext(c *testing
|
||||||
if err := os.Chown(pathToDirectoryWithoutReadAccess, 0, 0); err != nil {
|
if err := os.Chown(pathToDirectoryWithoutReadAccess, 0, 0); err != nil {
|
||||||
c.Fatalf("failed to chown directory to root: %s", err)
|
c.Fatalf("failed to chown directory to root: %s", err)
|
||||||
}
|
}
|
||||||
if err := os.Chmod(pathToDirectoryWithoutReadAccess, 0444); err != nil {
|
if err := os.Chmod(pathToDirectoryWithoutReadAccess, 0o444); err != nil {
|
||||||
c.Fatalf("failed to chmod directory to 444: %s", err)
|
c.Fatalf("failed to chmod directory to 444: %s", err)
|
||||||
}
|
}
|
||||||
if err := os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0700); err != nil {
|
if err := os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0o700); err != nil {
|
||||||
c.Fatalf("failed to chmod file to 700: %s", err)
|
c.Fatalf("failed to chmod file to 700: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
result := icmd.RunCmd(icmd.Cmd{
|
result := icmd.RunCmd(icmd.Cmd{
|
||||||
Dir: ctx.Dir,
|
Dir: ctx.Dir,
|
||||||
Command: []string{"su", "unprivilegeduser", "-c",
|
Command: []string{
|
||||||
fmt.Sprintf("%s build -t %s .", dockerBinary, name)},
|
"su", "unprivilegeduser", "-c",
|
||||||
|
fmt.Sprintf("%s build -t %s .", dockerBinary, name),
|
||||||
|
},
|
||||||
})
|
})
|
||||||
result.Assert(c, icmd.Expected{})
|
result.Assert(c, icmd.Expected{})
|
||||||
}
|
}
|
||||||
|
@ -2061,7 +2061,7 @@ func (s *DockerCLIBuildSuite) TestBuildDockerfileStdin(c *testing.T) {
|
||||||
name := "stdindockerfile"
|
name := "stdindockerfile"
|
||||||
tmpDir, err := os.MkdirTemp("", "fake-context")
|
tmpDir, err := os.MkdirTemp("", "fake-context")
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
err = os.WriteFile(filepath.Join(tmpDir, "foo"), []byte("bar"), 0600)
|
err = os.WriteFile(filepath.Join(tmpDir, "foo"), []byte("bar"), 0o600)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
icmd.RunCmd(icmd.Cmd{
|
icmd.RunCmd(icmd.Cmd{
|
||||||
|
@ -2106,7 +2106,7 @@ func (s *DockerCLIBuildSuite) testBuildDockerfileStdinNoExtraFiles(c *testing.T,
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
writeFile := func(filename, content string) {
|
writeFile := func(filename, content string) {
|
||||||
err = os.WriteFile(filepath.Join(tmpDir, filename), []byte(content), 0600)
|
err = os.WriteFile(filepath.Join(tmpDir, filename), []byte(content), 0o600)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2856,7 +2856,7 @@ RUN cat /existing-directory-trailing-slash/test/foo | grep Hi`
|
||||||
c.Fatalf("failed to close tar archive: %v", err)
|
c.Fatalf("failed to close tar archive: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
|
||||||
c.Fatalf("failed to open destination dockerfile: %v", err)
|
c.Fatalf("failed to open destination dockerfile: %v", err)
|
||||||
}
|
}
|
||||||
return fakecontext.New(c, tmpDir)
|
return fakecontext.New(c, tmpDir)
|
||||||
|
@ -2905,7 +2905,7 @@ ADD test.tar /`
|
||||||
c.Fatalf("failed to truncate tar archive: %v", err)
|
c.Fatalf("failed to truncate tar archive: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
|
||||||
c.Fatalf("failed to open destination dockerfile: %v", err)
|
c.Fatalf("failed to open destination dockerfile: %v", err)
|
||||||
}
|
}
|
||||||
return fakecontext.New(c, tmpDir)
|
return fakecontext.New(c, tmpDir)
|
||||||
|
@ -2968,7 +2968,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddTarXz(c *testing.T) {
|
||||||
Command: []string{"xz", "-k", "test.tar"},
|
Command: []string{"xz", "-k", "test.tar"},
|
||||||
Dir: tmpDir,
|
Dir: tmpDir,
|
||||||
}).Assert(c, icmd.Success)
|
}).Assert(c, icmd.Success)
|
||||||
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
|
||||||
c.Fatalf("failed to open destination dockerfile: %v", err)
|
c.Fatalf("failed to open destination dockerfile: %v", err)
|
||||||
}
|
}
|
||||||
return fakecontext.New(c, tmpDir)
|
return fakecontext.New(c, tmpDir)
|
||||||
|
@ -3020,7 +3020,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddTarXzGz(c *testing.T) {
|
||||||
Command: []string{"gzip", "test.tar.xz"},
|
Command: []string{"gzip", "test.tar.xz"},
|
||||||
Dir: tmpDir,
|
Dir: tmpDir,
|
||||||
})
|
})
|
||||||
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
|
||||||
c.Fatalf("failed to open destination dockerfile: %v", err)
|
c.Fatalf("failed to open destination dockerfile: %v", err)
|
||||||
}
|
}
|
||||||
return fakecontext.New(c, tmpDir)
|
return fakecontext.New(c, tmpDir)
|
||||||
|
@ -3587,18 +3587,18 @@ func (s *DockerCLIBuildSuite) TestBuildSymlinkBreakout(c *testing.T) {
|
||||||
|
|
||||||
defer os.RemoveAll(tmpdir)
|
defer os.RemoveAll(tmpdir)
|
||||||
ctx := filepath.Join(tmpdir, "context")
|
ctx := filepath.Join(tmpdir, "context")
|
||||||
if err := os.MkdirAll(ctx, 0755); err != nil {
|
if err := os.MkdirAll(ctx, 0o755); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(filepath.Join(ctx, "Dockerfile"), []byte(`
|
if err := os.WriteFile(filepath.Join(ctx, "Dockerfile"), []byte(`
|
||||||
from busybox
|
from busybox
|
||||||
add symlink.tar /
|
add symlink.tar /
|
||||||
add inject /symlink/
|
add inject /symlink/
|
||||||
`), 0644); err != nil {
|
`), 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
inject := filepath.Join(ctx, "inject")
|
inject := filepath.Join(ctx, "inject")
|
||||||
if err := os.WriteFile(inject, nil, 0644); err != nil {
|
if err := os.WriteFile(inject, nil, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
f, err := os.Create(filepath.Join(ctx, "symlink.tar"))
|
f, err := os.Create(filepath.Join(ctx, "symlink.tar"))
|
||||||
|
@ -4747,7 +4747,7 @@ func (s *DockerCLIBuildSuite) TestBuildCacheBrokenSymlink(c *testing.T) {
|
||||||
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||||
|
|
||||||
// add new file to context, should invalidate cache
|
// add new file to context, should invalidate cache
|
||||||
err = os.WriteFile(filepath.Join(ctx.Dir, "newfile"), []byte("foo"), 0644)
|
err = os.WriteFile(filepath.Join(ctx.Dir, "newfile"), []byte("foo"), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||||
|
@ -4776,14 +4776,13 @@ func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
|
||||||
assert.Assert(c, cmp.Regexp("^bar$", out))
|
assert.Assert(c, cmp.Regexp("^bar$", out))
|
||||||
|
|
||||||
// change target file should invalidate cache
|
// change target file should invalidate cache
|
||||||
err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
|
err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||||
assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
|
assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
|
||||||
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
|
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
|
||||||
assert.Assert(c, cmp.Regexp("^baz$", out))
|
assert.Assert(c, cmp.Regexp("^baz$", out))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
||||||
|
@ -4807,7 +4806,7 @@ func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
||||||
assert.Assert(c, cmp.Regexp("^barbaz$", out))
|
assert.Assert(c, cmp.Regexp("^barbaz$", out))
|
||||||
|
|
||||||
// change target file should invalidate cache
|
// change target file should invalidate cache
|
||||||
err = os.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0644)
|
err = os.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||||
|
@ -4854,7 +4853,7 @@ func (s *DockerCLIBuildSuite) TestBuildCacheRootSource(c *testing.T) {
|
||||||
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||||
|
|
||||||
// change file, should invalidate cache
|
// change file, should invalidate cache
|
||||||
err := os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
|
err := os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||||
|
@ -5004,7 +5003,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestBuildWithExternalAuth(c *testing.T
|
||||||
externalAuthConfig := `{ "credsStore": "shell-test" }`
|
externalAuthConfig := `{ "credsStore": "shell-test" }`
|
||||||
|
|
||||||
configPath := filepath.Join(tmp, "config.json")
|
configPath := filepath.Join(tmp, "config.json")
|
||||||
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
|
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
||||||
|
@ -5464,7 +5463,7 @@ func (s *DockerCLIBuildSuite) TestBuildCacheFrom(c *testing.T) {
|
||||||
ENV FOO=bar
|
ENV FOO=bar
|
||||||
ADD baz /
|
ADD baz /
|
||||||
RUN touch newfile`
|
RUN touch newfile`
|
||||||
err = os.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(dockerfile), 0644)
|
err = os.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(dockerfile), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
|
result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
|
||||||
|
@ -5621,14 +5620,14 @@ func (s *DockerCLIBuildSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) {
|
||||||
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 7)
|
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 7)
|
||||||
assert.Equal(c, getIDByName(c, "build1"), getIDByName(c, "build2"))
|
assert.Equal(c, getIDByName(c, "build1"), getIDByName(c, "build2"))
|
||||||
|
|
||||||
err := os.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(fmt.Sprintf(dockerfile, "COPY baz/aa foo")), 0644)
|
err := os.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(fmt.Sprintf(dockerfile, "COPY baz/aa foo")), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
// changing file in parent block should not affect last block
|
// changing file in parent block should not affect last block
|
||||||
result = cli.BuildCmd(c, "build3", build.WithExternalBuildContext(ctx))
|
result = cli.BuildCmd(c, "build3", build.WithExternalBuildContext(ctx))
|
||||||
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 5)
|
assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 5)
|
||||||
|
|
||||||
err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("pqr"), 0644)
|
err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("pqr"), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
// changing file in parent block should affect both first and last block
|
// changing file in parent block should affect both first and last block
|
||||||
|
@ -6145,7 +6144,7 @@ func (s *DockerCLIBuildSuite) TestBuildIidFileCleanupOnFail(c *testing.T) {
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
tmpIidFile := filepath.Join(tmpDir, "iid")
|
tmpIidFile := filepath.Join(tmpDir, "iid")
|
||||||
|
|
||||||
err = os.WriteFile(tmpIidFile, []byte("Dummy"), 0666)
|
err = os.WriteFile(tmpIidFile, []byte("Dummy"), 0o666)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
cli.Docker(cli.Args("build", "-t", "testbuildiidfilecleanuponfail"),
|
cli.Docker(cli.Args("build", "-t", "testbuildiidfilecleanuponfail"),
|
||||||
|
|
|
@ -107,7 +107,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddChangeOwnership(c *testing.T) {
|
||||||
Dir: tmpDir,
|
Dir: tmpDir,
|
||||||
}).Assert(c, icmd.Success)
|
}).Assert(c, icmd.Success)
|
||||||
|
|
||||||
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
|
||||||
c.Fatalf("failed to open destination dockerfile: %v", err)
|
c.Fatalf("failed to open destination dockerfile: %v", err)
|
||||||
}
|
}
|
||||||
return fakecontext.New(c, tmpDir)
|
return fakecontext.New(c, tmpDir)
|
||||||
|
|
|
@ -182,7 +182,7 @@ func (s *DockerCLICpSuite) TestCpFromCaseD(c *testing.T) {
|
||||||
// Now try again but using a trailing path separator for dstDir.
|
// Now try again but using a trailing path separator for dstDir.
|
||||||
|
|
||||||
assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
|
assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
|
||||||
assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0755)), "unable to make dstDir")
|
assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0o755)), "unable to make dstDir")
|
||||||
|
|
||||||
dstDir = cpPathTrailingSep(tmpDir, "dir1")
|
dstDir = cpPathTrailingSep(tmpDir, "dir1")
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ func (s *DockerCLICpSuite) TestCpFromCaseG(c *testing.T) {
|
||||||
// Now try again but using a trailing path separator for dstDir.
|
// Now try again but using a trailing path separator for dstDir.
|
||||||
|
|
||||||
assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
|
assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
|
||||||
assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0755)), "unable to make dstDir")
|
assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0o755)), "unable to make dstDir")
|
||||||
|
|
||||||
dstDir = cpPathTrailingSep(tmpDir, "dir2")
|
dstDir = cpPathTrailingSep(tmpDir, "dir2")
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ func (s *DockerCLICpSuite) TestCpFromCaseJ(c *testing.T) {
|
||||||
// Now try again but using a trailing path separator for dstDir.
|
// Now try again but using a trailing path separator for dstDir.
|
||||||
|
|
||||||
assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
|
assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
|
||||||
assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0755)), "unable to make dstDir")
|
assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0o755)), "unable to make dstDir")
|
||||||
|
|
||||||
dstDir = cpPathTrailingSep(tmpDir, "dir2")
|
dstDir = cpPathTrailingSep(tmpDir, "dir2")
|
||||||
|
|
||||||
|
|
|
@ -265,8 +265,8 @@ func (s *DockerCLICpSuite) TestCpToSymlinkToDirectory(c *testing.T) {
|
||||||
// This file will be at "/testDir/some/path/test" and will be copied into
|
// This file will be at "/testDir/some/path/test" and will be copied into
|
||||||
// the test volume later.
|
// the test volume later.
|
||||||
hostTestFilename := filepath.Join(testDir, cpFullPath)
|
hostTestFilename := filepath.Join(testDir, cpFullPath)
|
||||||
assert.NilError(c, os.MkdirAll(filepath.Dir(hostTestFilename), os.FileMode(0700)))
|
assert.NilError(c, os.MkdirAll(filepath.Dir(hostTestFilename), os.FileMode(0o700)))
|
||||||
assert.NilError(c, os.WriteFile(hostTestFilename, []byte(cpHostContents), os.FileMode(0600)))
|
assert.NilError(c, os.WriteFile(hostTestFilename, []byte(cpHostContents), os.FileMode(0o600)))
|
||||||
|
|
||||||
// Now create another temp directory to hold a symlink to the
|
// Now create another temp directory to hold a symlink to the
|
||||||
// "/testDir/some" directory.
|
// "/testDir/some" directory.
|
||||||
|
@ -375,7 +375,7 @@ func (s *DockerCLICpSuite) TestCpUnprivilegedUser(c *testing.T) {
|
||||||
|
|
||||||
defer os.RemoveAll(tmpdir)
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
err = os.Chmod(tmpdir, 0777)
|
err = os.Chmod(tmpdir, 0o777)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
result := icmd.RunCommand("su", "unprivilegeduser", "-c",
|
result := icmd.RunCommand("su", "unprivilegeduser", "-c",
|
||||||
|
|
|
@ -59,33 +59,33 @@ func mkFilesCommand(fds []fileData) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultFileData = []fileData{
|
var defaultFileData = []fileData{
|
||||||
{ftRegular, "file1", "file1", 0, 0, 0666},
|
{ftRegular, "file1", "file1", 0, 0, 0o666},
|
||||||
{ftRegular, "file2", "file2", 0, 0, 0666},
|
{ftRegular, "file2", "file2", 0, 0, 0o666},
|
||||||
{ftRegular, "file3", "file3", 0, 0, 0666},
|
{ftRegular, "file3", "file3", 0, 0, 0o666},
|
||||||
{ftRegular, "file4", "file4", 0, 0, 0666},
|
{ftRegular, "file4", "file4", 0, 0, 0o666},
|
||||||
{ftRegular, "file5", "file5", 0, 0, 0666},
|
{ftRegular, "file5", "file5", 0, 0, 0o666},
|
||||||
{ftRegular, "file6", "file6", 0, 0, 0666},
|
{ftRegular, "file6", "file6", 0, 0, 0o666},
|
||||||
{ftRegular, "file7", "file7", 0, 0, 0666},
|
{ftRegular, "file7", "file7", 0, 0, 0o666},
|
||||||
{ftDir, "dir1", "", 0, 0, 0777},
|
{ftDir, "dir1", "", 0, 0, 0o777},
|
||||||
{ftRegular, "dir1/file1-1", "file1-1", 0, 0, 0666},
|
{ftRegular, "dir1/file1-1", "file1-1", 0, 0, 0o666},
|
||||||
{ftRegular, "dir1/file1-2", "file1-2", 0, 0, 0666},
|
{ftRegular, "dir1/file1-2", "file1-2", 0, 0, 0o666},
|
||||||
{ftDir, "dir2", "", 0, 0, 0666},
|
{ftDir, "dir2", "", 0, 0, 0o666},
|
||||||
{ftRegular, "dir2/file2-1", "file2-1", 0, 0, 0666},
|
{ftRegular, "dir2/file2-1", "file2-1", 0, 0, 0o666},
|
||||||
{ftRegular, "dir2/file2-2", "file2-2", 0, 0, 0666},
|
{ftRegular, "dir2/file2-2", "file2-2", 0, 0, 0o666},
|
||||||
{ftDir, "dir3", "", 0, 0, 0666},
|
{ftDir, "dir3", "", 0, 0, 0o666},
|
||||||
{ftRegular, "dir3/file3-1", "file3-1", 0, 0, 0666},
|
{ftRegular, "dir3/file3-1", "file3-1", 0, 0, 0o666},
|
||||||
{ftRegular, "dir3/file3-2", "file3-2", 0, 0, 0666},
|
{ftRegular, "dir3/file3-2", "file3-2", 0, 0, 0o666},
|
||||||
{ftDir, "dir4", "", 0, 0, 0666},
|
{ftDir, "dir4", "", 0, 0, 0o666},
|
||||||
{ftRegular, "dir4/file3-1", "file4-1", 0, 0, 0666},
|
{ftRegular, "dir4/file3-1", "file4-1", 0, 0, 0o666},
|
||||||
{ftRegular, "dir4/file3-2", "file4-2", 0, 0, 0666},
|
{ftRegular, "dir4/file3-2", "file4-2", 0, 0, 0o666},
|
||||||
{ftDir, "dir5", "", 0, 0, 0666},
|
{ftDir, "dir5", "", 0, 0, 0o666},
|
||||||
{ftSymlink, "symlinkToFile1", "file1", 0, 0, 0666},
|
{ftSymlink, "symlinkToFile1", "file1", 0, 0, 0o666},
|
||||||
{ftSymlink, "symlinkToDir1", "dir1", 0, 0, 0666},
|
{ftSymlink, "symlinkToDir1", "dir1", 0, 0, 0o666},
|
||||||
{ftSymlink, "brokenSymlinkToFileX", "fileX", 0, 0, 0666},
|
{ftSymlink, "brokenSymlinkToFileX", "fileX", 0, 0, 0o666},
|
||||||
{ftSymlink, "brokenSymlinkToDirX", "dirX", 0, 0, 0666},
|
{ftSymlink, "brokenSymlinkToDirX", "dirX", 0, 0, 0o666},
|
||||||
{ftSymlink, "symlinkToAbsDir", "/root", 0, 0, 0666},
|
{ftSymlink, "symlinkToAbsDir", "/root", 0, 0, 0o666},
|
||||||
{ftDir, "permdirtest", "", 2, 2, 0700},
|
{ftDir, "permdirtest", "", 2, 2, 0o700},
|
||||||
{ftRegular, "permdirtest/permtest", "perm_test", 65534, 65534, 0400},
|
{ftRegular, "permdirtest/permtest", "perm_test", 65534, 65534, 0o400},
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultMkContentCommand() string {
|
func defaultMkContentCommand() string {
|
||||||
|
|
|
@ -2215,7 +2215,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
os.WriteFile(configName, []byte(config), 0644)
|
os.WriteFile(configName, []byte(config), 0o644)
|
||||||
s.d.StartWithBusybox(c, "--config-file", configName)
|
s.d.StartWithBusybox(c, "--config-file", configName)
|
||||||
|
|
||||||
// Run with default runtime
|
// Run with default runtime
|
||||||
|
@ -2241,7 +2241,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
os.WriteFile(configName, []byte(config), 0644)
|
os.WriteFile(configName, []byte(config), 0o644)
|
||||||
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
|
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
|
||||||
// Give daemon time to reload config
|
// Give daemon time to reload config
|
||||||
<-time.After(1 * time.Second)
|
<-time.After(1 * time.Second)
|
||||||
|
@ -2268,7 +2268,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
os.WriteFile(configName, []byte(config), 0644)
|
os.WriteFile(configName, []byte(config), 0o644)
|
||||||
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
|
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
|
||||||
// Give daemon time to reload config
|
// Give daemon time to reload config
|
||||||
<-time.After(1 * time.Second)
|
<-time.After(1 * time.Second)
|
||||||
|
@ -2293,7 +2293,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
os.WriteFile(configName, []byte(config), 0644)
|
os.WriteFile(configName, []byte(config), 0o644)
|
||||||
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
|
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
|
||||||
// Give daemon time to reload config
|
// Give daemon time to reload config
|
||||||
<-time.After(1 * time.Second)
|
<-time.After(1 * time.Second)
|
||||||
|
@ -2654,7 +2654,7 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
|
||||||
|
|
||||||
size := 67108864 * 2
|
size := 67108864 * 2
|
||||||
configData := []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
|
configData := []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
|
||||||
assert.Assert(c, os.WriteFile(configFile, configData, 0666) == nil, "could not write temp file for config reload")
|
assert.Assert(c, os.WriteFile(configFile, configData, 0o666) == nil, "could not write temp file for config reload")
|
||||||
pattern := regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
|
pattern := regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
|
||||||
|
|
||||||
s.d.StartWithBusybox(c, "--config-file", configFile)
|
s.d.StartWithBusybox(c, "--config-file", configFile)
|
||||||
|
@ -2669,7 +2669,7 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
|
||||||
|
|
||||||
size = 67108864 * 3
|
size = 67108864 * 3
|
||||||
configData = []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
|
configData = []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
|
||||||
assert.Assert(c, os.WriteFile(configFile, configData, 0666) == nil, "could not write temp file for config reload")
|
assert.Assert(c, os.WriteFile(configFile, configData, 0o666) == nil, "could not write temp file for config reload")
|
||||||
pattern = regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
|
pattern = regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
|
||||||
|
|
||||||
err = s.d.ReloadConfig()
|
err = s.d.ReloadConfig()
|
||||||
|
|
|
@ -395,14 +395,14 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *testing.T) {
|
||||||
defer os.Remove(configFilePath)
|
defer os.Remove(configFilePath)
|
||||||
|
|
||||||
daemonConfig := `{"labels":["foo=bar"]}`
|
daemonConfig := `{"labels":["foo=bar"]}`
|
||||||
err := os.WriteFile(configFilePath, []byte(daemonConfig), 0644)
|
err := os.WriteFile(configFilePath, []byte(daemonConfig), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
s.d.Start(c, "--config-file="+configFilePath)
|
s.d.Start(c, "--config-file="+configFilePath)
|
||||||
|
|
||||||
info := s.d.Info(c)
|
info := s.d.Info(c)
|
||||||
|
|
||||||
daemonConfig = `{"max-concurrent-downloads":1,"labels":["bar=foo"], "shutdown-timeout": 10}`
|
daemonConfig = `{"max-concurrent-downloads":1,"labels":["bar=foo"], "shutdown-timeout": 10}`
|
||||||
err = os.WriteFile(configFilePath, []byte(daemonConfig), 0644)
|
err = os.WriteFile(configFilePath, []byte(daemonConfig), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
assert.NilError(c, s.d.Signal(unix.SIGHUP))
|
assert.NilError(c, s.d.Signal(unix.SIGHUP))
|
||||||
|
@ -442,7 +442,7 @@ func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *testing.T) {
|
||||||
defer os.Remove(configFilePath)
|
defer os.Remove(configFilePath)
|
||||||
|
|
||||||
daemonConfig := `{"labels":["foo=bar"]}`
|
daemonConfig := `{"labels":["foo=bar"]}`
|
||||||
err := os.WriteFile(configFilePath, []byte(daemonConfig), 0644)
|
err := os.WriteFile(configFilePath, []byte(daemonConfig), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
s.d.Start(c, "--config-file="+configFilePath)
|
s.d.Start(c, "--config-file="+configFilePath)
|
||||||
|
|
||||||
|
|
|
@ -408,7 +408,7 @@ func (s *DockerCLIExecSuite) TestRunMutableNetworkFiles(c *testing.T) {
|
||||||
contID := strings.TrimSpace(out)
|
contID := strings.TrimSpace(out)
|
||||||
netFilePath := containerStorageFile(contID, fn)
|
netFilePath := containerStorageFile(contID, fn)
|
||||||
|
|
||||||
f, err := os.OpenFile(netFilePath, os.O_WRONLY|os.O_SYNC|os.O_APPEND, 0644)
|
f, err := os.OpenFile(netFilePath, os.O_WRONLY|os.O_SYNC|os.O_APPEND, 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
if _, err := f.Seek(0, 0); err != nil {
|
if _, err := f.Seek(0, 0); err != nil {
|
||||||
|
|
|
@ -216,17 +216,17 @@ func newVolumePlugin(c *testing.T, name string) *volumePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
p := hostVolumePath(pr.Name)
|
p := hostVolumePath(pr.Name)
|
||||||
if err := os.MkdirAll(p, 0755); err != nil {
|
if err := os.MkdirAll(p, 0o755); err != nil {
|
||||||
send(w, &pluginResp{Err: err.Error()})
|
send(w, &pluginResp{Err: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(filepath.Join(p, "test"), []byte(s.Server.URL), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(p, "test"), []byte(s.Server.URL), 0o644); err != nil {
|
||||||
send(w, err)
|
send(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(filepath.Join(p, "mountID"), []byte(pr.ID), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(p, "mountID"), []byte(pr.ID), 0o644); err != nil {
|
||||||
send(w, err)
|
send(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -258,10 +258,10 @@ func newVolumePlugin(c *testing.T, name string) *volumePlugin {
|
||||||
send(w, `{"Capabilities": { "Scope": "global" }}`)
|
send(w, `{"Capabilities": { "Scope": "global" }}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
err := os.MkdirAll("/etc/docker/plugins", 0755)
|
err := os.MkdirAll("/etc/docker/plugins", 0o755)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
err = os.WriteFile("/etc/docker/plugins/"+name+".spec", []byte(s.Server.URL), 0644)
|
err = os.WriteFile("/etc/docker/plugins/"+name+".spec", []byte(s.Server.URL), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ func hostVolumePath(name string) string {
|
||||||
// Make sure a request to use a down driver doesn't block other requests
|
// Make sure a request to use a down driver doesn't block other requests
|
||||||
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *testing.T) {
|
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *testing.T) {
|
||||||
specPath := "/etc/docker/plugins/down-driver.spec"
|
specPath := "/etc/docker/plugins/down-driver.spec"
|
||||||
err := os.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0644)
|
err := os.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer os.RemoveAll(specPath)
|
defer os.RemoveAll(specPath)
|
||||||
|
|
||||||
|
|
|
@ -367,7 +367,7 @@ func (s *DockerCLIImagesSuite) TestImagesFormatDefaultFormat(c *testing.T) {
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer os.RemoveAll(d)
|
defer os.RemoveAll(d)
|
||||||
|
|
||||||
err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
|
err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
out, _ = dockerCmd(c, "--config", d, "images", "-q", "myimage")
|
out, _ = dockerCmd(c, "--config", d, "images", "-q", "myimage")
|
||||||
|
|
|
@ -110,7 +110,7 @@ func (s *DockerCLILinksSuite) TestLinksInspectLinksStarted(c *testing.T) {
|
||||||
err := json.Unmarshal([]byte(links), &result)
|
err := json.Unmarshal([]byte(links), &result)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
var expected = []string{
|
expected := []string{
|
||||||
"/container1:/testinspectlink/alias1",
|
"/container1:/testinspectlink/alias1",
|
||||||
"/container2:/testinspectlink/alias2",
|
"/container2:/testinspectlink/alias2",
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ func (s *DockerCLILinksSuite) TestLinksInspectLinksStopped(c *testing.T) {
|
||||||
err := json.Unmarshal([]byte(links), &result)
|
err := json.Unmarshal([]byte(links), &result)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
var expected = []string{
|
expected := []string{
|
||||||
"/container1:/testinspectlink/alias1",
|
"/container1:/testinspectlink/alias1",
|
||||||
"/container2:/testinspectlink/alias2",
|
"/container2:/testinspectlink/alias2",
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.
|
||||||
externalAuthConfig := `{ "credsStore": "shell-test" }`
|
externalAuthConfig := `{ "credsStore": "shell-test" }`
|
||||||
|
|
||||||
configPath := filepath.Join(tmp, "config.json")
|
configPath := filepath.Join(tmp, "config.json")
|
||||||
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
|
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
_, err = s.d.Cmd("--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
_, err = s.d.Cmd("--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
||||||
|
@ -83,7 +83,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithWrongHostnamesStored(c *
|
||||||
externalAuthConfig := fmt.Sprintf(`{ "auths": {"https://%s": {}}, "credsStore": "shell-test" }`, privateRegistryURL)
|
externalAuthConfig := fmt.Sprintf(`{ "auths": {"https://%s": {}}, "credsStore": "shell-test" }`, privateRegistryURL)
|
||||||
|
|
||||||
configPath := filepath.Join(tmp, "config.json")
|
configPath := filepath.Join(tmp, "config.json")
|
||||||
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
|
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
||||||
|
|
|
@ -31,8 +31,10 @@ import (
|
||||||
"gotest.tools/v3/icmd"
|
"gotest.tools/v3/icmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
const dummyNetworkDriver = "dummy-network-driver"
|
const (
|
||||||
const dummyIPAMDriver = "dummy-ipam-driver"
|
dummyNetworkDriver = "dummy-network-driver"
|
||||||
|
dummyIPAMDriver = "dummy-ipam-driver"
|
||||||
|
)
|
||||||
|
|
||||||
var remoteDriverNetworkRequest remoteapi.CreateNetworkRequest
|
var remoteDriverNetworkRequest remoteapi.CreateNetworkRequest
|
||||||
|
|
||||||
|
@ -90,7 +92,8 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
||||||
|
|
||||||
veth := &netlink.Veth{
|
veth := &netlink.Veth{
|
||||||
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0"}
|
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
|
||||||
|
}
|
||||||
if err := netlink.LinkAdd(veth); err != nil {
|
if err := netlink.LinkAdd(veth); err != nil {
|
||||||
fmt.Fprintf(w, `{"Error":"failed to add veth pair: `+err.Error()+`"}`)
|
fmt.Fprintf(w, `{"Error":"failed to add veth pair: `+err.Error()+`"}`)
|
||||||
} else {
|
} else {
|
||||||
|
@ -194,15 +197,15 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
err := os.MkdirAll("/etc/docker/plugins", 0755)
|
err := os.MkdirAll("/etc/docker/plugins", 0o755)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv)
|
fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv)
|
||||||
err = os.WriteFile(fileName, []byte(url), 0644)
|
err = os.WriteFile(fileName, []byte(url), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv)
|
ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv)
|
||||||
err = os.WriteFile(ipamFileName, []byte(url), 0644)
|
err = os.WriteFile(ipamFileName, []byte(url), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,10 +261,10 @@ func (ps *DockerPluginSuite) TestPluginCreate(c *testing.T) {
|
||||||
defer os.RemoveAll(temp)
|
defer os.RemoveAll(temp)
|
||||||
|
|
||||||
data := `{"description": "foo plugin"}`
|
data := `{"description": "foo plugin"}`
|
||||||
err = os.WriteFile(filepath.Join(temp, "config.json"), []byte(data), 0644)
|
err = os.WriteFile(filepath.Join(temp, "config.json"), []byte(data), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
err = os.MkdirAll(filepath.Join(temp, "rootfs"), 0700)
|
err = os.MkdirAll(filepath.Join(temp, "rootfs"), 0o700)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
out, _, err := dockerCmdWithError("plugin", "create", name, temp)
|
out, _, err := dockerCmdWithError("plugin", "create", name, temp)
|
||||||
|
@ -400,7 +400,7 @@ func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *testing.T) {
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer os.RemoveAll(config)
|
defer os.RemoveAll(config)
|
||||||
|
|
||||||
err = os.WriteFile(filepath.Join(config, "config.json"), []byte(`{"pluginsFormat": "raw"}`), 0644)
|
err = os.WriteFile(filepath.Join(config, "config.json"), []byte(`{"pluginsFormat": "raw"}`), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
name := "test:latest"
|
name := "test:latest"
|
||||||
|
|
|
@ -156,7 +156,7 @@ func (s *DockerCLIPruneSuite) TestPruneContainerLabel(c *testing.T) {
|
||||||
d, err := os.MkdirTemp("", "integration-cli-")
|
d, err := os.MkdirTemp("", "integration-cli-")
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer os.RemoveAll(d)
|
defer os.RemoveAll(d)
|
||||||
err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
|
err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
// With config.json only, prune based on label=foobar
|
// With config.json only, prune based on label=foobar
|
||||||
|
@ -208,7 +208,7 @@ func (s *DockerCLIPruneSuite) TestPruneVolumeLabel(c *testing.T) {
|
||||||
d, err := os.MkdirTemp("", "integration-cli-")
|
d, err := os.MkdirTemp("", "integration-cli-")
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer os.RemoveAll(d)
|
defer os.RemoveAll(d)
|
||||||
err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
|
err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
// With config.json only, prune based on label=foobar
|
// With config.json only, prune based on label=foobar
|
||||||
|
|
|
@ -356,7 +356,7 @@ func (s *DockerCLIPsSuite) TestPsListContainersFilterAncestorImage(c *testing.T)
|
||||||
dockerCmd(c, "run", "--name=fifth", imageName2, "echo", "hello")
|
dockerCmd(c, "run", "--name=fifth", imageName2, "echo", "hello")
|
||||||
fifthID := getIDByName(c, "fifth")
|
fifthID := getIDByName(c, "fifth")
|
||||||
|
|
||||||
var filterTestSuite = []struct {
|
filterTestSuite := []struct {
|
||||||
filterName string
|
filterName string
|
||||||
expectedIDs []string
|
expectedIDs []string
|
||||||
}{
|
}{
|
||||||
|
|
|
@ -329,23 +329,23 @@ func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
|
||||||
|
|
||||||
// Write manifest list to blob store
|
// Write manifest list to blob store
|
||||||
blobDir := filepath.Join(registryV2Path, "blobs", "sha256", hexDigest[:2], hexDigest)
|
blobDir := filepath.Join(registryV2Path, "blobs", "sha256", hexDigest[:2], hexDigest)
|
||||||
err = os.MkdirAll(blobDir, 0755)
|
err = os.MkdirAll(blobDir, 0o755)
|
||||||
assert.NilError(c, err, "error creating blob dir")
|
assert.NilError(c, err, "error creating blob dir")
|
||||||
blobPath := filepath.Join(blobDir, "data")
|
blobPath := filepath.Join(blobDir, "data")
|
||||||
err = os.WriteFile(blobPath, manifestListJSON, 0644)
|
err = os.WriteFile(blobPath, manifestListJSON, 0o644)
|
||||||
assert.NilError(c, err, "error writing manifest list")
|
assert.NilError(c, err, "error writing manifest list")
|
||||||
|
|
||||||
// Add to revision store
|
// Add to revision store
|
||||||
revisionDir := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "revisions", "sha256", hexDigest)
|
revisionDir := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "revisions", "sha256", hexDigest)
|
||||||
err = os.Mkdir(revisionDir, 0755)
|
err = os.Mkdir(revisionDir, 0o755)
|
||||||
assert.Assert(c, err == nil, "error creating revision dir")
|
assert.Assert(c, err == nil, "error creating revision dir")
|
||||||
revisionPath := filepath.Join(revisionDir, "link")
|
revisionPath := filepath.Join(revisionDir, "link")
|
||||||
err = os.WriteFile(revisionPath, []byte(manifestListDigest.String()), 0644)
|
err = os.WriteFile(revisionPath, []byte(manifestListDigest.String()), 0o644)
|
||||||
assert.Assert(c, err == nil, "error writing revision link")
|
assert.Assert(c, err == nil, "error writing revision link")
|
||||||
|
|
||||||
// Update tag
|
// Update tag
|
||||||
tagPath := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "tags", "latest", "current", "link")
|
tagPath := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "tags", "latest", "current", "link")
|
||||||
err = os.WriteFile(tagPath, []byte(manifestListDigest.String()), 0644)
|
err = os.WriteFile(tagPath, []byte(manifestListDigest.String()), 0o644)
|
||||||
assert.NilError(c, err, "error writing tag link")
|
assert.NilError(c, err, "error writing tag link")
|
||||||
|
|
||||||
// Verify that the image can be pulled through the manifest list.
|
// Verify that the image can be pulled through the manifest list.
|
||||||
|
@ -384,7 +384,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithSchem
|
||||||
externalAuthConfig := `{ "credsStore": "shell-test" }`
|
externalAuthConfig := `{ "credsStore": "shell-test" }`
|
||||||
|
|
||||||
configPath := filepath.Join(tmp, "config.json")
|
configPath := filepath.Join(tmp, "config.json")
|
||||||
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
|
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
||||||
|
@ -426,7 +426,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *testing.T)
|
||||||
externalAuthConfig := `{ "credsStore": "shell-test" }`
|
externalAuthConfig := `{ "credsStore": "shell-test" }`
|
||||||
|
|
||||||
configPath := filepath.Join(tmp, "config.json")
|
configPath := filepath.Join(tmp, "config.json")
|
||||||
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
|
err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
|
||||||
|
|
|
@ -281,8 +281,8 @@ func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponse
|
||||||
out, _, err := dockerCmdWithError("push", repoName)
|
out, _, err := dockerCmdWithError("push", repoName)
|
||||||
assert.ErrorContains(c, err, "", out)
|
assert.ErrorContains(c, err, "", out)
|
||||||
// TODO: isolate test so that it can be guaranteed that the 503 will trigger xfer retries
|
// TODO: isolate test so that it can be guaranteed that the 503 will trigger xfer retries
|
||||||
//assert.Assert(c, strings.Contains(out, "Retrying"))
|
// assert.Assert(c, strings.Contains(out, "Retrying"))
|
||||||
//assert.Assert(c, !strings.Contains(out, "Retrying in 15"))
|
// assert.Assert(c, !strings.Contains(out, "Retrying in 15"))
|
||||||
split := strings.Split(out, "\n")
|
split := strings.Split(out, "\n")
|
||||||
assert.Equal(c, split[len(split)-2], "toomanyrequests: out of tokens")
|
assert.Equal(c, split[len(split)-2], "toomanyrequests: out of tokens")
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,7 +406,7 @@ func (s *DockerCLIRunSuite) TestRunCreateVolumesInSymlinkDir(c *testing.T) {
|
||||||
c.Skip("Requires TEMP to point to C: drive")
|
c.Skip("Requires TEMP to point to C: drive")
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.OpenFile(filepath.Join(dir, "test"), os.O_CREATE, 0700)
|
f, err := os.OpenFile(filepath.Join(dir, "test"), os.O_CREATE, 0o700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ func (s *DockerCLIRunSuite) TestVolumesFromGetsProperMode(c *testing.T) {
|
||||||
testRequires(c, testEnv.IsLocalDaemon)
|
testRequires(c, testEnv.IsLocalDaemon)
|
||||||
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
|
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
|
||||||
hostpath := RandomTmpDirPath("test", testEnv.DaemonInfo.OSType)
|
hostpath := RandomTmpDirPath("test", testEnv.DaemonInfo.OSType)
|
||||||
if err := os.MkdirAll(hostpath, 0755); err != nil {
|
if err := os.MkdirAll(hostpath, 0o755); err != nil {
|
||||||
c.Fatalf("Failed to create %s: %q", hostpath, err)
|
c.Fatalf("Failed to create %s: %q", hostpath, err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(hostpath)
|
defer os.RemoveAll(hostpath)
|
||||||
|
@ -534,11 +534,11 @@ func (s *DockerCLIRunSuite) TestRunNoDupVolumes(c *testing.T) {
|
||||||
// Windows requires that the source directory exists before calling HCS
|
// Windows requires that the source directory exists before calling HCS
|
||||||
testRequires(c, testEnv.IsLocalDaemon)
|
testRequires(c, testEnv.IsLocalDaemon)
|
||||||
someplace = `:c:\someplace`
|
someplace = `:c:\someplace`
|
||||||
if err := os.MkdirAll(path1, 0755); err != nil {
|
if err := os.MkdirAll(path1, 0o755); err != nil {
|
||||||
c.Fatalf("Failed to create %s: %q", path1, err)
|
c.Fatalf("Failed to create %s: %q", path1, err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(path1)
|
defer os.RemoveAll(path1)
|
||||||
if err := os.MkdirAll(path2, 0755); err != nil {
|
if err := os.MkdirAll(path2, 0o755); err != nil {
|
||||||
c.Fatalf("Failed to create %s: %q", path1, err)
|
c.Fatalf("Failed to create %s: %q", path1, err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(path2)
|
defer os.RemoveAll(path2)
|
||||||
|
@ -1269,7 +1269,7 @@ func (s *DockerCLIRunSuite) TestRunDNSDefaultOptions(c *testing.T) {
|
||||||
}
|
}
|
||||||
// defer restored original conf
|
// defer restored original conf
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := os.WriteFile("/etc/resolv.conf", origResolvConf, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", origResolvConf, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -1278,7 +1278,7 @@ func (s *DockerCLIRunSuite) TestRunDNSDefaultOptions(c *testing.T) {
|
||||||
// 2 are removed from the file at container start, and the 3rd (commented out) one is ignored by
|
// 2 are removed from the file at container start, and the 3rd (commented out) one is ignored by
|
||||||
// GetNameservers(), leading to a replacement of nameservers with the default set
|
// GetNameservers(), leading to a replacement of nameservers with the default set
|
||||||
tmpResolvConf := []byte("nameserver 127.0.0.1\n#nameserver 127.0.2.1\nnameserver ::1")
|
tmpResolvConf := []byte("nameserver 127.0.0.1\n#nameserver 127.0.2.1\nnameserver ::1")
|
||||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1373,12 +1373,12 @@ func (s *DockerCLIRunSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T)
|
||||||
|
|
||||||
// test with file
|
// test with file
|
||||||
tmpResolvConf := []byte("search example.com\nnameserver 12.34.56.78\nnameserver 127.0.0.1")
|
tmpResolvConf := []byte("search example.com\nnameserver 12.34.56.78\nnameserver 127.0.0.1")
|
||||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
// put the old resolvconf back
|
// put the old resolvconf back
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := os.WriteFile("/etc/resolv.conf", origResolvConf, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", origResolvConf, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -1416,7 +1416,7 @@ func (s *DockerCLIRunSuite) TestRunNonRootUserResolvName(c *testing.T) {
|
||||||
|
|
||||||
cID := getIDByName(c, "testperm")
|
cID := getIDByName(c, "testperm")
|
||||||
|
|
||||||
fmode := (os.FileMode)(0644)
|
fmode := (os.FileMode)(0o644)
|
||||||
finfo, err := os.Stat(containerStorageFile(cID, "resolv.conf"))
|
finfo, err := os.Stat(containerStorageFile(cID, "resolv.conf"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
|
@ -1457,7 +1457,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -1467,7 +1467,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
|
||||||
containerID1 := getIDByName(c, "first")
|
containerID1 := getIDByName(c, "first")
|
||||||
|
|
||||||
// replace resolv.conf with our temporary copy
|
// replace resolv.conf with our temporary copy
|
||||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1490,7 +1490,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
|
||||||
containerID2 := getIDByName(c, "second")
|
containerID2 := getIDByName(c, "second")
|
||||||
|
|
||||||
// make a change to resolv.conf (in this case replacing our tmp copy with orig copy)
|
// make a change to resolv.conf (in this case replacing our tmp copy with orig copy)
|
||||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1508,7 +1508,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
|
||||||
runningContainerID := strings.TrimSpace(out)
|
runningContainerID := strings.TrimSpace(out)
|
||||||
|
|
||||||
// replace resolv.conf
|
// replace resolv.conf
|
||||||
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1532,7 +1532,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
|
||||||
// host resolv.conf before updating container's resolv.conf copies
|
// host resolv.conf before updating container's resolv.conf copies
|
||||||
|
|
||||||
// replace resolv.conf with a localhost-only nameserver copy
|
// replace resolv.conf with a localhost-only nameserver copy
|
||||||
if err = os.WriteFile("/etc/resolv.conf", tmpLocalhostResolvConf, 0644); err != nil {
|
if err = os.WriteFile("/etc/resolv.conf", tmpLocalhostResolvConf, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1551,7 +1551,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
|
||||||
// of containers' resolv.conf.
|
// of containers' resolv.conf.
|
||||||
|
|
||||||
// Restore the original resolv.conf
|
// Restore the original resolv.conf
|
||||||
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1560,7 +1560,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
|
||||||
containerID3 := getIDByName(c, "third")
|
containerID3 := getIDByName(c, "third")
|
||||||
|
|
||||||
// Create a modified resolv.conf.aside and override resolv.conf with it
|
// Create a modified resolv.conf.aside and override resolv.conf with it
|
||||||
if err := os.WriteFile("/etc/resolv.conf.aside", tmpResolvConf, 0644); err != nil {
|
if err := os.WriteFile("/etc/resolv.conf.aside", tmpResolvConf, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2097,19 +2097,19 @@ func (s *DockerCLIRunSuite) TestRunMountOrdering(c *testing.T) {
|
||||||
|
|
||||||
// Create a temporary tmpfs mounc.
|
// Create a temporary tmpfs mounc.
|
||||||
fooDir := filepath.Join(tmpDir, "foo")
|
fooDir := filepath.Join(tmpDir, "foo")
|
||||||
if err := os.MkdirAll(filepath.Join(tmpDir, "foo"), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Join(tmpDir, "foo"), 0o755); err != nil {
|
||||||
c.Fatalf("failed to mkdir at %s - %s", fooDir, err)
|
c.Fatalf("failed to mkdir at %s - %s", fooDir, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(fmt.Sprintf("%s/touch-me", fooDir), []byte{}, 0644); err != nil {
|
if err := os.WriteFile(fmt.Sprintf("%s/touch-me", fooDir), []byte{}, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(fmt.Sprintf("%s/touch-me", tmpDir), []byte{}, 0644); err != nil {
|
if err := os.WriteFile(fmt.Sprintf("%s/touch-me", tmpDir), []byte{}, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(fmt.Sprintf("%s/touch-me", tmpDir2), []byte{}, 0644); err != nil {
|
if err := os.WriteFile(fmt.Sprintf("%s/touch-me", tmpDir2), []byte{}, 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3055,7 +3055,7 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMount(c *testing.T) {
|
||||||
defer os.Remove(filename)
|
defer os.Remove(filename)
|
||||||
|
|
||||||
// for user namespaced test runs, the temp file must be accessible to unprivileged root
|
// for user namespaced test runs, the temp file must be accessible to unprivileged root
|
||||||
if err := os.Chmod(filename, 0646); err != nil {
|
if err := os.Chmod(filename, 0o646); err != nil {
|
||||||
c.Fatalf("error modifying permissions of %s: %v", filename, err)
|
c.Fatalf("error modifying permissions of %s: %v", filename, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3077,7 +3077,7 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMountRO(c *testing.T) {
|
||||||
defer os.Remove(filename)
|
defer os.Remove(filename)
|
||||||
|
|
||||||
// for user namespaced test runs, the temp file must be accessible to unprivileged root
|
// for user namespaced test runs, the temp file must be accessible to unprivileged root
|
||||||
if err := os.Chmod(filename, 0646); err != nil {
|
if err := os.Chmod(filename, 0o646); err != nil {
|
||||||
c.Fatalf("error modifying permissions of %s: %v", filename, err)
|
c.Fatalf("error modifying permissions of %s: %v", filename, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3099,7 +3099,7 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMountROFilesystem(c *testing.
|
||||||
defer os.Remove(filename)
|
defer os.Remove(filename)
|
||||||
|
|
||||||
// for user namespaced test runs, the temp file must be accessible to unprivileged root
|
// for user namespaced test runs, the temp file must be accessible to unprivileged root
|
||||||
if err := os.Chmod(filename, 0646); err != nil {
|
if err := os.Chmod(filename, 0o646); err != nil {
|
||||||
c.Fatalf("error modifying permissions of %s: %v", filename, err)
|
c.Fatalf("error modifying permissions of %s: %v", filename, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4223,16 +4223,16 @@ func (s *DockerCLIRunSuite) TestRunMount(c *testing.T) {
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
mnt1, mnt2 := path.Join(tmpDir, "mnt1"), path.Join(tmpDir, "mnt2")
|
mnt1, mnt2 := path.Join(tmpDir, "mnt1"), path.Join(tmpDir, "mnt2")
|
||||||
if err := os.Mkdir(mnt1, 0755); err != nil {
|
if err := os.Mkdir(mnt1, 0o755); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := os.Mkdir(mnt2, 0755); err != nil {
|
if err := os.Mkdir(mnt2, 0o755); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(path.Join(mnt1, "test1"), []byte("test1"), 0644); err != nil {
|
if err := os.WriteFile(path.Join(mnt1, "test1"), []byte("test1"), 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(path.Join(mnt2, "test2"), []byte("test2"), 0644); err != nil {
|
if err := os.WriteFile(path.Join(mnt2, "test2"), []byte("test2"), 0o644); err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
testCatFooBar := func(cName string) error {
|
testCatFooBar := func(cName string) error {
|
||||||
|
|
|
@ -68,7 +68,7 @@ func (s *DockerCLIRunSuite) TestRunWithVolumesIsRecursive(c *testing.T) {
|
||||||
|
|
||||||
// Create a temporary tmpfs mount.
|
// Create a temporary tmpfs mount.
|
||||||
tmpfsDir := filepath.Join(tmpDir, "tmpfs")
|
tmpfsDir := filepath.Join(tmpDir, "tmpfs")
|
||||||
assert.Assert(c, os.MkdirAll(tmpfsDir, 0777) == nil, "failed to mkdir at %s", tmpfsDir)
|
assert.Assert(c, os.MkdirAll(tmpfsDir, 0o777) == nil, "failed to mkdir at %s", tmpfsDir)
|
||||||
assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", "") == nil, "failed to create a tmpfs mount at %s", tmpfsDir)
|
assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", "") == nil, "failed to create a tmpfs mount at %s", tmpfsDir)
|
||||||
|
|
||||||
f, err := os.CreateTemp(tmpfsDir, "touch-me")
|
f, err := os.CreateTemp(tmpfsDir, "touch-me")
|
||||||
|
@ -247,7 +247,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachFromConfig(c *testing.T) {
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
dotDocker := filepath.Join(tmpDir, ".docker")
|
dotDocker := filepath.Join(tmpDir, ".docker")
|
||||||
os.Mkdir(dotDocker, 0600)
|
os.Mkdir(dotDocker, 0o600)
|
||||||
tmpCfg := filepath.Join(dotDocker, "config.json")
|
tmpCfg := filepath.Join(dotDocker, "config.json")
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
|
@ -260,7 +260,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachFromConfig(c *testing.T) {
|
||||||
"detachKeys": "ctrl-a,a"
|
"detachKeys": "ctrl-a,a"
|
||||||
}`
|
}`
|
||||||
|
|
||||||
err = os.WriteFile(tmpCfg, []byte(data), 0600)
|
err = os.WriteFile(tmpCfg, []byte(data), 0o600)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
// Then do the work
|
// Then do the work
|
||||||
|
@ -331,7 +331,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T)
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
dotDocker := filepath.Join(tmpDir, ".docker")
|
dotDocker := filepath.Join(tmpDir, ".docker")
|
||||||
os.Mkdir(dotDocker, 0600)
|
os.Mkdir(dotDocker, 0o600)
|
||||||
tmpCfg := filepath.Join(dotDocker, "config.json")
|
tmpCfg := filepath.Join(dotDocker, "config.json")
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
|
@ -344,7 +344,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T)
|
||||||
"detachKeys": "ctrl-e,e"
|
"detachKeys": "ctrl-e,e"
|
||||||
}`
|
}`
|
||||||
|
|
||||||
err = os.WriteFile(tmpCfg, []byte(data), 0600)
|
err = os.WriteFile(tmpCfg, []byte(data), 0o600)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
// Then do the work
|
// Then do the work
|
||||||
|
@ -1362,7 +1362,7 @@ func (s *DockerCLIRunSuite) TestRunDeviceSymlink(c *testing.T) {
|
||||||
// Create a temporary file "temp" inside tmpDir, write some data to "tmpDir/temp",
|
// Create a temporary file "temp" inside tmpDir, write some data to "tmpDir/temp",
|
||||||
// then create a symlink "tmpDir/file" to the temporary file "tmpDir/temp".
|
// then create a symlink "tmpDir/file" to the temporary file "tmpDir/temp".
|
||||||
tmpFile := filepath.Join(tmpDir, "temp")
|
tmpFile := filepath.Join(tmpDir, "temp")
|
||||||
err = os.WriteFile(tmpFile, []byte("temp"), 0666)
|
err = os.WriteFile(tmpFile, []byte("temp"), 0o666)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
symFile := filepath.Join(tmpDir, "file")
|
symFile := filepath.Join(tmpDir, "file")
|
||||||
err = os.Symlink(tmpFile, symFile)
|
err = os.Symlink(tmpFile, symFile)
|
||||||
|
|
|
@ -202,9 +202,7 @@ func (s *DockerCLISaveLoadSuite) TestSaveLoadParents(c *testing.T) {
|
||||||
testRequires(c, DaemonIsLinux)
|
testRequires(c, DaemonIsLinux)
|
||||||
|
|
||||||
makeImage := func(from string, addfile string) string {
|
makeImage := func(from string, addfile string) string {
|
||||||
var (
|
var out string
|
||||||
out string
|
|
||||||
)
|
|
||||||
out, _ = dockerCmd(c, "run", "-d", from, "touch", addfile)
|
out, _ = dockerCmd(c, "run", "-d", from, "touch", addfile)
|
||||||
cleanedContainerID := strings.TrimSpace(out)
|
cleanedContainerID := strings.TrimSpace(out)
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,6 @@ func (s *DockerCLISaveLoadSuite) TestLoadNoStdinFail(c *testing.T) {
|
||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
|
|
||||||
n, err := pty.Read(buf)
|
n, err := pty.Read(buf)
|
||||||
assert.NilError(c, err) //could not read tty output
|
assert.NilError(c, err) // could not read tty output
|
||||||
assert.Assert(c, strings.Contains(string(buf[:n]), "requested load from stdin, but stdin is empty"))
|
assert.Assert(c, strings.Contains(string(buf[:n]), "requested load from stdin, but stdin is empty"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -610,8 +610,10 @@ func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *testing.T) {
|
||||||
assert.Assert(c, lines[0] != bareID, "Expected not %s, but got it for is-task label, output %q", bareID, out)
|
assert.Assert(c, lines[0] != bareID, "Expected not %s, but got it for is-task label, output %q", bareID, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
const globalNetworkPlugin = "global-network-plugin"
|
const (
|
||||||
const globalIPAMPlugin = "global-ipam-plugin"
|
globalNetworkPlugin = "global-network-plugin"
|
||||||
|
globalIPAMPlugin = "global-ipam-plugin"
|
||||||
|
)
|
||||||
|
|
||||||
func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
||||||
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -664,7 +666,8 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
||||||
|
|
||||||
veth := &netlink.Veth{
|
veth := &netlink.Veth{
|
||||||
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0"}
|
LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
|
||||||
|
}
|
||||||
if err := netlink.LinkAdd(veth); err != nil {
|
if err := netlink.LinkAdd(veth); err != nil {
|
||||||
fmt.Fprintf(w, `{"Error":"failed to add veth pair: `+err.Error()+`"}`)
|
fmt.Fprintf(w, `{"Error":"failed to add veth pair: `+err.Error()+`"}`)
|
||||||
} else {
|
} else {
|
||||||
|
@ -768,15 +771,15 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
err := os.MkdirAll("/etc/docker/plugins", 0755)
|
err := os.MkdirAll("/etc/docker/plugins", 0o755)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv)
|
fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv)
|
||||||
err = os.WriteFile(fileName, []byte(url), 0644)
|
err = os.WriteFile(fileName, []byte(url), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv)
|
ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv)
|
||||||
err = os.WriteFile(ipamFileName, []byte(url), 0644)
|
err = os.WriteFile(ipamFileName, []byte(url), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,7 +806,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *testing.T) {
|
||||||
d := s.AddDaemon(c, true, true)
|
d := s.AddDaemon(c, true, true)
|
||||||
|
|
||||||
path := filepath.Join(d.Folder, "env.txt")
|
path := filepath.Join(d.Folder, "env.txt")
|
||||||
err := os.WriteFile(path, []byte("VAR1=A\nVAR2=A\n"), 0644)
|
err := os.WriteFile(path, []byte("VAR1=A\nVAR2=A\n"), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
name := "worker"
|
name := "worker"
|
||||||
|
|
|
@ -109,7 +109,7 @@ func (s *DockerCLIVolumeSuite) TestVolumeLsFormatDefaultFormat(c *testing.T) {
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer os.RemoveAll(d)
|
defer os.RemoveAll(d)
|
||||||
|
|
||||||
err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
|
err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
out, _ := dockerCmd(c, "--config", d, "volume", "ls")
|
out, _ := dockerCmd(c, "--config", d, "volume", "ls")
|
||||||
|
@ -567,7 +567,7 @@ func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c
|
||||||
out, _ = dockerCmd(c, "volume", "ls", "-q")
|
out, _ = dockerCmd(c, "volume", "ls", "-q")
|
||||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
|
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
|
||||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
|
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
|
||||||
err := os.MkdirAll("/tmp/data", 0755)
|
err := os.MkdirAll("/tmp/data", 0o755)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
// Mounts is available in API
|
// Mounts is available in API
|
||||||
apiClient, err := client.NewClientWithOpts(client.FromEnv)
|
apiClient, err := client.NewClientWithOpts(client.FromEnv)
|
||||||
|
|
|
@ -186,8 +186,8 @@ func buildImage(name string, cmdOperators ...cli.CmdOperator) *icmd.Result {
|
||||||
func writeFile(dst, content string, c *testing.T) {
|
func writeFile(dst, content string, c *testing.T) {
|
||||||
c.Helper()
|
c.Helper()
|
||||||
// Create subdirectories if necessary
|
// Create subdirectories if necessary
|
||||||
assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700) == nil)
|
assert.Assert(c, os.MkdirAll(path.Dir(dst), 0o700) == nil)
|
||||||
f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0700)
|
f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o700)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
// Write content (truncate if it exists)
|
// Write content (truncate if it exists)
|
||||||
|
@ -302,7 +302,7 @@ func createTmpFile(c *testing.T, content string) string {
|
||||||
|
|
||||||
filename := f.Name()
|
filename := f.Name()
|
||||||
|
|
||||||
err = os.WriteFile(filename, []byte(content), 0644)
|
err = os.WriteFile(filename, []byte(content), 0o644)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
@ -403,8 +403,10 @@ func getErrorMessage(c *testing.T, body []byte) string {
|
||||||
return strings.TrimSpace(resp.Message)
|
return strings.TrimSpace(resp.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
type checkF func(*testing.T) (interface{}, string)
|
type (
|
||||||
type reducer func(...interface{}) interface{}
|
checkF func(*testing.T) (interface{}, string)
|
||||||
|
reducer func(...interface{}) interface{}
|
||||||
|
)
|
||||||
|
|
||||||
func pollCheck(t *testing.T, f checkF, compare func(x interface{}) assert.BoolOrComparison) poll.Check {
|
func pollCheck(t *testing.T, f checkF, compare func(x interface{}) assert.BoolOrComparison) poll.Check {
|
||||||
return func(poll.LogT) poll.Result {
|
return func(poll.LogT) poll.Result {
|
||||||
|
|
|
@ -7,10 +7,8 @@ import (
|
||||||
"github.com/docker/docker/testutil/environment"
|
"github.com/docker/docker/testutil/environment"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// DefaultClientBinary is the name of the docker binary
|
||||||
// DefaultClientBinary is the name of the docker binary
|
var DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
|
||||||
DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if DefaultClientBinary == "" {
|
if DefaultClientBinary == "" {
|
||||||
|
|
|
@ -51,7 +51,7 @@ func ensureSyscallTest(c *testing.T) {
|
||||||
FROM debian:bullseye-slim
|
FROM debian:bullseye-slim
|
||||||
COPY . /usr/bin/
|
COPY . /usr/bin/
|
||||||
`)
|
`)
|
||||||
err = os.WriteFile(dockerFile, content, 0600)
|
err = os.WriteFile(dockerFile, content, 0o600)
|
||||||
assert.NilError(c, err)
|
assert.NilError(c, err)
|
||||||
|
|
||||||
var buildArgs []string
|
var buildArgs []string
|
||||||
|
@ -106,7 +106,7 @@ func ensureNNPTest(c *testing.T) {
|
||||||
COPY . /usr/bin
|
COPY . /usr/bin
|
||||||
RUN chmod +s /usr/bin/nnp-test
|
RUN chmod +s /usr/bin/nnp-test
|
||||||
`
|
`
|
||||||
err = os.WriteFile(dockerfile, []byte(content), 0600)
|
err = os.WriteFile(dockerfile, []byte(content), 0o600)
|
||||||
assert.NilError(c, err, "could not write Dockerfile for nnp-test image")
|
assert.NilError(c, err, "could not write Dockerfile for nnp-test image")
|
||||||
|
|
||||||
var buildArgs []string
|
var buildArgs []string
|
||||||
|
|
|
@ -11,10 +11,8 @@ import (
|
||||||
"github.com/docker/docker/pkg/sysinfo"
|
"github.com/docker/docker/pkg/sysinfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// SysInfo stores information about which features a kernel supports.
|
||||||
// SysInfo stores information about which features a kernel supports.
|
var SysInfo *sysinfo.SysInfo
|
||||||
SysInfo *sysinfo.SysInfo
|
|
||||||
)
|
|
||||||
|
|
||||||
func cpuCfsPeriod() bool {
|
func cpuCfsPeriod() bool {
|
||||||
return testEnv.DaemonInfo.CPUCfsPeriod
|
return testEnv.DaemonInfo.CPUCfsPeriod
|
||||||
|
|
Loading…
Reference in a new issue