ALBS-334: Make the ability of Pungi to give module_defaults from remote sources #5

Closed
soksanichenko wants to merge 11 commits from ALBS-334 into aln9
Showing only changes of commit 38ea822260 - Show all commits

View File

@ -79,6 +79,8 @@ def read_modules_yaml_from_specific_repo(repo_path: AnyStr) -> List[BytesIO]:
record.location_href, record.location_href,
) )
return [read_modules_yaml(modules_yaml_path=modules_yaml_path)] return [read_modules_yaml(modules_yaml_path=modules_yaml_path)]
else:
return []
def collect_modules( def collect_modules(
@ -93,9 +95,12 @@ def collect_modules(
Returns: Returns:
object: object:
""" """
xor_flag = grep_only_modules_defaults_data is grep_only_modules_data
modules_path = os.path.join(target_dir, 'modules') modules_path = os.path.join(target_dir, 'modules')
module_defaults_path = os.path.join(target_dir, 'module_defaults') module_defaults_path = os.path.join(target_dir, 'module_defaults')
if grep_only_modules_data or xor_flag:
os.makedirs(modules_path, exist_ok=True) os.makedirs(modules_path, exist_ok=True)
if grep_only_modules_defaults_data or xor_flag:
os.makedirs(module_defaults_path, exist_ok=True) os.makedirs(module_defaults_path, exist_ok=True)
# Defaults modules can be empty, but pungi detects # Defaults modules can be empty, but pungi detects
# empty folder while copying and raises the exception in this case # empty folder while copying and raises the exception in this case
@ -108,7 +113,6 @@ def collect_modules(
elif is_xz_file(data[:2]): elif is_xz_file(data[:2]):
data = lzma.decompress(data) data = lzma.decompress(data)
documents = yaml.load_all(data, Loader=yaml.BaseLoader) documents = yaml.load_all(data, Loader=yaml.BaseLoader)
xor_flag = grep_only_modules_defaults_data is grep_only_modules_data
for doc in documents: for doc in documents:
path = None path = None
if doc['document'] == 'modulemd-defaults' and \ if doc['document'] == 'modulemd-defaults' and \
@ -171,17 +175,22 @@ def cli_main():
help='Path to a directory which contains repodirs. E.g. /var/repos' help='Path to a directory which contains repodirs. E.g. /var/repos'
) )
path_group.add_argument( path_group.add_argument(
'-rd', '--repodata-path', '-rd', '--repodata-paths',
required=False, required=False,
type=str, type=str,
default=None, nargs='+',
help='Path/url to a directory with repodata dir', default=[],
help='Paths/urls to the directories with directory `repodata`',
) )
parser.add_argument('-t', '--target', required=True) parser.add_argument('-t', '--target', required=True)
namespace = parser.parse_args() namespace = parser.parse_args()
if namespace.repodata_path is not None: if namespace.repodata_paths:
modules = read_modules_yaml_from_specific_repo(namespace.repodata_path) modules = []
for repodata_path in namespace.repodata_paths:
modules.extend(read_modules_yaml_from_specific_repo(
repodata_path,
))
elif namespace.path is not None: elif namespace.path is not None:
modules = namespace.path modules = namespace.path
else: else: