diff options
-rw-r--r-- | cmd/podman/common/create.go | 2 | ||||
-rw-r--r-- | cmd/podman/common/create_opts.go | 2 | ||||
-rw-r--r-- | cmd/podman/play/kube.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/play.go | 10 | ||||
-rw-r--r-- | test/system/700-play.bats | 17 |
5 files changed, 30 insertions, 3 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index 1c1a7c3e3..d28becc8a 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -299,7 +299,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, logDriverFlagName := "log-driver" createFlags.StringVar( &cf.LogDriver, - logDriverFlagName, logDriver(), + logDriverFlagName, LogDriver(), "Logging driver for the container", ) _ = cmd.RegisterFlagCompletionFunc(logDriverFlagName, AutocompleteLogDriver) diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index 16f193b03..c40d1ea51 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -530,7 +530,7 @@ func volumes() []string { return nil } -func logDriver() string { +func LogDriver() string { if !registry.IsRemote() { return containerConfig.Containers.LogDriver } diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go index 40d14a609..3be7396ce 100644 --- a/cmd/podman/play/kube.go +++ b/cmd/podman/play/kube.go @@ -87,7 +87,7 @@ func init() { _ = kubeCmd.RegisterFlagCompletionFunc(staticIPFlagName, completion.AutocompleteNone) logDriverFlagName := "log-driver" - flags.StringVar(&kubeOptions.LogDriver, logDriverFlagName, "", "Logging driver for the container") + flags.StringVar(&kubeOptions.LogDriver, logDriverFlagName, common.LogDriver(), "Logging driver for the container") _ = kubeCmd.RegisterFlagCompletionFunc(logDriverFlagName, common.AutocompleteLogDriver) logOptFlagName := "log-opt" diff --git a/pkg/api/handlers/libpod/play.go b/pkg/api/handlers/libpod/play.go index ca9ada761..b71afc28c 100644 --- a/pkg/api/handlers/libpod/play.go +++ b/pkg/api/handlers/libpod/play.go @@ -70,6 +70,16 @@ func PlayKube(w http.ResponseWriter, r *http.Request) { password = authConf.Password } + logDriver := query.LogDriver + if logDriver == "" { + config, err := runtime.GetConfig() + if err != nil { + utils.Error(w, http.StatusInternalServerError, err) + return + } + query.LogDriver = config.Containers.LogDriver + } + containerEngine := abi.ContainerEngine{Libpod: runtime} options := entities.PlayKubeOptions{ Annotations: query.Annotations, diff --git a/test/system/700-play.bats b/test/system/700-play.bats index b0624cbf2..7988b26a4 100644 --- a/test/system/700-play.bats +++ b/test/system/700-play.bats @@ -278,3 +278,20 @@ status: {} run_podman 125 play kube - < $PODMAN_TMPDIR/test.yaml assert "$output" =~ "invalid annotation \"test\"=\"$RANDOMSTRING\"" "Expected to fail with annotation length greater than 63" } + +@test "podman play kube - default log driver" { + TESTDIR=$PODMAN_TMPDIR/testdir + mkdir -p $TESTDIR + echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml + # Get the default log driver + run_podman info --format "{{.Host.LogDriver}}" + default_driver=$output + + # Make sure that the default log driver is used + run_podman play kube $PODMAN_TMPDIR/test.yaml + run_podman inspect --format "{{.HostConfig.LogConfig.Type}}" test_pod-test + is "$output" "$default_driver" "play kube uses default log driver" + + run_podman stop -a -t 0 + run_podman pod rm -t 0 -f test_pod +} |