mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
enable podman-remote on windows
build a podman-remote binary for windows that allows users to use the remote client on windows and interact with podman on linux system. Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
@@ -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")
|
||||
|
||||
39
utils/utils_supported.go
Normal file
39
utils/utils_supported.go
Normal file
@@ -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),
|
||||
}
|
||||
}
|
||||
9
utils/utils_windows.go
Normal file
9
utils/utils_windows.go
Normal file
@@ -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")
|
||||
}
|
||||
Reference in New Issue
Block a user