Browse code

integration/network: remove IsUserNamespace in favor of testenv equivalent

We're already using testenv here, so might as well use the exact same
function that it provides.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2021/08/12 16:12:04
Showing 4 changed files
... ...
@@ -16,7 +16,7 @@ import (
16 16
 func TestDaemonDNSFallback(t *testing.T) {
17 17
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
18 18
 	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
19
-	skip.If(t, IsUserNamespace())
19
+	skip.If(t, testEnv.IsUserNamespace)
20 20
 
21 21
 	d := daemon.New(t)
22 22
 	d.StartWithBusybox(t, "-b", "none", "--dns", "127.127.127.1", "--dns", "8.8.8.8")
... ...
@@ -5,7 +5,6 @@ package network
5 5
 import (
6 6
 	"context"
7 7
 	"fmt"
8
-	"os"
9 8
 	"testing"
10 9
 
11 10
 	"github.com/docker/docker/api/types"
... ...
@@ -86,9 +85,3 @@ func CheckKernelMajorVersionGreaterOrEqualThen(kernelVersion int, majorVersion i
86 86
 	}
87 87
 	return true
88 88
 }
89
-
90
-// IsUserNamespace returns whether the user namespace remapping is enabled
91
-func IsUserNamespace() bool {
92
-	root := os.Getenv("DOCKER_REMAP_ROOT")
93
-	return root != ""
94
-}
... ...
@@ -3,7 +3,6 @@ package network
3 3
 import (
4 4
 	"context"
5 5
 	"fmt"
6
-	"os"
7 6
 
8 7
 	"github.com/docker/docker/api/types"
9 8
 	"github.com/docker/docker/client"
... ...
@@ -41,9 +40,3 @@ func IsNetworkNotAvailable(c client.NetworkAPIClient, name string) cmp.Compariso
41 41
 		return cmp.ResultSuccess
42 42
 	}
43 43
 }
44
-
45
-// IsUserNamespace returns whether the user namespace remapping is enabled
46
-func IsUserNamespace() bool {
47
-	root := os.Getenv("DOCKER_REMAP_ROOT")
48
-	return root != ""
49
-}
... ...
@@ -23,7 +23,7 @@ import (
23 23
 func TestRunContainerWithBridgeNone(t *testing.T) {
24 24
 	skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
25 25
 	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
26
-	skip.If(t, IsUserNamespace())
26
+	skip.If(t, testEnv.IsUserNamespace)
27 27
 	skip.If(t, testEnv.IsRootless, "rootless mode has different view of network")
28 28
 
29 29
 	d := daemon.New(t)