mirror of
https://github.com/containers/podman.git
synced 2026-07-09 14:54:59 -04:00
pkg/namespaces: fix NetworkMode IsNS and IsUserDefined
NetworkMode.IsNS matched any value starting with "ns" (e.g. a network named "nsproxy"), unlike UsernsMode.IsNS which requires the "ns:" prefix; require it. IsUserDefined also did not exclude pod, so a pod network was reported as user-defined; exclude it. Signed-off-by: ROKUMATE <rohitkumawat0110@gmail.com>
This commit is contained in:
@@ -208,7 +208,7 @@ func (n NetworkMode) IsPasta() bool {
|
||||
|
||||
// IsNS indicates a network namespace passed in by path (ns:<path>)
|
||||
func (n NetworkMode) IsNS() bool {
|
||||
return strings.HasPrefix(string(n), nsType)
|
||||
return strings.HasPrefix(string(n), nsType+":")
|
||||
}
|
||||
|
||||
// NS gets the path associated with a ns:<path> network ns
|
||||
@@ -224,5 +224,5 @@ func (n NetworkMode) IsPod() bool {
|
||||
|
||||
// IsUserDefined indicates user-created network
|
||||
func (n NetworkMode) IsUserDefined() bool {
|
||||
return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() && !n.IsPasta() && !n.IsNS()
|
||||
return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() && !n.IsPasta() && !n.IsNS() && !n.IsPod()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user