summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/cliconfig/config.go2
-rw-r--r--cmd/podman/cp.go4
-rw-r--r--cmd/podman/import.go5
-rw-r--r--cmd/podman/main.go20
-rw-r--r--cmd/podman/main_remote.go30
-rw-r--r--cmd/podman/network_create.go6
-rw-r--r--cmd/podman/remoteclientconfig/config.go10
-rw-r--r--cmd/podman/remoteclientconfig/configfile_test.go6
-rw-r--r--cmd/podman/varlink/io.podman.varlink37
9 files changed, 92 insertions, 28 deletions
diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go
index b8796f9b3..5b5225f02 100644
--- a/cmd/podman/cliconfig/config.go
+++ b/cmd/podman/cliconfig/config.go
@@ -42,6 +42,8 @@ type MainFlags struct {
ConnectionName string
RemoteConfigFilePath string
Port int
+ IdentityFile string
+ IgnoreHosts bool
}
type AttachValues struct {
diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go
index 7205f9357..75a23afd6 100644
--- a/cmd/podman/cp.go
+++ b/cmd/podman/cp.go
@@ -290,7 +290,7 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch
}
destdir := destPath
- if !srcfi.IsDir() && !strings.HasSuffix(dest, string(os.PathSeparator)) {
+ if !srcfi.IsDir() {
destdir = filepath.Dir(destPath)
}
_, err = os.Stat(destdir)
@@ -329,7 +329,7 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch
destfi, err := os.Stat(destPath)
if err != nil {
- if !os.IsNotExist(err) {
+ if !os.IsNotExist(err) || strings.HasSuffix(dest, string(os.PathSeparator)) {
return errors.Wrapf(err, "failed to get stat of dest path %s", destPath)
}
}
diff --git a/cmd/podman/import.go b/cmd/podman/import.go
index d49792f27..027fa7299 100644
--- a/cmd/podman/import.go
+++ b/cmd/podman/import.go
@@ -39,7 +39,7 @@ func init() {
importCommand.SetHelpTemplate(HelpTemplate())
importCommand.SetUsageTemplate(UsageTemplate())
flags := importCommand.Flags()
- flags.StringSliceVarP(&importCommand.Change, "change", "c", []string{}, "Apply the following possible instructions to the created image (default []): CMD | ENTRYPOINT | ENV | EXPOSE | LABEL | STOPSIGNAL | USER | VOLUME | WORKDIR")
+ flags.StringArrayVarP(&importCommand.Change, "change", "c", []string{}, "Apply the following possible instructions to the created image (default []): CMD | ENTRYPOINT | ENV | EXPOSE | LABEL | STOPSIGNAL | USER | VOLUME | WORKDIR")
flags.StringVarP(&importCommand.Message, "message", "m", "", "Set commit message for imported image")
flags.BoolVarP(&importCommand.Quiet, "quiet", "q", false, "Suppress output")
@@ -56,7 +56,6 @@ func importCmd(c *cliconfig.ImportValues) error {
source string
reference string
)
-
args := c.InputArgs
switch len(args) {
case 0:
@@ -81,7 +80,7 @@ func importCmd(c *cliconfig.ImportValues) error {
if runtime.Remote {
quiet = false
}
- iid, err := runtime.Import(getContext(), source, reference, c.StringSlice("change"), c.String("message"), quiet)
+ iid, err := runtime.Import(getContext(), source, reference, importCommand.Change, c.String("message"), quiet)
if err == nil {
fmt.Println(iid)
}
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index 992dbe1d5..344170ddd 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -107,15 +107,6 @@ func before(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
- if err := setupRootless(cmd, args); err != nil {
- return err
- }
-
- // check that global opts input is valid
- if err := checkInput(); err != nil {
- return err
- }
-
// Set log level; if not log-level is provided, default to error
logLevel := MainGlobalOpts.LogLevel
if logLevel == "" {
@@ -130,6 +121,15 @@ func before(cmd *cobra.Command, args []string) error {
return err
}
+ if err := setupRootless(cmd, args); err != nil {
+ return err
+ }
+
+ // check that global opts input is valid
+ if err := checkInput(); err != nil {
+ return err
+ }
+
if err := setRLimits(); err != nil {
return err
}
@@ -149,6 +149,8 @@ func main() {
//cpuProfile := false
if reexec.Init() {
+ // We were invoked with a different argv[0] indicating that we
+ // had a specific job to do as a subprocess, and it's done.
return
}
// Hard code TMPDIR functions to use /var/tmp, if user did not override
diff --git a/cmd/podman/main_remote.go b/cmd/podman/main_remote.go
index f617422e6..623f4098e 100644
--- a/cmd/podman/main_remote.go
+++ b/cmd/podman/main_remote.go
@@ -3,9 +3,11 @@
package main
import (
- "github.com/pkg/errors"
+ "os"
"os/user"
+ "strconv"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -13,14 +15,32 @@ const remote = true
func init() {
var username string
- if curruser, err := user.Current(); err == nil {
- username = curruser.Username
+ if username = os.Getenv("PODMAN_USER"); username == "" {
+ if curruser, err := user.Current(); err == nil {
+ username = curruser.Username
+ }
+ }
+ host := os.Getenv("PODMAN_HOST")
+ port := 22
+ if portstr := os.Getenv("PODMAN_PORT"); portstr != "" {
+ if p, err := strconv.Atoi(portstr); err == nil {
+ port = p
+ }
+ }
+ key := os.Getenv("PODMAN_IDENTITY_FILE")
+ ignore := false
+ if ignorestr := os.Getenv("PODMAN_IGNORE_HOSTS"); ignorestr != "" {
+ if b, err := strconv.ParseBool(ignorestr); err == nil {
+ ignore = b
+ }
}
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.ConnectionName, "connection", "", "remote connection name")
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.RemoteConfigFilePath, "remote-config-path", "", "alternate path for configuration file")
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.RemoteUserName, "username", username, "username on the remote host")
- rootCmd.PersistentFlags().IntVar(&MainGlobalOpts.Port, "port", 22, "port on remote host")
- rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.RemoteHost, "remote-host", "", "remote host")
+ rootCmd.PersistentFlags().IntVar(&MainGlobalOpts.Port, "port", port, "port on remote host")
+ rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.RemoteHost, "remote-host", host, "remote host")
+ rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.IdentityFile, "identity-file", key, "identity-file")
+ rootCmd.PersistentFlags().BoolVar(&MainGlobalOpts.IgnoreHosts, "ignore-hosts", ignore, "ignore hosts")
// TODO maybe we allow the altering of this for bridge connections?
// rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.VarlinkAddress, "varlink-address", adapter.DefaultAddress, "address of the varlink socket")
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.LogLevel, "log-level", "error", "Log messages above specified level: debug, info, warn, error, fatal or panic. Logged to ~/.config/containers/podman.log")
diff --git a/cmd/podman/network_create.go b/cmd/podman/network_create.go
index 378a92568..11f13faad 100644
--- a/cmd/podman/network_create.go
+++ b/cmd/podman/network_create.go
@@ -4,11 +4,12 @@ package main
import (
"fmt"
- "github.com/containers/libpod/pkg/network"
"net"
"github.com/containers/libpod/cmd/podman/cliconfig"
+ "github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
+ "github.com/containers/libpod/pkg/network"
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -58,6 +59,9 @@ func networkcreateCmd(c *cliconfig.NetworkCreateValues) error {
if len(c.InputArgs) > 1 {
return errors.Errorf("only one network can be created at a time")
}
+ if len(c.InputArgs) > 0 && !libpod.NameRegex.MatchString(c.InputArgs[0]) {
+ return libpod.RegexError
+ }
runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
if err != nil {
return err
diff --git a/cmd/podman/remoteclientconfig/config.go b/cmd/podman/remoteclientconfig/config.go
index 13880a868..3faa7954a 100644
--- a/cmd/podman/remoteclientconfig/config.go
+++ b/cmd/podman/remoteclientconfig/config.go
@@ -9,10 +9,12 @@ type RemoteConfig struct {
// RemoteConnection describes the attributes of a podman-remote endpoint
type RemoteConnection struct {
- Destination string `toml:"destination"`
- Username string `toml:"username"`
- IsDefault bool `toml:"default"`
- Port int `toml:"port"`
+ Destination string `toml:"destination"`
+ Username string `toml:"username"`
+ IsDefault bool `toml:"default"`
+ Port int `toml:"port"`
+ IdentityFile string `toml:"identity_file"`
+ IgnoreHosts bool `toml:"ignore_hosts"`
}
// GetConfigFilePath is a simple helper to export the configuration file's
diff --git a/cmd/podman/remoteclientconfig/configfile_test.go b/cmd/podman/remoteclientconfig/configfile_test.go
index ea2224ea7..0bcac29a8 100644
--- a/cmd/podman/remoteclientconfig/configfile_test.go
+++ b/cmd/podman/remoteclientconfig/configfile_test.go
@@ -143,7 +143,7 @@ func TestRemoteConfig_GetDefault(t *testing.T) {
wantErr bool
}{
// A good toml should return the connection that is marked isDefault
- {"good", fields{Connections: makeGoodResult().Connections}, &RemoteConnection{"192.168.1.1", "myuser", true, 22}, false},
+ {"good", fields{Connections: makeGoodResult().Connections}, &RemoteConnection{"192.168.1.1", "myuser", true, 22, "", false}, false},
// If nothing is marked as isDefault and there is more than one connection, error should occur
{"nodefault", fields{Connections: noDefault}, nil, true},
// if nothing is marked as isDefault but there is only one connection, the one connection is considered the default
@@ -183,9 +183,9 @@ func TestRemoteConfig_GetRemoteConnection(t *testing.T) {
wantErr bool
}{
// Good connection
- {"goodhomer", fields{Connections: makeGoodResult().Connections}, args{name: "homer"}, &RemoteConnection{"192.168.1.1", "myuser", true, 22}, false},
+ {"goodhomer", fields{Connections: makeGoodResult().Connections}, args{name: "homer"}, &RemoteConnection{"192.168.1.1", "myuser", true, 22, "", false}, false},
// Good connection
- {"goodbart", fields{Connections: makeGoodResult().Connections}, args{name: "bart"}, &RemoteConnection{"foobar.com", "root", false, 22}, false},
+ {"goodbart", fields{Connections: makeGoodResult().Connections}, args{name: "bart"}, &RemoteConnection{"foobar.com", "root", false, 22, "", false}, false},
// Getting an unknown connection should result in error
{"noexist", fields{Connections: makeGoodResult().Connections}, args{name: "foobar"}, nil, true},
// Getting a connection when there are none should result in an error
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index 3434a2bcb..2408dc80c 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -781,8 +781,43 @@ method ListImages() -> (images: []Image)
method GetImage(id: string) -> (image: Image)
# BuildImage takes a [BuildInfo](#BuildInfo) structure and builds an image. At a minimum, you must provide the
-# 'dockerfile' and 'tags' options in the BuildInfo structure. It will return a [MoreResponse](#MoreResponse) structure
+# contextDir tarball path, the 'dockerfiles' path, and 'output' option in the BuildInfo structure. The 'output'
+# options is the name of the of the resulting build. It will return a [MoreResponse](#MoreResponse) structure
# that contains the build logs and resulting image ID.
+# #### Example
+# ~~~
+# $ sudo varlink call -m unix:///run/podman/io.podman/io.podman.BuildImage '{"build":{"contextDir":"/tmp/t/context.tar","dockerfiles":["Dockerfile"], "output":"foobar"}}'
+# {
+# "image": {
+# "id": "",
+# "logs": [
+# "STEP 1: FROM alpine\n"
+# ]
+# }
+# }
+# {
+# "image": {
+# "id": "",
+# "logs": [
+# "STEP 2: COMMIT foobar\n"
+# ]
+# }
+# }
+# {
+# "image": {
+# "id": "",
+# "logs": [
+# "b7b28af77ffec6054d13378df4fdf02725830086c7444d9c278af25312aa39b9\n"
+# ]
+# }
+# }
+# {
+# "image": {
+# "id": "b7b28af77ffec6054d13378df4fdf02725830086c7444d9c278af25312aa39b9",
+# "logs": []
+# }
+# }
+# ~~~
method BuildImage(build: BuildInfo) -> (image: MoreResponse)
# This function is not implemented yet.