shell completion: respect CONTAINERS_REGISTRIES_CONF

Found in debian testing where by default there are no unqualified search
registries installed. As such the test failed as the FIXME said. Now
there is no need for the test to assume anything.

Instead set our own config via CONTAINERS_REGISTRIES_CONF then we can
do exact matches, except that env was not read in the shell completion
code so move some code around to make it read the var in the same way as
podman login/logout.

Signed-off-by: Paul Holzinger <git@holzinger.dev>
This commit is contained in:
Paul Holzinger
2024-12-17 16:29:40 +01:00
parent 3e385eb76a
commit 153a975888
5 changed files with 37 additions and 22 deletions

View File

@@ -168,10 +168,10 @@ function check_shell_completion() {
*REGISTRY*)
run_completion "$@" $cmd "${extra_args[@]}" ""
### FIXME how can we get the configured registries?
_check_completion_end NoFileComp
### FIXME this fails if no registries are configured
assert "${#lines[@]}" -gt 2 "$* $cmd: No REGISTRIES found in suggestions"
# We can assume quay.io as we force our own CONTAINERS_REGISTRIES_CONF below.
assert "${lines[0]}" == "quay.io" "unqualified-search-registries from registries.conf listed"
match=true
# resume
@@ -311,6 +311,11 @@ function _check_no_suggestions() {
# create secret
run_podman secret create $random_secret_name $secret_file
# create our own registries.conf so we know what registry is set
local CONTAINERS_REGISTRIES_CONF="$PODMAN_TMPDIR/registries.conf"
echo 'unqualified-search-registries = ["quay.io"]' > "$CONTAINERS_REGISTRIES_CONF"
export CONTAINERS_REGISTRIES_CONF
# Called with no args -- start with 'podman --help'. check_shell_completion() will
# recurse for any subcommands.
check_shell_completion