--env-host: use default from containers.conf

As found while working on #20000, the `--env-host` flag should use the
default from containers.conf.  Add a new "supported fields" test to the
system tests to make sure we have a goto test for catching such
regressions.  I suspect more flags to not use the defaults from
containers.conf.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-09-18 14:06:51 +02:00
parent d912e735a3
commit 41beb53744
2 changed files with 18 additions and 1 deletions

View File

@ -140,7 +140,9 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
if !registry.IsRemote() {
createFlags.BoolVar(
&cf.EnvHost,
"env-host", false, "Use all current host environment variables in container",
"env-host",
podmanConfig.ContainersConfDefaultsRO.Containers.EnvHost,
"Use all current host environment variables in container",
)
}

View File

@ -177,4 +177,19 @@ EOF
assert "${lines[1]}" = "$m2" "completion finds module 2"
}
@test "podman --module - supported fields" {
skip_if_remote "--module is not supported for remote clients"
conf_tmp="$PODMAN_TMPDIR/test.conf"
cat > $conf_tmp <<EOF
[containers]
env_host=true
EOF
# Make sure env_host variable is read
random_env_var="expected_env_var_$(random_string 15)"
FOO="$random_env_var" run_podman --module=$conf_tmp run --rm $IMAGE /bin/printenv FOO
is "$output" "$random_env_var" "--module should yield injecting host env vars into the container"
}
# vim: filetype=sh