summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-08-15 07:18:34 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2022-08-15 08:21:15 -0400
commit2d30b4dee596157d85ce9728921286a6242b5a29 (patch)
treea0cf8e7a0642b2bdd238a88faa06287f6267375b
parent4136496ee713982daf3136ffe65d11a4163fabb8 (diff)
downloadpodman-2d30b4dee596157d85ce9728921286a6242b5a29.tar.gz
podman-2d30b4dee596157d85ce9728921286a6242b5a29.tar.bz2
podman-2d30b4dee596157d85ce9728921286a6242b5a29.zip
Add compatibility support for --debug -D flag from docker
This is another fix for https://github.com/containers/podman/issues/14917 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r--cmd/podman/root.go15
-rw-r--r--test/system/001-basic.bats3
2 files changed, 17 insertions, 1 deletions
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 3637b2674..f45dc94b2 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -71,7 +71,10 @@ var (
DisableFlagsInUseLine: true,
}
- logLevel = "warn"
+ defaultLogLevel = "warn"
+ logLevel = defaultLogLevel
+ debug bool
+
useSyslog bool
requireCleanup = true
)
@@ -310,6 +313,13 @@ func persistentPostRunE(cmd *cobra.Command, args []string) error {
func loggingHook() {
var found bool
+ if debug {
+ if logLevel != defaultLogLevel {
+ fmt.Fprintf(os.Stderr, "Setting --log-level and --debug is not allowed\n")
+ os.Exit(1)
+ }
+ logLevel = "debug"
+ }
for _, l := range common.LogLevels {
if l == strings.ToLower(logLevel) {
found = true
@@ -465,6 +475,9 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
pFlags.StringVar(&logLevel, logLevelFlagName, logLevel, fmt.Sprintf("Log messages above specified level (%s)", strings.Join(common.LogLevels, ", ")))
_ = rootCmd.RegisterFlagCompletionFunc(logLevelFlagName, common.AutocompleteLogLevel)
+ pFlags.BoolVar(&debug, "debug", false, "Docker compatibility, force setting of log-level")
+ _ = pFlags.MarkHidden("debug")
+
// Only create these flags for ABI connections
if !registry.IsRemote() {
runtimeflagFlagName := "runtime-flag"
diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats
index cf37fc07c..584511388 100644
--- a/test/system/001-basic.bats
+++ b/test/system/001-basic.bats
@@ -190,6 +190,9 @@ See 'podman version --help'" "podman version --remote"
run_podman --log-level=error info
run_podman --log-level=fatal info
run_podman --log-level=panic info
+ run_podman --debug info
+ run_podman 1 --debug --log-level=panic info
+ is "$output" "Setting --log-level and --debug is not allowed"
}
# vim: filetype=sh