mirror of
https://github.com/containers/podman.git
synced 2025-07-04 10:10:32 +08:00
Merge pull request #14060 from nicrowe00/13781
play kube default log driver
This commit is contained in:
@ -299,7 +299,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
|
|||||||
logDriverFlagName := "log-driver"
|
logDriverFlagName := "log-driver"
|
||||||
createFlags.StringVar(
|
createFlags.StringVar(
|
||||||
&cf.LogDriver,
|
&cf.LogDriver,
|
||||||
logDriverFlagName, logDriver(),
|
logDriverFlagName, LogDriver(),
|
||||||
"Logging driver for the container",
|
"Logging driver for the container",
|
||||||
)
|
)
|
||||||
_ = cmd.RegisterFlagCompletionFunc(logDriverFlagName, AutocompleteLogDriver)
|
_ = cmd.RegisterFlagCompletionFunc(logDriverFlagName, AutocompleteLogDriver)
|
||||||
|
@ -530,7 +530,7 @@ func volumes() []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func logDriver() string {
|
func LogDriver() string {
|
||||||
if !registry.IsRemote() {
|
if !registry.IsRemote() {
|
||||||
return containerConfig.Containers.LogDriver
|
return containerConfig.Containers.LogDriver
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func init() {
|
|||||||
_ = kubeCmd.RegisterFlagCompletionFunc(staticIPFlagName, completion.AutocompleteNone)
|
_ = kubeCmd.RegisterFlagCompletionFunc(staticIPFlagName, completion.AutocompleteNone)
|
||||||
|
|
||||||
logDriverFlagName := "log-driver"
|
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)
|
_ = kubeCmd.RegisterFlagCompletionFunc(logDriverFlagName, common.AutocompleteLogDriver)
|
||||||
|
|
||||||
logOptFlagName := "log-opt"
|
logOptFlagName := "log-opt"
|
||||||
|
@ -70,6 +70,16 @@ func PlayKube(w http.ResponseWriter, r *http.Request) {
|
|||||||
password = authConf.Password
|
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}
|
containerEngine := abi.ContainerEngine{Libpod: runtime}
|
||||||
options := entities.PlayKubeOptions{
|
options := entities.PlayKubeOptions{
|
||||||
Annotations: query.Annotations,
|
Annotations: query.Annotations,
|
||||||
|
@ -278,3 +278,20 @@ status: {}
|
|||||||
run_podman 125 play kube - < $PODMAN_TMPDIR/test.yaml
|
run_podman 125 play kube - < $PODMAN_TMPDIR/test.yaml
|
||||||
assert "$output" =~ "invalid annotation \"test\"=\"$RANDOMSTRING\"" "Expected to fail with annotation length greater than 63"
|
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
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user