aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/commit.go6
-rw-r--r--cmd/podman/export.go4
-rw-r--r--cmd/podman/main.go7
-rw-r--r--cmd/podman/main_remote.go39
-rw-r--r--cmd/podman/save.go4
-rw-r--r--cmd/podman/shared/container.go2
-rw-r--r--cmd/podman/shared/container_inspect.go46
-rw-r--r--cmd/podman/shared/create.go2
-rw-r--r--cmd/podman/system_df.go2
-rw-r--r--cmd/podman/varlink/io.podman.varlink10
10 files changed, 57 insertions, 65 deletions
diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go
index 01e2ec701..db0b8241e 100644
--- a/cmd/podman/commit.go
+++ b/cmd/podman/commit.go
@@ -26,9 +26,9 @@ var (
commitCommand.Remote = remoteclient
return commitCmd(&commitCommand)
},
- Example: `podman commit -q --message "committing container to image" reverent_golick image-commited
- podman commit -q --author "firstName lastName" reverent_golick image-commited
- podman commit -q --pause=false containerID image-commited`,
+ Example: `podman commit -q --message "committing container to image" reverent_golick image-committed
+ podman commit -q --author "firstName lastName" reverent_golick image-committed
+ podman commit -q --pause=false containerID image-committed`,
}
)
diff --git a/cmd/podman/export.go b/cmd/podman/export.go
index 82a4c13e7..f2336167b 100644
--- a/cmd/podman/export.go
+++ b/cmd/podman/export.go
@@ -7,8 +7,8 @@ import (
"github.com/containers/libpod/cmd/podman/shared/parse"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
- "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
+ "golang.org/x/crypto/ssh/terminal"
)
var (
@@ -62,7 +62,7 @@ func exportCmd(c *cliconfig.ExportValues) error {
if len(output) == 0 {
file := os.Stdout
- if logrus.IsTerminal(file) {
+ if terminal.IsTerminal(int(file.Fd())) {
return errors.Errorf("refusing to export to terminal. Use -o flag or redirect")
}
output = "/dev/stdout"
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index cbca32cc8..847cc0731 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -104,9 +104,7 @@ func before(cmd *cobra.Command, args []string) error {
logrus.Errorf(err.Error())
os.Exit(1)
}
- if err := setSyslog(); err != nil {
- return err
- }
+
if err := setupRootless(cmd, args); err != nil {
return err
}
@@ -121,6 +119,9 @@ func before(cmd *cobra.Command, args []string) error {
return err
}
logrus.SetLevel(level)
+ if err := setSyslog(); err != nil {
+ return err
+ }
if err := setRLimits(); err != nil {
return err
diff --git a/cmd/podman/main_remote.go b/cmd/podman/main_remote.go
index 1b9430e92..ecbb44d5a 100644
--- a/cmd/podman/main_remote.go
+++ b/cmd/podman/main_remote.go
@@ -3,8 +3,13 @@
package main
import (
+ "fmt"
+ "os"
"os/user"
+ "path/filepath"
+ "github.com/docker/docker/pkg/homedir"
+ "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -20,11 +25,41 @@ func init() {
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.RemoteUserName, "username", username, "username on the remote host")
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.RemoteHost, "remote-host", "", "remote host")
// 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")
+ // 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")
+ rootCmd.PersistentFlags().BoolVar(&MainGlobalOpts.Syslog, "syslog", false, "Output logging information to syslog as well as the console")
}
func setSyslog() error {
+ // Log to file if not using syslog
+ homeDir := homedir.Get()
+ path := filepath.Join(homeDir, ".config", "containers")
+
+ if _, err := os.Stat(path); os.IsNotExist(err) {
+ if err := os.MkdirAll(path, 0750); err != nil {
+ fmt.Fprintf(os.Stderr, "%v", err)
+ return err
+ }
+ }
+
+ // Update path to include file name
+ path = filepath.Join(path, "podman.log")
+
+ // Create the log file if doesn't exist. And append to it if it already exists.
+ file, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0640)
+ if err != nil {
+ // Cannot open log file. Logging to stderr
+ fmt.Fprintf(os.Stderr, "%v", err)
+ return err
+ } else {
+ formatter := new(logrus.TextFormatter)
+ formatter.FullTimestamp = true
+ logrus.SetFormatter(formatter)
+ logrus.SetOutput(file)
+ }
+
+ // Note this message is only logged if --log-level >= Info!
+ logrus.Infof("Logging level set to %s", logrus.GetLevel().String())
return nil
}
diff --git a/cmd/podman/save.go b/cmd/podman/save.go
index 4d204337e..e59c9df5f 100644
--- a/cmd/podman/save.go
+++ b/cmd/podman/save.go
@@ -9,8 +9,8 @@ import (
"github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
- "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
+ "golang.org/x/crypto/ssh/terminal"
)
const (
@@ -82,7 +82,7 @@ func saveCmd(c *cliconfig.SaveValues) error {
if len(c.Output) == 0 {
fi := os.Stdout
- if logrus.IsTerminal(fi) {
+ if terminal.IsTerminal(int(fi.Fd())) {
return errors.Errorf("refusing to save to terminal. Use -o flag or redirect")
}
c.Output = "/dev/stdout"
diff --git a/cmd/podman/shared/container.go b/cmd/podman/shared/container.go
index c97eaa290..f24a2358f 100644
--- a/cmd/podman/shared/container.go
+++ b/cmd/podman/shared/container.go
@@ -710,7 +710,7 @@ func portsToString(ports []ocicni.PortMapping) string {
}
// GetRunlabel is a helper function for runlabel; it gets the image if needed and begins the
-// contruction of the runlabel output and environment variables
+// construction of the runlabel output and environment variables
func GetRunlabel(label string, runlabelImage string, ctx context.Context, runtime *libpod.Runtime, pull bool, inputCreds string, dockerRegistryOptions image.DockerRegistryOptions, authfile string, signaturePolicyPath string, output io.Writer) (string, string, error) {
var (
newImage *image.Image
diff --git a/cmd/podman/shared/container_inspect.go b/cmd/podman/shared/container_inspect.go
index 97a1d0238..c89daf6bb 100644
--- a/cmd/podman/shared/container_inspect.go
+++ b/cmd/podman/shared/container_inspect.go
@@ -1,9 +1,6 @@
package shared
import (
- "strings"
-
- "github.com/containers/image/manifest"
"github.com/containers/libpod/libpod"
cc "github.com/containers/libpod/pkg/spec"
"github.com/docker/go-connections/nat"
@@ -17,7 +14,6 @@ import (
type InspectContainer struct {
*libpod.InspectContainerData
HostConfig *InspectContainerHostConfig `json:"HostConfig"`
- Config *InspectContainerConfig `json:"Config"`
}
// InspectContainerHostConfig holds Container configuration that is not specific
@@ -82,33 +78,8 @@ type InspectContainerHostConfig struct {
Tmpfs []string `json:"Tmpfs"`
}
-// InspectContainerConfig holds further data about a container, again mostly
-// not directly stored in Libpod. This struct is matched to the output of
-// `docker inspect`.
-type InspectContainerConfig struct {
- Hostname string `json:"Hostname"`
- DomainName string `json:"Domainname"` //TODO
- User specs.User `json:"User"`
- AttachStdin bool `json:"AttachStdin"` //TODO
- AttachStdout bool `json:"AttachStdout"` //TODO
- AttachStderr bool `json:"AttachStderr"` //TODO
- Tty bool `json:"Tty"`
- OpenStdin bool `json:"OpenStdin"`
- StdinOnce bool `json:"StdinOnce"` //TODO
- Env []string `json:"Env"`
- Cmd []string `json:"Cmd"`
- Image string `json:"Image"`
- Volumes map[string]struct{} `json:"Volumes"`
- WorkingDir string `json:"WorkingDir"`
- Entrypoint string `json:"Entrypoint"`
- Labels map[string]string `json:"Labels"`
- Annotations map[string]string `json:"Annotations"`
- StopSignal uint `json:"StopSignal"`
- Healthcheck *manifest.Schema2HealthConfig `json:"Healthcheck,omitempty"`
-}
-
// InspectLogConfig holds information about a container's configured log driver
-// and is presently unused. It is retained for Docker compatability.
+// and is presently unused. It is retained for Docker compatibility.
type InspectLogConfig struct {
Type string `json:"Type"`
Config map[string]string `json:"Config"` //idk type, TODO
@@ -181,21 +152,6 @@ func GetCtrInspectInfo(config *libpod.ContainerConfig, ctrInspectData *libpod.In
SecurityOpt: createArtifact.SecurityOpts,
Tmpfs: createArtifact.Tmpfs,
},
- &InspectContainerConfig{
- Hostname: spec.Hostname,
- User: spec.Process.User,
- Env: spec.Process.Env,
- Image: config.RootfsImageName,
- WorkingDir: spec.Process.Cwd,
- Labels: config.Labels,
- Annotations: spec.Annotations,
- Tty: spec.Process.Terminal,
- OpenStdin: config.Stdin,
- StopSignal: config.StopSignal,
- Cmd: config.Spec.Process.Args,
- Entrypoint: strings.Join(createArtifact.Entrypoint, " "),
- Healthcheck: config.HealthCheckConfig,
- },
}
return data, nil
}
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index 7cf230605..eee5f515d 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -811,7 +811,7 @@ func makeHealthCheckFromCli(c *GenericCLIResults) (*manifest.Schema2HealthConfig
return nil, errors.Wrapf(err, "invalid healthcheck-start-period %s", inStartPeriod)
}
if startPeriodDuration < time.Duration(0) {
- return nil, errors.New("healthcheck-start-period must be a 0 seconds or greater")
+ return nil, errors.New("healthcheck-start-period must be 0 seconds or greater")
}
hc.StartPeriod = startPeriodDuration
diff --git a/cmd/podman/system_df.go b/cmd/podman/system_df.go
index 840916547..d2163d0d7 100644
--- a/cmd/podman/system_df.go
+++ b/cmd/podman/system_df.go
@@ -586,7 +586,7 @@ func volumesVerboseOutput(ctx context.Context, metaData dfMetaData) error {
}
volumesVerboseDiskUsage, err := getVolumeVerboseDiskUsage(metaData.volumes, metaData.volumeUsedByContainerMap)
if err != nil {
- return errors.Wrapf(err, "error getting verbose ouput of volumes")
+ return errors.Wrapf(err, "error getting verbose output of volumes")
}
os.Stderr.WriteString("\nLocal Volumes space usage:\n\n")
out := formats.StdoutTemplateArray{Output: systemDfVolumeVerboseDiskUsageToGeneric(volumesVerboseDiskUsage), Template: volumeVerboseFormat, Fields: volumeVerboseHeader}
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index 5b3d5ae4c..9410b9459 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -207,7 +207,7 @@ type ContainerNameSpace (
ipc: string
)
-# InfoDistribution describes the the host's distribution
+# InfoDistribution describes the host's distribution
type InfoDistribution (
distribution: string,
version: string
@@ -671,7 +671,7 @@ method PauseContainer(name: string) -> (container: string)
# See also [PauseContainer](#PauseContainer).
method UnpauseContainer(name: string) -> (container: string)
-# Attach takes the name or ID of a container and sets up a the ability to remotely attach to its console. The start
+# Attach takes the name or ID of a container and sets up the ability to remotely attach to its console. The start
# bool is whether you wish to start the container in question first.
method Attach(name: string, detachKeys: string, start: bool) -> ()
@@ -744,7 +744,7 @@ method BuildImage(build: BuildInfo) -> (image: MoreResponse)
# This function is not implemented yet.
# method CreateImage() -> (notimplemented: NotImplemented)
-# InspectImage takes the name or ID of an image and returns a string respresentation of data associated with the
+# InspectImage takes the name or ID of an image and returns a string representation of data associated with the
#image. You must serialize the string into JSON to use it further. An [ImageNotFound](#ImageNotFound) error will
# be returned if the image cannot be found.
method InspectImage(name: string) -> (image: string)
@@ -810,7 +810,7 @@ method Commit(name: string, image_name: string, changes: []string, author: strin
method ImportImage(source: string, reference: string, message: string, changes: []string, delete: bool) -> (image: string)
# ExportImage takes the name or ID of an image and exports it to a destination like a tarball. There is also
-# a booleon option to force compression. It also takes in a string array of tags to be able to save multiple
+# a boolean option to force compression. It also takes in a string array of tags to be able to save multiple
# tags of the same image to a tarball (each tag should be of the form <image>:<tag>). Upon completion, the ID
# of the image is returned. If the image cannot be found in local storage, an [ImageNotFound](#ImageNotFound)
# error will be returned. See also [ImportImage](ImportImage).
@@ -915,7 +915,7 @@ method ListPods() -> (pods: []ListPodData)
# ~~~
method GetPod(name: string) -> (pod: ListPodData)
-# InspectPod takes the name or ID of an image and returns a string respresentation of data associated with the
+# InspectPod takes the name or ID of an image and returns a string representation of data associated with the
# pod. You must serialize the string into JSON to use it further. A [PodNotFound](#PodNotFound) error will
# be returned if the pod cannot be found.
method InspectPod(name: string) -> (pod: string)