diff options
Diffstat (limited to 'cmd/podman/root.go')
-rw-r--r-- | cmd/podman/root.go | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 56ca549b6..3796b8e27 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -2,13 +2,13 @@ package main import ( "fmt" - "log/syslog" "os" "path" "runtime/pprof" "strings" "github.com/containers/libpod/cmd/podman/registry" + "github.com/containers/libpod/cmd/podman/validate" "github.com/containers/libpod/pkg/domain/entities" "github.com/containers/libpod/pkg/rootless" "github.com/containers/libpod/pkg/tracing" @@ -16,7 +16,6 @@ import ( "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" - logrusSyslog "github.com/sirupsen/logrus/hooks/syslog" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -60,7 +59,7 @@ var ( SilenceErrors: true, TraverseChildren: true, PersistentPreRunE: persistentPreRunE, - RunE: registry.SubCommandExists, + RunE: validate.SubCommandExists, PersistentPostRunE: persistentPostRunE, Version: version.Version, } @@ -78,6 +77,10 @@ func init() { ) rootFlags(registry.PodmanConfig(), rootCmd.PersistentFlags()) + + // "version" is a local flag to avoid collisions with sub-commands that use "-v" + var dummyVersion bool + rootCmd.Flags().BoolVarP(&dummyVersion, "version", "v", false, "Version of Podman") } func Execute() { @@ -96,7 +99,7 @@ func Execute() { func persistentPreRunE(cmd *cobra.Command, args []string) error { // TODO: Remove trace statement in podman V2.1 - logrus.Debugf("Called %s.PersistentPreRunE()", cmd.Name()) + logrus.Debugf("Called %s.PersistentPreRunE(%s)", cmd.Name(), strings.Join(os.Args, " ")) cfg := registry.PodmanConfig() @@ -145,7 +148,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error { func persistentPostRunE(cmd *cobra.Command, args []string) error { // TODO: Remove trace statement in podman V2.1 - logrus.Debugf("Called %s.PersistentPostRunE()", cmd.Name()) + logrus.Debugf("Called %s.PersistentPostRunE(%s)", cmd.Name(), strings.Join(os.Args, " ")) cfg := registry.PodmanConfig() if cmd.Flag("cpu-profile").Changed { @@ -186,33 +189,13 @@ func loggingHook() { } } -func syslogHook() { - if !useSyslog { - return - } - - hook, err := logrusSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "") - if err != nil { - fmt.Fprint(os.Stderr, "Failed to initialize syslog hook: "+err.Error()) - os.Exit(1) - } - if err == nil { - logrus.AddHook(hook) - } -} - func rootFlags(opts *entities.PodmanConfig, flags *pflag.FlagSet) { // V2 flags - flags.StringVarP(&opts.Uri, "remote", "r", "", "URL to access Podman service") + flags.StringVarP(&opts.Uri, "remote", "r", registry.DefaultAPIAddress(), "URL to access Podman service") flags.StringSliceVar(&opts.Identities, "identity", []string{}, "path to SSH identity file") - // Override default --help information of `--version` global flag - // TODO: restore -v option for version without breaking -v for volumes - var dummyVersion bool - flags.BoolVar(&dummyVersion, "version", false, "Version of Podman") - cfg := opts.Config - flags.StringVar(&cfg.Engine.CgroupManager, "cgroup-manager", cfg.Engine.CgroupManager, opts.CGroupUsage) + flags.StringVar(&cfg.Engine.CgroupManager, "cgroup-manager", cfg.Engine.CgroupManager, "Cgroup manager to use (\"cgroupfs\"|\"systemd\")") flags.StringVar(&opts.CpuProfile, "cpu-profile", "", "Path for the cpu profiling results") flags.StringVar(&opts.ConmonPath, "conmon", "", "Path of the conmon binary") flags.StringVar(&cfg.Engine.NetworkCmdPath, "network-cmd-path", cfg.Engine.NetworkCmdPath, "Path to the command for configuring the network") @@ -223,6 +206,7 @@ func rootFlags(opts *entities.PodmanConfig, flags *pflag.FlagSet) { flags.IntVar(&opts.MaxWorks, "max-workers", 0, "The maximum number of workers for parallel operations") flags.StringVar(&cfg.Engine.Namespace, "namespace", cfg.Engine.Namespace, "Set the libpod namespace, used to create separate views of the containers and pods on the system") flags.StringVar(&cfg.Engine.StaticDir, "root", "", "Path to the root directory in which data, including images, is stored") + flags.StringVar(&opts.RegistriesConf, "registries-conf", "", "Path to a registries.conf to use for image processing") flags.StringVar(&opts.Runroot, "runroot", "", "Path to the 'run directory' where all state information is stored") flags.StringVar(&opts.RuntimePath, "runtime", "", "Path to the OCI-compatible binary used to run containers, default is /usr/bin/runc") // -s is deprecated due to conflict with -s on subcommands @@ -242,6 +226,7 @@ func rootFlags(opts *entities.PodmanConfig, flags *pflag.FlagSet) { "cpu-profile", "default-mounts-file", "max-workers", + "registries-conf", "trace", } { if err := flags.MarkHidden(f); err != nil { |