mirror of
https://github.com/containers/podman.git
synced 2025-05-21 17:16:22 +08:00
Add darwin support for remote-client
Add the ability to cross-compile podman remote for OSX. Also, add image exists and tag to remote-client. Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
5
Makefile
5
Makefile
@ -1,6 +1,6 @@
|
|||||||
GO ?= go
|
GO ?= go
|
||||||
DESTDIR ?= /
|
DESTDIR ?= /
|
||||||
EPOCH_TEST_COMMIT ?= e1732a5213147e3c0b7bf60b55a332c3720ecb4b
|
EPOCH_TEST_COMMIT ?= bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87
|
||||||
HEAD ?= HEAD
|
HEAD ?= HEAD
|
||||||
CHANGELOG_BASE ?= HEAD~
|
CHANGELOG_BASE ?= HEAD~
|
||||||
CHANGELOG_TARGET ?= HEAD
|
CHANGELOG_TARGET ?= HEAD
|
||||||
@ -109,6 +109,9 @@ podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
|
|||||||
podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
|
podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
|
||||||
$(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS) remoteclient" -o bin/$@ $(PROJECT)/cmd/podman
|
$(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS) remoteclient" -o bin/$@ $(PROJECT)/cmd/podman
|
||||||
|
|
||||||
|
podman-remote-darwin: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
|
||||||
|
GOOS=darwin $(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "remoteclient containers_image_openpgp exclude_graphdriver_devicemapper" -o bin/$@ $(PROJECT)/cmd/podman
|
||||||
|
|
||||||
local-cross: $(CROSS_BUILD_TARGETS)
|
local-cross: $(CROSS_BUILD_TARGETS)
|
||||||
|
|
||||||
bin/podman.cross.%: .gopathok
|
bin/podman.cross.%: .gopathok
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/libpodruntime"
|
"github.com/containers/libpod/cmd/podman/libpodruntime"
|
||||||
"github.com/containers/libpod/libpod"
|
"github.com/containers/libpod/libpod"
|
||||||
|
"github.com/containers/libpod/libpod/adapter"
|
||||||
"github.com/containers/libpod/libpod/image"
|
"github.com/containers/libpod/libpod/image"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@ -66,13 +67,15 @@ func imageExistsCmd(c *cli.Context) error {
|
|||||||
if len(args) > 1 || len(args) < 1 {
|
if len(args) > 1 || len(args) < 1 {
|
||||||
return errors.New("you may only check for the existence of one image at a time")
|
return errors.New("you may only check for the existence of one image at a time")
|
||||||
}
|
}
|
||||||
runtime, err := libpodruntime.GetRuntime(c)
|
localRuntime, err := adapter.GetRuntime(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not get runtime")
|
return errors.Wrapf(err, "could not get runtime")
|
||||||
}
|
}
|
||||||
defer runtime.Shutdown(false)
|
defer localRuntime.Runtime.Shutdown(false)
|
||||||
if _, err := runtime.ImageRuntime().NewFromLocal(args[0]); err != nil {
|
if _, err := localRuntime.NewImageFromLocal(args[0]); err != nil {
|
||||||
if errors.Cause(err) == image.ErrNoSuchImage {
|
//TODO we need to ask about having varlink defined errors exposed
|
||||||
|
//so we can reuse them
|
||||||
|
if errors.Cause(err) == image.ErrNoSuchImage || err.Error() == "io.podman.ImageNotFound" {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -120,7 +120,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
if args.Present() {
|
if args.Present() && rootless.IsRootless() {
|
||||||
if _, notRequireRootless := cmdsNotRequiringRootless[args.First()]; !notRequireRootless {
|
if _, notRequireRootless := cmdsNotRequiringRootless[args.First()]; !notRequireRootless {
|
||||||
became, ret, err := rootless.BecomeRootInUserNS()
|
became, ret, err := rootless.BecomeRootInUserNS()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -265,11 +265,10 @@ func main() {
|
|||||||
Usage: "output logging information to syslog as well as the console",
|
Usage: "output logging information to syslog as well as the console",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if _, err := os.Stat("/etc/containers/registries.conf"); err != nil {
|
// Check if /etc/containers/registries.conf exists when running in
|
||||||
if os.IsNotExist(err) {
|
// in a local environment.
|
||||||
logrus.Warn("unable to find /etc/containers/registries.conf. some podman (image shortnames) commands may be limited")
|
CheckForRegistries()
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
if debug {
|
if debug {
|
||||||
logrus.Errorf(err.Error())
|
logrus.Errorf(err.Error())
|
||||||
|
17
cmd/podman/platform_linux.go
Normal file
17
cmd/podman/platform_linux.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CheckForRegistries() {
|
||||||
|
if _, err := os.Stat("/etc/containers/registries.conf"); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
logrus.Warn("unable to find /etc/containers/registries.conf. some podman (image shortnames) commands may be limited")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
cmd/podman/platform_unsupported.go
Normal file
6
cmd/podman/platform_unsupported.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build !linux
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func CheckForRegistries() {
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/containers/libpod/cmd/podman/libpodruntime"
|
"github.com/containers/libpod/libpod/adapter"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -23,13 +23,13 @@ func tagCmd(c *cli.Context) error {
|
|||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
return errors.Errorf("image name and at least one new name must be specified")
|
return errors.Errorf("image name and at least one new name must be specified")
|
||||||
}
|
}
|
||||||
runtime, err := libpodruntime.GetRuntime(c)
|
localRuntime, err := adapter.GetRuntime(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not create runtime")
|
return errors.Wrapf(err, "could not create runtime")
|
||||||
}
|
}
|
||||||
defer runtime.Shutdown(false)
|
defer localRuntime.Runtime.Shutdown(false)
|
||||||
|
|
||||||
newImage, err := runtime.ImageRuntime().NewFromLocal(args[0])
|
newImage, err := localRuntime.NewImageFromLocal(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ type remoteImage struct {
|
|||||||
Names []string
|
Names []string
|
||||||
Digest digest.Digest
|
Digest digest.Digest
|
||||||
isParent bool
|
isParent bool
|
||||||
|
Runtime *LocalRuntime
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetImages returns a slice of containerimages over a varlink connection
|
// GetImages returns a slice of containerimages over a varlink connection
|
||||||
@ -80,7 +81,7 @@ func (r *LocalRuntime) GetImages() ([]*ContainerImage, error) {
|
|||||||
if len(i.RepoTags) > 1 {
|
if len(i.RepoTags) > 1 {
|
||||||
name = i.RepoTags[0]
|
name = i.RepoTags[0]
|
||||||
}
|
}
|
||||||
newImage, err := imageInListToContainerImage(i, name)
|
newImage, err := imageInListToContainerImage(i, name, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -89,7 +90,7 @@ func (r *LocalRuntime) GetImages() ([]*ContainerImage, error) {
|
|||||||
return newImages, nil
|
return newImages, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func imageInListToContainerImage(i iopodman.ImageInList, name string) (*ContainerImage, error) {
|
func imageInListToContainerImage(i iopodman.ImageInList, name string, runtime *LocalRuntime) (*ContainerImage, error) {
|
||||||
imageParts, err := image.DecomposeString(name)
|
imageParts, err := image.DecomposeString(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -111,6 +112,7 @@ func imageInListToContainerImage(i iopodman.ImageInList, name string) (*Containe
|
|||||||
Repository: imageParts.Registry,
|
Repository: imageParts.Registry,
|
||||||
Names: i.RepoTags,
|
Names: i.RepoTags,
|
||||||
isParent: i.IsParent,
|
isParent: i.IsParent,
|
||||||
|
Runtime: runtime,
|
||||||
}
|
}
|
||||||
return &ContainerImage{ri}, nil
|
return &ContainerImage{ri}, nil
|
||||||
}
|
}
|
||||||
@ -121,7 +123,7 @@ func (r *LocalRuntime) NewImageFromLocal(name string) (*ContainerImage, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return imageInListToContainerImage(img, name)
|
return imageInListToContainerImage(img, name, r)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,3 +175,13 @@ func (ci *ContainerImage) Labels(ctx context.Context) (map[string]string, error)
|
|||||||
func (ci *ContainerImage) Dangling() bool {
|
func (ci *ContainerImage) Dangling() bool {
|
||||||
return len(ci.Names()) == 0
|
return len(ci.Names()) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TagImage ...
|
||||||
|
func (ci *ContainerImage) TagImage(tag string) error {
|
||||||
|
_, err := iopodman.TagImage().Call(ci.Runtime.Conn, ci.ID(), tag)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r RemoteRuntime) RemoveImage(force bool) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@ package libpod
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -413,6 +414,25 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user, workDir
|
|||||||
return waitErr
|
return waitErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AttachStreams contains streams that will be attached to the container
|
||||||
|
type AttachStreams struct {
|
||||||
|
// OutputStream will be attached to container's STDOUT
|
||||||
|
OutputStream io.WriteCloser
|
||||||
|
// ErrorStream will be attached to container's STDERR
|
||||||
|
ErrorStream io.WriteCloser
|
||||||
|
// InputStream will be attached to container's STDIN
|
||||||
|
InputStream io.Reader
|
||||||
|
// AttachOutput is whether to attach to STDOUT
|
||||||
|
// If false, stdout will not be attached
|
||||||
|
AttachOutput bool
|
||||||
|
// AttachError is whether to attach to STDERR
|
||||||
|
// If false, stdout will not be attached
|
||||||
|
AttachError bool
|
||||||
|
// AttachInput is whether to attach to STDIN
|
||||||
|
// If false, stdout will not be attached
|
||||||
|
AttachInput bool
|
||||||
|
}
|
||||||
|
|
||||||
// Attach attaches to a container
|
// Attach attaches to a container
|
||||||
func (c *Container) Attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize) error {
|
func (c *Container) Attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize) error {
|
||||||
if !c.batched {
|
if !c.batched {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
//+build linux
|
||||||
|
|
||||||
package libpod
|
package libpod
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -27,25 +29,6 @@ const (
|
|||||||
AttachPipeStderr = 3
|
AttachPipeStderr = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// AttachStreams contains streams that will be attached to the container
|
|
||||||
type AttachStreams struct {
|
|
||||||
// OutputStream will be attached to container's STDOUT
|
|
||||||
OutputStream io.WriteCloser
|
|
||||||
// ErrorStream will be attached to container's STDERR
|
|
||||||
ErrorStream io.WriteCloser
|
|
||||||
// InputStream will be attached to container's STDIN
|
|
||||||
InputStream io.Reader
|
|
||||||
// AttachOutput is whether to attach to STDOUT
|
|
||||||
// If false, stdout will not be attached
|
|
||||||
AttachOutput bool
|
|
||||||
// AttachError is whether to attach to STDERR
|
|
||||||
// If false, stdout will not be attached
|
|
||||||
AttachError bool
|
|
||||||
// AttachInput is whether to attach to STDIN
|
|
||||||
// If false, stdout will not be attached
|
|
||||||
AttachInput bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach to the given container
|
// Attach to the given container
|
||||||
// Does not check if state is appropriate
|
// Does not check if state is appropriate
|
||||||
func (c *Container) attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize, startContainer bool) error {
|
func (c *Container) attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize, startContainer bool) error {
|
11
libpod/container_attach_unsupported.go
Normal file
11
libpod/container_attach_unsupported.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//+build !linux
|
||||||
|
|
||||||
|
package libpod
|
||||||
|
|
||||||
|
import (
|
||||||
|
"k8s.io/client-go/tools/remotecommand"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *Container) attach(streams *AttachStreams, keys string, resize <-chan remotecommand.TerminalSize, startContainer bool) error {
|
||||||
|
return ErrNotImplemented
|
||||||
|
}
|
@ -9,12 +9,12 @@ import "fmt"
|
|||||||
type SHMLockManager struct{}
|
type SHMLockManager struct{}
|
||||||
|
|
||||||
// NewSHMLockManager is not supported on this platform
|
// NewSHMLockManager is not supported on this platform
|
||||||
func NewSHMLockManager(numLocks uint32) (Manager, error) {
|
func NewSHMLockManager(path string, numLocks uint32) (Manager, error) {
|
||||||
return nil, fmt.Errorf("not supported")
|
return nil, fmt.Errorf("not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenSHMLockManager is not supported on this platform
|
// OpenSHMLockManager is not supported on this platform
|
||||||
func OpenSHMLockManager(numLocks uint32) (Manager, error) {
|
func OpenSHMLockManager(path string, numLocks uint32) (Manager, error) {
|
||||||
return nil, fmt.Errorf("not supported")
|
return nil, fmt.Errorf("not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
libpod/runtime_volume_unsupported.go
Normal file
19
libpod/runtime_volume_unsupported.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// +build !linux
|
||||||
|
|
||||||
|
package libpod
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r *Runtime) removeVolume(ctx context.Context, v *Volume, force, prune bool) error {
|
||||||
|
return ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Runtime) newVolume(ctx context.Context, options ...VolumeCreateOption) (*Volume, error) {
|
||||||
|
return nil, ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Runtime) NewVolume(ctx context.Context, options ...VolumeCreateOption) (*Volume, error) {
|
||||||
|
return nil, ErrNotImplemented
|
||||||
|
}
|
@ -14,7 +14,7 @@ func IsRootless() bool {
|
|||||||
// BecomeRootInUserNS is a stub function that always returns false and an
|
// BecomeRootInUserNS is a stub function that always returns false and an
|
||||||
// error on unsupported OS's
|
// error on unsupported OS's
|
||||||
func BecomeRootInUserNS() (bool, int, error) {
|
func BecomeRootInUserNS() (bool, int, error) {
|
||||||
return false, -1, errors.New("this function is not supported on this os")
|
return false, -1, errors.New("this function is not supported on this os1")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRootlessUID returns the UID of the user in the parent userNS
|
// GetRootlessUID returns the UID of the user in the parent userNS
|
||||||
@ -34,11 +34,18 @@ func SkipStorageSetup() bool {
|
|||||||
// JoinNS re-exec podman in a new userNS and join the user namespace of the specified
|
// JoinNS re-exec podman in a new userNS and join the user namespace of the specified
|
||||||
// PID.
|
// PID.
|
||||||
func JoinNS(pid uint) (bool, int, error) {
|
func JoinNS(pid uint) (bool, int, error) {
|
||||||
return false, -1, errors.New("this function is not supported on this os")
|
return false, -1, errors.New("this function is not supported on this os2")
|
||||||
}
|
}
|
||||||
|
|
||||||
// JoinNSPath re-exec podman in a new userNS and join the owner user namespace of the
|
// JoinNSPath re-exec podman in a new userNS and join the owner user namespace of the
|
||||||
// specified path.
|
// specified path.
|
||||||
func JoinNSPath(path string) (bool, int, error) {
|
func JoinNSPath(path string) (bool, int, error) {
|
||||||
return false, -1, errors.New("this function is not supported on this os")
|
return false, -1, errors.New("this function is not supported on this os3")
|
||||||
|
}
|
||||||
|
|
||||||
|
// JoinDirectUserAndMountNS re-exec podman in a new userNS and join the user and mount
|
||||||
|
// namespace of the specified PID without looking up its parent. Useful to join directly
|
||||||
|
// the conmon process.
|
||||||
|
func JoinDirectUserAndMountNS(pid uint) (bool, int, error) {
|
||||||
|
return false, -1, errors.New("this function is not supported on this os4")
|
||||||
}
|
}
|
||||||
|
@ -26,3 +26,7 @@ func (c *CreateConfig) createBlockIO() (*spec.LinuxBlockIO, error) {
|
|||||||
func makeThrottleArray(throttleInput []string, rateType int) ([]spec.LinuxThrottleDevice, error) {
|
func makeThrottleArray(throttleInput []string, rateType int) ([]spec.LinuxThrottleDevice, error) {
|
||||||
return nil, errors.New("function not implemented")
|
return nil, errors.New("function not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func devicesFromPath(g *generate.Generator, devicePath string) error {
|
||||||
|
return errors.New("function not implemented")
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user