summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-01 16:20:41 +0200
committerGitHub <noreply@github.com>2019-05-01 16:20:41 +0200
commitad68036a88e35dc3c7a19962b8e21867b459f8f1 (patch)
treeb3854bdbf0971e58b85bdd039ea447ef6390d933 /utils
parenteea77b5ae3e7fb8a60d438a79d3a4b30d35bb67c (diff)
parent0b6bb6a3d3c3c15b9c6629a6949a616a30b0478a (diff)
downloadpodman-ad68036a88e35dc3c7a19962b8e21867b459f8f1.tar.gz
podman-ad68036a88e35dc3c7a19962b8e21867b459f8f1.tar.bz2
podman-ad68036a88e35dc3c7a19962b8e21867b459f8f1.zip
Merge pull request #3031 from baude/remotewindows
enable podman-remote on windows
Diffstat (limited to 'utils')
-rw-r--r--utils/utils.go33
-rw-r--r--utils/utils_supported.go39
-rw-r--r--utils/utils_windows.go9
3 files changed, 48 insertions, 33 deletions
diff --git a/utils/utils.go b/utils/utils.go
index c195daa5d..86adfb967 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -9,8 +9,6 @@ import (
"strings"
"github.com/containers/storage/pkg/archive"
- systemdDbus "github.com/coreos/go-systemd/dbus"
- "github.com/godbus/dbus"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -55,37 +53,6 @@ func StatusToExitCode(status int) int {
return ((status) & 0xff00) >> 8
}
-// RunUnderSystemdScope adds the specified pid to a systemd scope
-func RunUnderSystemdScope(pid int, slice string, unitName string) error {
- var properties []systemdDbus.Property
- conn, err := systemdDbus.New()
- if err != nil {
- return err
- }
- properties = append(properties, systemdDbus.PropSlice(slice))
- properties = append(properties, newProp("PIDs", []uint32{uint32(pid)}))
- properties = append(properties, newProp("Delegate", true))
- properties = append(properties, newProp("DefaultDependencies", false))
- ch := make(chan string)
- _, err = conn.StartTransientUnit(unitName, "replace", properties, ch)
- if err != nil {
- return err
- }
- defer conn.Close()
-
- // Block until job is started
- <-ch
-
- return nil
-}
-
-func newProp(name string, units interface{}) systemdDbus.Property {
- return systemdDbus.Property{
- Name: name,
- Value: dbus.MakeVariant(units),
- }
-}
-
// ErrDetach is an error indicating that the user manually detached from the
// container.
var ErrDetach = errors.New("detached from container")
diff --git a/utils/utils_supported.go b/utils/utils_supported.go
new file mode 100644
index 000000000..8b0ba4438
--- /dev/null
+++ b/utils/utils_supported.go
@@ -0,0 +1,39 @@
+// +build linux darwin
+
+package utils
+
+import (
+ systemdDbus "github.com/coreos/go-systemd/dbus"
+ "github.com/godbus/dbus"
+)
+
+// RunUnderSystemdScope adds the specified pid to a systemd scope
+func RunUnderSystemdScope(pid int, slice string, unitName string) error {
+ var properties []systemdDbus.Property
+ conn, err := systemdDbus.New()
+ if err != nil {
+ return err
+ }
+ properties = append(properties, systemdDbus.PropSlice(slice))
+ properties = append(properties, newProp("PIDs", []uint32{uint32(pid)}))
+ properties = append(properties, newProp("Delegate", true))
+ properties = append(properties, newProp("DefaultDependencies", false))
+ ch := make(chan string)
+ _, err = conn.StartTransientUnit(unitName, "replace", properties, ch)
+ if err != nil {
+ return err
+ }
+ defer conn.Close()
+
+ // Block until job is started
+ <-ch
+
+ return nil
+}
+
+func newProp(name string, units interface{}) systemdDbus.Property {
+ return systemdDbus.Property{
+ Name: name,
+ Value: dbus.MakeVariant(units),
+ }
+}
diff --git a/utils/utils_windows.go b/utils/utils_windows.go
new file mode 100644
index 000000000..db27877d9
--- /dev/null
+++ b/utils/utils_windows.go
@@ -0,0 +1,9 @@
+// +build windows
+
+package utils
+
+import "github.com/pkg/errors"
+
+func RunUnderSystemdScope(pid int, slice string, unitName string) error {
+ return errors.New("not implemented for windows")
+}