summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common/create_opts.go11
-rw-r--r--cmd/podman/common/netflags.go34
-rw-r--r--cmd/podman/completion/completion.go6
-rw-r--r--cmd/podman/containers/ps.go6
-rw-r--r--cmd/podman/pods/create.go28
-rw-r--r--cmd/podman/registry/registry.go3
-rw-r--r--cmd/podman/system/service.go17
-rw-r--r--cmd/podman/system/varlink.go61
8 files changed, 51 insertions, 115 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 6dc43dbc6..41611d1aa 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -211,12 +211,6 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
mounts = append(mounts, mount)
}
- // volumes
- volumes := make([]string, 0, len(cc.Config.Volumes))
- for v := range cc.Config.Volumes {
- volumes = append(volumes, v)
- }
-
// dns
dns := make([]net.IP, 0, len(cc.HostConfig.DNS))
for _, d := range cc.HostConfig.DNS {
@@ -373,7 +367,6 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
UserNS: string(cc.HostConfig.UsernsMode),
UTS: string(cc.HostConfig.UTSMode),
Mount: mounts,
- Volume: volumes,
VolumesFrom: cc.HostConfig.VolumesFrom,
Workdir: cc.Config.WorkingDir,
Net: &netInfo,
@@ -388,6 +381,10 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
}
}
+ // volumes
+ if volumes := cc.HostConfig.Binds; len(volumes) > 0 {
+ cliOpts.Volume = volumes
+ }
if len(cc.HostConfig.BlkioWeightDevice) > 0 {
devices := make([]string, 0, len(cc.HostConfig.BlkioWeightDevice))
for _, d := range cc.HostConfig.BlkioWeightDevice {
diff --git a/cmd/podman/common/netflags.go b/cmd/podman/common/netflags.go
index 898d65bd0..cae52ccaa 100644
--- a/cmd/podman/common/netflags.go
+++ b/cmd/podman/common/netflags.go
@@ -59,8 +59,8 @@ func DefineNetFlags(cmd *cobra.Command) {
_ = cmd.RegisterFlagCompletionFunc(macAddressFlagName, completion.AutocompleteNone)
networkFlagName := "network"
- netFlags.StringArray(
- networkFlagName, []string{containerConfig.NetNS()},
+ netFlags.String(
+ networkFlagName, containerConfig.NetNS(),
"Connect a container to a network",
)
_ = cmd.RegisterFlagCompletionFunc(networkFlagName, AutocompleteNetworks)
@@ -194,29 +194,25 @@ func NetFlagsToNetOptions(cmd *cobra.Command) (*entities.NetOptions, error) {
}
if cmd.Flags().Changed("network") {
- networks, err := cmd.Flags().GetStringArray("network")
+ network, err := cmd.Flags().GetString("network")
if err != nil {
return nil, err
}
- for i, network := range networks {
- parts := strings.SplitN(network, ":", 2)
- ns, cniNets, err := specgen.ParseNetworkNamespace(network)
- if err != nil {
- return nil, err
- }
- if i > 0 && (len(cniNets) == 0 || len(opts.CNINetworks) == 0) {
- return nil, errors.Errorf("network conflict between type %s and %s", opts.Network.NSMode, ns.NSMode)
- }
+ parts := strings.SplitN(network, ":", 2)
- if len(parts) > 1 {
- opts.NetworkOptions = make(map[string][]string)
- opts.NetworkOptions[parts[0]] = strings.Split(parts[1], ",")
- cniNets = nil
- }
- opts.Network = ns
- opts.CNINetworks = append(opts.CNINetworks, cniNets...)
+ ns, cniNets, err := specgen.ParseNetworkNamespace(network)
+ if err != nil {
+ return nil, err
+ }
+
+ if len(parts) > 1 {
+ opts.NetworkOptions = make(map[string][]string)
+ opts.NetworkOptions[parts[0]] = strings.Split(parts[1], ",")
+ cniNets = nil
}
+ opts.Network = ns
+ opts.CNINetworks = cniNets
}
aliases, err := cmd.Flags().GetStringSlice("network-alias")
diff --git a/cmd/podman/completion/completion.go b/cmd/podman/completion/completion.go
index ead8d1f05..84942a508 100644
--- a/cmd/podman/completion/completion.go
+++ b/cmd/podman/completion/completion.go
@@ -67,11 +67,7 @@ func completion(cmd *cobra.Command, args []string) error {
var err error
switch args[0] {
case "bash":
- if noDesc {
- err = cmd.Root().GenBashCompletion(w)
- } else {
- err = cmd.Root().GenBashCompletionWithDesc(w)
- }
+ err = cmd.Root().GenBashCompletion(w)
case "zsh":
if noDesc {
err = cmd.Root().GenZshCompletionNoDesc(w)
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 6f84cf9b8..5d08e6163 100644
--- a/cmd/podman/containers/ps.go
+++ b/cmd/podman/containers/ps.go
@@ -144,7 +144,7 @@ func checkFlags(c *cobra.Command) error {
func jsonOut(responses []entities.ListContainer) error {
r := make([]entities.ListContainer, 0)
for _, con := range responses {
- con.CreatedAt = units.HumanDuration(time.Since(time.Unix(con.Created, 0))) + " ago"
+ con.CreatedAt = units.HumanDuration(time.Since(con.Created)) + " ago"
con.Status = psReporter{con}.Status()
r = append(r, con)
}
@@ -404,12 +404,12 @@ func (l psReporter) Ports() string {
// CreatedAt returns the container creation time in string format. podman
// and docker both return a timestamped value for createdat
func (l psReporter) CreatedAt() string {
- return time.Unix(l.Created, 0).String()
+ return l.Created.String()
}
// CreateHuman allows us to output the created time in human readable format
func (l psReporter) CreatedHuman() string {
- return units.HumanDuration(time.Since(time.Unix(l.Created, 0))) + " ago"
+ return units.HumanDuration(time.Since(l.Created)) + " ago"
}
// Cgroup exposes .Namespaces.Cgroup
diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go
index 5b0aa2fe4..d997ea344 100644
--- a/cmd/podman/pods/create.go
+++ b/cmd/podman/pods/create.go
@@ -171,7 +171,33 @@ func create(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
-
+ createOptions.Net.Network = specgen.Namespace{}
+ if cmd.Flag("network").Changed {
+ netInput, err := cmd.Flags().GetString("network")
+ if err != nil {
+ return err
+ }
+ parts := strings.SplitN(netInput, ":", 2)
+
+ n := specgen.Namespace{}
+ switch {
+ case netInput == "bridge":
+ n.NSMode = specgen.Bridge
+ case netInput == "host":
+ n.NSMode = specgen.Host
+ case netInput == "slirp4netns", strings.HasPrefix(netInput, "slirp4netns:"):
+ n.NSMode = specgen.Slirp
+ if len(parts) > 1 {
+ createOptions.Net.NetworkOptions = make(map[string][]string)
+ createOptions.Net.NetworkOptions[parts[0]] = strings.Split(parts[1], ",")
+ }
+ default:
+ // Container and NS mode are presently unsupported
+ n.NSMode = specgen.Bridge
+ createOptions.Net.CNINetworks = strings.Split(netInput, ",")
+ }
+ createOptions.Net.Network = n
+ }
if len(createOptions.Net.PublishPorts) > 0 {
if !createOptions.Infra {
return errors.Errorf("you must have an infra container to publish port bindings to the host")
diff --git a/cmd/podman/registry/registry.go b/cmd/podman/registry/registry.go
index 9c0b290e7..481ed810f 100644
--- a/cmd/podman/registry/registry.go
+++ b/cmd/podman/registry/registry.go
@@ -18,9 +18,6 @@ const DefaultRootAPIPath = "/run/podman/podman.sock"
// DefaultRootAPIAddress is the default address of the REST socket with unix: prefix
const DefaultRootAPIAddress = "unix:" + DefaultRootAPIPath
-// DefaultVarlinkAddress is the default address of the varlink socket
-const DefaultVarlinkAddress = "unix:/run/podman/io.podman"
-
type CliCommand struct {
Mode []entities.EngineMode
Command *cobra.Command
diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go
index 78062d135..42482b5d9 100644
--- a/cmd/podman/system/service.go
+++ b/cmd/podman/system/service.go
@@ -38,7 +38,6 @@ Enable a listening service for API access to Podman commands.
srvArgs = struct {
Timeout int64
- Varlink bool
}{}
)
@@ -55,9 +54,6 @@ func init() {
flags.Int64VarP(&srvArgs.Timeout, timeFlagName, "t", 5, "Time until the service session expires in seconds. Use 0 to disable the timeout")
_ = srvCmd.RegisterFlagCompletionFunc(timeFlagName, completion.AutocompleteNone)
- flags.BoolVar(&srvArgs.Varlink, "varlink", false, "Use legacy varlink service instead of REST. Unit of --time changes from seconds to milliseconds.")
-
- _ = flags.MarkDeprecated("varlink", "valink API is deprecated.")
flags.SetNormalizeFunc(aliasTimeoutFlag)
}
@@ -97,11 +93,6 @@ func service(cmd *cobra.Command, args []string) error {
Command: cmd,
}
- if srvArgs.Varlink {
- opts.Timeout = time.Duration(srvArgs.Timeout) * time.Millisecond
- return registry.ContainerEngine().VarlinkService(registry.GetContext(), opts)
- }
-
opts.Timeout = time.Duration(srvArgs.Timeout) * time.Second
return restService(opts, cmd.Flags(), registry.PodmanConfig())
}
@@ -111,8 +102,7 @@ func resolveAPIURI(_url []string) (string, error) {
// 1) User input wins always
// 2) systemd socket activation
// 3) rootless honors XDG_RUNTIME_DIR
- // 4) if varlink -- adapter.DefaultVarlinkAddress
- // 5) lastly adapter.DefaultAPIAddress
+ // 4) lastly adapter.DefaultAPIAddress
if len(_url) == 0 {
if v, found := os.LookupEnv("PODMAN_SOCKET"); found {
@@ -134,16 +124,11 @@ func resolveAPIURI(_url []string) (string, error) {
}
socketName := "podman.sock"
- if srvArgs.Varlink {
- socketName = "io.podman"
- }
socketPath := filepath.Join(xdg, "podman", socketName)
if err := os.MkdirAll(filepath.Dir(socketPath), 0700); err != nil {
return "", err
}
return "unix:" + socketPath, nil
- case srvArgs.Varlink:
- return registry.DefaultVarlinkAddress, nil
default:
if err := os.MkdirAll(filepath.Dir(registry.DefaultRootAPIPath), 0700); err != nil {
return "", err
diff --git a/cmd/podman/system/varlink.go b/cmd/podman/system/varlink.go
deleted file mode 100644
index 363ac9cca..000000000
--- a/cmd/podman/system/varlink.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// +build linux,!remote
-
-package system
-
-import (
- "time"
-
- "github.com/containers/common/pkg/completion"
- "github.com/containers/podman/v2/cmd/podman/registry"
- "github.com/containers/podman/v2/pkg/domain/entities"
- "github.com/spf13/cobra"
-)
-
-var (
- varlinkDescription = `Run varlink interface. Podman varlink listens on the specified unix domain socket for incoming connects.
-
- Tools speaking varlink protocol can remotely manage pods, containers and images.
-`
- varlinkCmd = &cobra.Command{
- Use: "varlink [options] [URI]",
- Args: cobra.MinimumNArgs(1),
- Short: "Run varlink interface",
- Long: varlinkDescription,
- RunE: varlinkE,
- ValidArgsFunction: completion.AutocompleteDefault,
- Deprecated: "Please see 'podman system service' for RESTful APIs",
- Hidden: true,
- Example: `podman varlink unix:/run/podman/io.podman
- podman varlink --time 5000 unix:/run/podman/io.podman`,
- }
- varlinkArgs = struct {
- Timeout int64
- }{}
-)
-
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: varlinkCmd,
- })
- flags := varlinkCmd.Flags()
-
- timeFlagName := "time"
- flags.Int64VarP(&varlinkArgs.Timeout, timeFlagName, "t", 1000, "Time until the varlink session expires in milliseconds. Use 0 to disable the timeout")
- _ = varlinkCmd.RegisterFlagCompletionFunc(timeFlagName, completion.AutocompleteNone)
-
- flags.SetNormalizeFunc(aliasTimeoutFlag)
-}
-
-func varlinkE(cmd *cobra.Command, args []string) error {
- uri := registry.DefaultVarlinkAddress
- if len(args) > 0 {
- uri = args[0]
- }
- opts := entities.ServiceOptions{
- URI: uri,
- Timeout: time.Duration(varlinkArgs.Timeout) * time.Second,
- Command: cmd,
- }
- return registry.ContainerEngine().VarlinkService(registry.GetContext(), opts)
-}