Skip to content

Commit

Permalink
--env-host: use default from containers.conf
Browse files Browse the repository at this point in the history
As found while working on containers#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 <[email protected]>
  • Loading branch information
vrothberg committed Sep 18, 2023
1 parent d912e73 commit 41beb53
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/podman/common/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
}

Expand Down
15 changes: 15 additions & 0 deletions test/system/800-config.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 41beb53

Please sign in to comment.