summaryrefslogtreecommitdiff
path: root/pkg/spec/parse.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-07-23 12:37:29 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-24 21:50:49 +0000
commit41c7e43b4dbba117d41d82cd8d5c0f004daba21e (patch)
tree15fee619996c847b99e19321485e49308aeec7f6 /pkg/spec/parse.go
parent6f65490e274e5cde5f5cb616719ea27932a764ee (diff)
downloadpodman-41c7e43b4dbba117d41d82cd8d5c0f004daba21e.tar.gz
podman-41c7e43b4dbba117d41d82cd8d5c0f004daba21e.tar.bz2
podman-41c7e43b4dbba117d41d82cd8d5c0f004daba21e.zip
network: support ns: prefix to join existing namespace
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1145 Approved by: rhatdan
Diffstat (limited to 'pkg/spec/parse.go')
-rw-r--r--pkg/spec/parse.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/spec/parse.go b/pkg/spec/parse.go
index 82ca92dff..d4a655e4f 100644
--- a/pkg/spec/parse.go
+++ b/pkg/spec/parse.go
@@ -18,6 +18,21 @@ func (w *weightDevice) String() string {
return fmt.Sprintf("%s:%d", w.path, w.weight)
}
+// IsNS returns if the specified string has a ns: prefix
+func IsNS(s string) bool {
+ parts := strings.SplitN(s, ":", 2)
+ return len(parts) > 1 && parts[0] == "ns"
+}
+
+// NS is the path to the namespace to join.
+func NS(s string) string {
+ parts := strings.SplitN(s, ":", 2)
+ if len(parts) > 1 {
+ return parts[1]
+ }
+ return ""
+}
+
// validateweightDevice validates that the specified string has a valid device-weight format
// for blkio-weight-device flag
func validateweightDevice(val string) (*weightDevice, error) {