util: remove storage_conf arg from get_host_storage()

Let the caller decide if a reload of the storage configuration is needed
and simplify the storage configuration reader.
This commit is contained in:
Achilleas Koutsou 2024-02-13 17:30:30 +01:00 committed by Ondřej Budai
parent 2d779a14e4
commit 6572b1b8e7
2 changed files with 10 additions and 10 deletions

View file

@ -171,7 +171,7 @@ def container_source(image):
yield image_name, image_source
def get_host_storage(storage_conf=None):
def get_host_storage():
"""
Read the host storage configuration.
"""
@ -183,13 +183,12 @@ def get_host_storage(storage_conf=None):
import tomli as toml
config_paths = ("/etc/containers/storage.conf", "/usr/share/containers/storage.conf")
if not storage_conf:
for conf_path in config_paths:
try:
with open(conf_path, "rb") as conf_file:
storage_conf = toml.load(conf_file)
return storage_conf
except FileNotFoundError:
pass
for conf_path in config_paths:
try:
with open(conf_path, "rb") as conf_file:
storage_conf = toml.load(conf_file)
return storage_conf
except FileNotFoundError:
pass
raise FileNotFoundError(f"could not find container storage configuration in any of {config_paths}")