add CONTAINERS_CONF_OVERRIDE

Add yet another environment variable for loading containers.conf.
When CONTAINERS_CONF_OVERRIDE is set, the specified config file
will be loaded last - even when CONTAINERS_CONF is set.

This mechanism is needed to preserve system settings and other
environment variables.  Setting CONTAINERS_CONF will load only
the specified config file and ignore all system and user paths.
That makes testing hard as many Podman tests use CONTAINERS_CONF
for testing.

The intended use of CONTAINERS_CONF_OVERRIDE is to set it during tests
and point it to a specific configuration of Podman (e.g., netavark with
sqlite backend).

Similar needs have popped up talking to users in the automotive and
high-performance computing space.  In a way, such a setting allows for
specifying a specific "flavor" of Podman while preserving all existing
settings on the system.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-03-23 11:08:20 +01:00
parent 5f86fae71f
commit c5fc44582f

View File

@ -182,4 +182,30 @@ host.slirp4netns.executable | $expr_path
is "$output" "Error: unsupported database backend: \"bogus\""
}
@test "CONTAINERS_CONF_OVERRIDE" {
skip_if_remote "remote does not support CONTAINERS_CONF*"
containersConf=$PODMAN_TMPDIR/containers.conf
cat >$containersConf <<EOF
[engine]
database_backend = "boltdb"
EOF
overrideConf=$PODMAN_TMPDIR/override.conf
cat >$overrideConf <<EOF
[engine]
database_backend = "sqlite"
EOF
CONTAINERS_CONF="$containersConf" run_podman info --format "{{ .Host.DatabaseBackend }}"
is "$output" "boltdb"
CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman info --format "{{ .Host.DatabaseBackend }}"
is "$output" "sqlite"
# CONTAINERS_CONF will be overriden by _OVERRIDE
CONTAINERS_CONF=$containersConf CONTAINERS_CONF_OVERRIDE=$overrideConf run_podman info --format "{{ .Host.DatabaseBackend }}"
is "$output" "sqlite"
}
# vim: filetype=sh