Skip to content

Commit

Permalink
Enforce and validate just the dest dir on merge
Browse files Browse the repository at this point in the history
This commit changes the `merge_catalog_dirs` to call the
`enforce_json_config_dir` and `opm_validate` only once after merging all
files into the destination dir.

Refers to CLOUDDST-21432
  • Loading branch information
JAVGan committed Apr 16, 2024
1 parent 6edebad commit 7c0b518
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
4 changes: 2 additions & 2 deletions iib/workers/tasks/fbc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def merge_catalogs_dirs(src_config: str, dest_config: str):
msg = f"config directory does not exist: {conf_dir}"
log.error(msg)
raise IIBError(msg)
enforce_json_config_dir(conf_dir)
opm_validate(conf_dir)

log.info("Merging config folders: %s to %s", src_config, dest_config)
shutil.copytree(src_config, dest_config, dirs_exist_ok=True)
enforce_json_config_dir(conf_dir)
opm_validate(conf_dir)


def extract_fbc_fragment(temp_dir: str, fbc_fragment: str) -> Tuple[str, str]:
Expand Down
21 changes: 4 additions & 17 deletions tests/test_workers/test_tasks/test_fbc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,10 @@ def test_merge_catalogs_dirs(mock_enforce_json, mock_rc, mock_opm, tmpdir):
tempfile.NamedTemporaryFile(dir=operator_dir, delete=False)

merge_catalogs_dirs(src_config=source_dir, dest_config=destination_dir)
mock_enforce_json.assert_has_calls(
[
mock.call(source_dir),
mock.call(destination_dir),
]
)
mock_rc.assert_has_calls(
[
mock.call(
[mock_opm.opm_version, 'validate', source_dir],
exc_msg=f'Failed to validate the content from config_dir {source_dir}',
),
mock.call(
[mock_opm.opm_version, 'validate', destination_dir],
exc_msg=f'Failed to validate the content from config_dir {destination_dir}',
),
]
mock_enforce_json.assert_called_once_with(destination_dir)
mock_rc.called_once_with(
[mock_opm.opm_version, 'validate', destination_dir],
exc_msg=f'Failed to validate the content from config_dir {destination_dir}',
)

for r, d, f in os.walk(source_dir):
Expand Down

0 comments on commit 7c0b518

Please sign in to comment.