util: move get_host_storage() to a separate module
Add a new util module called host which is used for functions that are meant for interactions with the host. These functions should not be used in stages. The containers.get_host_storage() function is renamed to host.get_container_storage() for clarity, since it is no longer namespaced under containers.
This commit is contained in:
parent
bce908e4a2
commit
07a597481b
4 changed files with 24 additions and 22 deletions
|
|
@ -180,21 +180,3 @@ def container_source(image):
|
|||
|
||||
with container_source_fn(image, image_filepath, container_format) as image_source:
|
||||
yield image_name, image_source
|
||||
|
||||
|
||||
def get_host_storage():
|
||||
"""
|
||||
Read the host storage configuration.
|
||||
"""
|
||||
# pylint: disable=import-outside-toplevel
|
||||
# importing this at the top level will break the buildroot
|
||||
from osbuild.util import toml
|
||||
|
||||
config_paths = ("/etc/containers/storage.conf", "/usr/share/containers/storage.conf")
|
||||
for conf_path in config_paths:
|
||||
try:
|
||||
return toml.load_from_file(conf_path)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
raise FileNotFoundError(f"could not find container storage configuration in any of {config_paths}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue