Skip to content

Commit 1fb00d9

Browse files
author
Dongsu Park
committed
validation: use helper util.GetRuntimeToolsNamespaces()
We should use an existing helper `util.GetRuntimeToolsNamespaces()` instead of writing an internal function again. Signed-off-by: Dongsu Park <[email protected]>
1 parent 0f52f9a commit 1fb00d9

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

validation/linux_ns_path.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ import (
1414
"github.com/opencontainers/runtime-tools/validation/util"
1515
)
1616

17-
func getRuntimeToolsNamespace(ns string) string {
18-
// Deal with exceptional cases of "net" and "mnt", because those strings
19-
// cannot be recognized by mapStrToNamespace(), which actually expects
20-
// "network" and "mount" respectively.
21-
switch ns {
22-
case "net":
23-
return "network"
24-
case "mnt":
25-
return "mount"
26-
}
27-
28-
// In other cases, return just the original string
29-
return ns
30-
}
31-
3217
func waitForState(stateCheckFunc func() error) error {
3318
timeout := 3 * time.Second
3419
alarm := time.After(timeout)
@@ -104,7 +89,7 @@ func checkNamespacePath(unsharePid int, ns string) error {
10489
return fmt.Errorf("cannot get the default generator: %v", err)
10590
}
10691

107-
rtns := getRuntimeToolsNamespace(ns)
92+
rtns := util.GetRuntimeToolsNamespace(ns)
10893
g.AddOrReplaceLinuxNamespace(rtns, unshareNsPath)
10994

11095
return util.RuntimeOutsideValidate(g, func(config *rspec.Spec, state *rspec.State) error {

validation/linux_ns_path_type.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,6 @@ import (
1212
"github.com/opencontainers/runtime-tools/validation/util"
1313
)
1414

15-
func getRuntimeToolsNamespace(ns string) string {
16-
// Deal with exceptional cases of "net" and "mnt", because those strings
17-
// cannot be recognized by mapStrToNamespace(), which actually expects
18-
// "network" and "mount" respectively.
19-
switch ns {
20-
case "net":
21-
return "network"
22-
case "mnt":
23-
return "mount"
24-
}
25-
26-
// In other cases, return just the original string
27-
return ns
28-
}
29-
3015
func checkNSPathMatchType(t *tap.T, ns, wrongNs string) error {
3116
// Deliberately set ns path with a wrong namespace, to check if the runtime
3217
// returns error when running with the wrong namespace path.
@@ -37,7 +22,7 @@ func checkNSPathMatchType(t *tap.T, ns, wrongNs string) error {
3722
return fmt.Errorf("cannot get default config from generator: %v", err)
3823
}
3924

40-
rtns := getRuntimeToolsNamespace(ns)
25+
rtns := util.GetRuntimeToolsNamespace(ns)
4126
g.AddOrReplaceLinuxNamespace(rtns, unshareNsPath)
4227

4328
err = util.RuntimeOutsideValidate(g, nil)

0 commit comments

Comments
 (0)