From 092902b455551d7353163c1e6d322f3605b9a897 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 29 Jun 2021 14:18:46 -0400 Subject: Handle advanced --network options in podman play kube Since Podman create/run can support this, so should play. Fixes: https://github.com/containers/podman/issues/10807 Signed-off-by: Daniel J Walsh --- pkg/specgen/namespaces.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'pkg/specgen') diff --git a/pkg/specgen/namespaces.go b/pkg/specgen/namespaces.go index 80852930a..76fa66bc7 100644 --- a/pkg/specgen/namespaces.go +++ b/pkg/specgen/namespaces.go @@ -68,6 +68,11 @@ func (n *Namespace) IsHost() bool { return n.NSMode == Host } +// IsBridge returns a bool if the namespace is a Bridge +func (n *Namespace) IsBridge() bool { + return n.NSMode == Bridge +} + // IsPath indicates via bool if the namespace is based on a path func (n *Namespace) IsPath() bool { return n.NSMode == Path @@ -301,3 +306,20 @@ func ParseNetworkNamespace(ns string, rootlessDefaultCNI bool) (Namespace, []str return toReturn, cniNetworks, nil } + +func ParseNetworkString(network string) (Namespace, []string, map[string][]string, error) { + var networkOptions map[string][]string + parts := strings.SplitN(network, ":", 2) + + ns, cniNets, err := ParseNetworkNamespace(network, containerConfig.Containers.RootlessNetworking == "cni") + if err != nil { + return Namespace{}, nil, nil, err + } + + if len(parts) > 1 { + networkOptions = make(map[string][]string) + networkOptions[parts[0]] = strings.Split(parts[1], ",") + cniNets = nil + } + return ns, cniNets, networkOptions, nil +} -- cgit v1.2.3-54-g00ecf