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:
parent
2d779a14e4
commit
6572b1b8e7
2 changed files with 10 additions and 10 deletions
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ class ContainersStorageSource(sources.SourceService):
|
|||
"""
|
||||
Construct the full image name that references an image with a given checksum in the local storage.
|
||||
"""
|
||||
conf = containers.get_host_storage(self.storage_conf)
|
||||
if self.storage_conf is None:
|
||||
conf = containers.get_host_storage()
|
||||
driver = conf["storage"]["driver"]
|
||||
graphroot = conf["storage"]["graphroot"]
|
||||
runroot = conf["storage"]["runroot"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue