podman-remote does not support most of the global flags

podman-remote --help is showing a bunch of global flags that it
does not support

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2020-09-30 16:24:10 -04:00
parent 00c7b493a0
commit b3f17936aa
3 changed files with 81 additions and 64 deletions

View File

@ -154,6 +154,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
} }
} }
if !registry.IsRemote() {
if cmd.Flag("cpu-profile").Changed { if cmd.Flag("cpu-profile").Changed {
f, err := os.Create(cfg.CPUProfile) f, err := os.Create(cfg.CPUProfile)
if err != nil { if err != nil {
@ -181,7 +182,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
if err := parallel.SetMaxThreads(uint(cfg.MaxWorks)); err != nil { if err := parallel.SetMaxThreads(uint(cfg.MaxWorks)); err != nil {
return err return err
} }
}
// Setup Rootless environment, IFF: // Setup Rootless environment, IFF:
// 1) in ABI mode // 1) in ABI mode
// 2) running as non-root // 2) running as non-root
@ -206,6 +207,7 @@ func persistentPostRunE(cmd *cobra.Command, args []string) error {
} }
cfg := registry.PodmanConfig() cfg := registry.PodmanConfig()
if !registry.IsRemote() {
if cmd.Flag("cpu-profile").Changed { if cmd.Flag("cpu-profile").Changed {
pprof.StopCPUProfile() pprof.StopCPUProfile()
} }
@ -213,6 +215,7 @@ func persistentPostRunE(cmd *cobra.Command, args []string) error {
cfg.Span.Finish() cfg.Span.Finish()
cfg.SpanCloser.Close() cfg.SpanCloser.Close()
} }
}
registry.ImageEngine().Shutdown(registry.Context()) registry.ImageEngine().Shutdown(registry.Context())
registry.ContainerEngine().Shutdown(registry.Context()) registry.ContainerEngine().Shutdown(registry.Context())
@ -249,12 +252,18 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
srv, uri, ident := resolveDestination() srv, uri, ident := resolveDestination()
lFlags := cmd.Flags() lFlags := cmd.Flags()
lFlags.BoolVarP(&opts.Remote, "remote", "r", false, "Access remote Podman service (default false)")
lFlags.StringVarP(&opts.Engine.ActiveService, "connection", "c", srv, "Connection to use for remote Podman service") lFlags.StringVarP(&opts.Engine.ActiveService, "connection", "c", srv, "Connection to use for remote Podman service")
lFlags.StringVar(&opts.URI, "url", uri, "URL to access Podman service (CONTAINER_HOST)") lFlags.StringVar(&opts.URI, "url", uri, "URL to access Podman service (CONTAINER_HOST)")
lFlags.StringVar(&opts.Identity, "identity", ident, "path to SSH identity file, (CONTAINER_SSHKEY)") lFlags.StringVar(&opts.Identity, "identity", ident, "path to SSH identity file, (CONTAINER_SSHKEY)")
lFlags.BoolVarP(&opts.Remote, "remote", "r", false, "Access remote Podman service (default false)")
pFlags := cmd.PersistentFlags() pFlags := cmd.PersistentFlags()
if registry.IsRemote() {
if err := lFlags.MarkHidden("remote"); err != nil {
logrus.Warnf("unable to mark --remote flag as hidden: %s", err.Error())
}
opts.Remote = true
} else {
pFlags.StringVar(&cfg.Engine.CgroupManager, "cgroup-manager", cfg.Engine.CgroupManager, "Cgroup manager to use (\"cgroupfs\"|\"systemd\")") pFlags.StringVar(&cfg.Engine.CgroupManager, "cgroup-manager", cfg.Engine.CgroupManager, "Cgroup manager to use (\"cgroupfs\"|\"systemd\")")
pFlags.StringVar(&opts.CPUProfile, "cpu-profile", "", "Path for the cpu profiling results") pFlags.StringVar(&opts.CPUProfile, "cpu-profile", "", "Path for the cpu profiling results")
pFlags.StringVar(&opts.ConmonPath, "conmon", "", "Path of the conmon binary") pFlags.StringVar(&opts.ConmonPath, "conmon", "", "Path of the conmon binary")
@ -276,11 +285,6 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
pFlags.StringVar(&opts.Engine.TmpDir, "tmpdir", "", "Path to the tmp directory for libpod state content.\n\nNote: use the environment variable 'TMPDIR' to change the temporary storage location for container images, '/var/tmp'.\n") pFlags.StringVar(&opts.Engine.TmpDir, "tmpdir", "", "Path to the tmp directory for libpod state content.\n\nNote: use the environment variable 'TMPDIR' to change the temporary storage location for container images, '/var/tmp'.\n")
pFlags.BoolVar(&opts.Trace, "trace", false, "Enable opentracing output (default false)") pFlags.BoolVar(&opts.Trace, "trace", false, "Enable opentracing output (default false)")
// Override default --help information of `--help` global flag
var dummyHelp bool
pFlags.BoolVar(&dummyHelp, "help", false, "Help for podman")
pFlags.StringVar(&logLevel, "log-level", logLevel, fmt.Sprintf("Log messages above specified level (%s)", strings.Join(logLevels, ", ")))
// Hide these flags for both ABI and Tunneling // Hide these flags for both ABI and Tunneling
for _, f := range []string{ for _, f := range []string{
"cpu-profile", "cpu-profile",
@ -293,6 +297,11 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
logrus.Warnf("unable to mark %s flag as hidden: %s", f, err.Error()) logrus.Warnf("unable to mark %s flag as hidden: %s", f, err.Error())
} }
} }
}
// Override default --help information of `--help` global flag
var dummyHelp bool
pFlags.BoolVar(&dummyHelp, "help", false, "Help for podman")
pFlags.StringVar(&logLevel, "log-level", logLevel, fmt.Sprintf("Log messages above specified level (%s)", strings.Join(logLevels, ", ")))
// Only create these flags for ABI connections // Only create these flags for ABI connections
if !registry.IsRemote() { if !registry.IsRemote() {

View File

@ -160,6 +160,14 @@ Print the version
Podman can set up environment variables from env of [engine] table in containers.conf. These variables can be overridden by passing environment variables before the `podman` commands. Podman can set up environment variables from env of [engine] table in containers.conf. These variables can be overridden by passing environment variables before the `podman` commands.
## Remote Access
The Podman command can be used with remote services using the `--remote` flag. Connections can
be made using local unix domain sockets, ssh or directly to tcp sockets. When specifying the
podman --remote flag, only the global options `--url`, `--identity`, `--log-level`, `--connection` are used.
Connection information can also be managed using the containers.conf file.
## Exit Status ## Exit Status
The exit code from `podman` gives information about why the container The exit code from `podman` gives information about why the container

View File

@ -61,7 +61,7 @@ function setup() {
is "$output" ".*Server:" "podman --remote: contacts server" is "$output" ".*Server:" "podman --remote: contacts server"
# This was failing: "podman --foo --bar --remote". # This was failing: "podman --foo --bar --remote".
PODMAN="${podman_non_remote} --tmpdir /var/tmp --log-level=error ${podman_args[@]} --remote" run_podman version PODMAN="${podman_non_remote} --log-level=error ${podman_args[@]} --remote" run_podman version
is "$output" ".*Server:" "podman [flags] --remote: contacts server" is "$output" ".*Server:" "podman [flags] --remote: contacts server"
# ...but no matter what, --remote is never allowed after subcommand # ...but no matter what, --remote is never allowed after subcommand