mirror of https://github.com/containers/podman.git
Merge pull request #24542 from ksw2000/refactor-linuxns-string
refactor: simplify LinuxNS type definition and String method
This commit is contained in:
commit
da8995658b
|
@ -47,44 +47,38 @@ const (
|
||||||
// InvalidNS is an invalid namespace
|
// InvalidNS is an invalid namespace
|
||||||
InvalidNS LinuxNS = iota
|
InvalidNS LinuxNS = iota
|
||||||
// IPCNS is the IPC namespace
|
// IPCNS is the IPC namespace
|
||||||
IPCNS LinuxNS = iota
|
IPCNS
|
||||||
// MountNS is the mount namespace
|
// MountNS is the mount namespace
|
||||||
MountNS LinuxNS = iota
|
MountNS
|
||||||
// NetNS is the network namespace
|
// NetNS is the network namespace
|
||||||
NetNS LinuxNS = iota
|
NetNS
|
||||||
// PIDNS is the PID namespace
|
// PIDNS is the PID namespace
|
||||||
PIDNS LinuxNS = iota
|
PIDNS
|
||||||
// UserNS is the user namespace
|
// UserNS is the user namespace
|
||||||
UserNS LinuxNS = iota
|
UserNS
|
||||||
// UTSNS is the UTS namespace
|
// UTSNS is the UTS namespace
|
||||||
UTSNS LinuxNS = iota
|
UTSNS
|
||||||
// CgroupNS is the Cgroup namespace
|
// CgroupNS is the Cgroup namespace
|
||||||
CgroupNS LinuxNS = iota
|
CgroupNS
|
||||||
)
|
)
|
||||||
|
|
||||||
// String returns a string representation of a Linux namespace
|
// String returns a string representation of a Linux namespace
|
||||||
// It is guaranteed to be the name of the namespace in /proc for valid ns types
|
// It is guaranteed to be the name of the namespace in /proc for valid ns types
|
||||||
func (ns LinuxNS) String() string {
|
func (ns LinuxNS) String() string {
|
||||||
switch ns {
|
s := [...]string{
|
||||||
case InvalidNS:
|
InvalidNS: "invalid",
|
||||||
return "invalid"
|
IPCNS: "ipc",
|
||||||
case IPCNS:
|
MountNS: "mnt",
|
||||||
return "ipc"
|
NetNS: "net",
|
||||||
case MountNS:
|
PIDNS: "pid",
|
||||||
return "mnt"
|
UserNS: "user",
|
||||||
case NetNS:
|
UTSNS: "uts",
|
||||||
return "net"
|
CgroupNS: "cgroup",
|
||||||
case PIDNS:
|
|
||||||
return "pid"
|
|
||||||
case UserNS:
|
|
||||||
return "user"
|
|
||||||
case UTSNS:
|
|
||||||
return "uts"
|
|
||||||
case CgroupNS:
|
|
||||||
return "cgroup"
|
|
||||||
default:
|
|
||||||
return "unknown"
|
|
||||||
}
|
}
|
||||||
|
if ns >= 0 && int(ns) < len(s) {
|
||||||
|
return s[ns]
|
||||||
|
}
|
||||||
|
return "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container is a single OCI container.
|
// Container is a single OCI container.
|
||||||
|
|
Loading…
Reference in New Issue