mirror of https://github.com/containers/podman.git
Merge pull request #16518 from ashley-cui/noout
Fix podman --noout to suppress all output
This commit is contained in:
commit
54b1fd35bd
|
@ -78,6 +78,7 @@ var (
|
||||||
|
|
||||||
useSyslog bool
|
useSyslog bool
|
||||||
requireCleanup = true
|
requireCleanup = true
|
||||||
|
noOut = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -87,6 +88,7 @@ func init() {
|
||||||
syslogHook,
|
syslogHook,
|
||||||
earlyInitHook,
|
earlyInitHook,
|
||||||
configHook,
|
configHook,
|
||||||
|
noOutHook,
|
||||||
)
|
)
|
||||||
|
|
||||||
rootFlags(rootCmd, registry.PodmanConfig())
|
rootFlags(rootCmd, registry.PodmanConfig())
|
||||||
|
@ -127,10 +129,6 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
podmanConfig := registry.PodmanConfig()
|
podmanConfig := registry.PodmanConfig()
|
||||||
if podmanConfig.NoOut {
|
|
||||||
null, _ := os.Open(os.DevNull)
|
|
||||||
os.Stdout = null
|
|
||||||
}
|
|
||||||
|
|
||||||
// Currently it is only possible to restore a container with the same runtime
|
// Currently it is only possible to restore a container with the same runtime
|
||||||
// as used for checkpointing. It should be possible to make crun and runc
|
// as used for checkpointing. It should be possible to make crun and runc
|
||||||
|
@ -368,6 +366,13 @@ func loggingHook() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func noOutHook() {
|
||||||
|
if noOut {
|
||||||
|
null, _ := os.Open(os.DevNull)
|
||||||
|
os.Stdout = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func rootFlags(cmd *cobra.Command, podmanConfig *entities.PodmanConfig) {
|
func rootFlags(cmd *cobra.Command, podmanConfig *entities.PodmanConfig) {
|
||||||
srv, uri, ident, machine := resolveDestination()
|
srv, uri, ident, machine := resolveDestination()
|
||||||
|
|
||||||
|
@ -400,7 +405,7 @@ func rootFlags(cmd *cobra.Command, podmanConfig *entities.PodmanConfig) {
|
||||||
lFlags.StringVar(&podmanConfig.Identity, identityFlagName, ident, "path to SSH identity file, (CONTAINER_SSHKEY)")
|
lFlags.StringVar(&podmanConfig.Identity, identityFlagName, ident, "path to SSH identity file, (CONTAINER_SSHKEY)")
|
||||||
_ = cmd.RegisterFlagCompletionFunc(identityFlagName, completion.AutocompleteDefault)
|
_ = cmd.RegisterFlagCompletionFunc(identityFlagName, completion.AutocompleteDefault)
|
||||||
|
|
||||||
lFlags.BoolVar(&podmanConfig.NoOut, "noout", false, "do not output to stdout")
|
lFlags.BoolVar(&noOut, "noout", false, "do not output to stdout")
|
||||||
lFlags.BoolVarP(&podmanConfig.Remote, "remote", "r", registry.IsRemote(), "Access remote Podman service")
|
lFlags.BoolVarP(&podmanConfig.Remote, "remote", "r", registry.IsRemote(), "Access remote Podman service")
|
||||||
pFlags := cmd.PersistentFlags()
|
pFlags := cmd.PersistentFlags()
|
||||||
if registry.IsRemote() {
|
if registry.IsRemote() {
|
||||||
|
|
|
@ -42,7 +42,6 @@ type PodmanConfig struct {
|
||||||
Identity string // ssh identity for connecting to server
|
Identity string // ssh identity for connecting to server
|
||||||
MaxWorks int // maximum number of parallel threads
|
MaxWorks int // maximum number of parallel threads
|
||||||
MemoryProfile string // Hidden: Should memory profile be taken
|
MemoryProfile string // Hidden: Should memory profile be taken
|
||||||
NoOut bool // Don't output to stdout
|
|
||||||
RegistriesConf string // allows for specifying a custom registries.conf
|
RegistriesConf string // allows for specifying a custom registries.conf
|
||||||
Remote bool // Connection to Podman API Service will use RESTful API
|
Remote bool // Connection to Podman API Service will use RESTful API
|
||||||
RuntimePath string // --runtime flag will set Engine.RuntimePath
|
RuntimePath string // --runtime flag will set Engine.RuntimePath
|
||||||
|
|
|
@ -232,4 +232,10 @@ See 'podman version --help'" "podman version --remote"
|
||||||
is "$output" "Setting --log-level and --debug is not allowed"
|
is "$output" "Setting --log-level and --debug is not allowed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Tests --noout for commands that do not enter the engine
|
||||||
|
@test "podman --noout properly supresses output" {
|
||||||
|
run_podman --noout system connection ls
|
||||||
|
is "$output" "" "output should be empty"
|
||||||
|
}
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
|
Loading…
Reference in New Issue