def _flatten_manifest_structure(source_dir, dest_dir): try: flatten(source_dir, dest_dir) except OpCourierError as e: raise_for_courier_exception(e) if not os.listdir(dest_dir): # if dest dir is empty, it means that flatten did noop and source dir # has already flat structure dir_util.copy_tree(source_dir, dest_dir)
def test_flatten_with_nvr(omps, quay, koji, tmp_path_factory): """ When the manifest data of an operator image has a nested structure, and the manifest data is pushed to Quay using the NVR endpoint, then pushing the data is successful. """ version = '1.0.0' nvr = test_env['koji_builds']['nested_manifest'] quay.delete(test_env['test_namespace'], test_env['test_package']) response = omps.fetch_nvr(organization=test_env['test_namespace'], repo=test_env['test_package'], nvr=nvr) assert response.status_code == requests.codes.ok assert response.json() == { 'extracted_files': [ '0.6.1/int-testcluster.crd.yaml', '0.6.1/int-testoperator.clusterserviceversion.yaml', '0.9.0/int-testbackup.crd.yaml', '0.9.0/int-testcluster.crd.yaml', '0.9.0/int-testoperator.v0.9.0.clusterserviceversion.yaml', '0.9.0/int-testrestore.crd.yaml', '0.9.2/int-testbackup.crd.yaml', '0.9.2/int-testoperator.v0.9.2.clusterserviceversion.yaml', 'int-test.package.yaml' ], 'nvr': nvr, 'organization': test_env['test_namespace'], 'repo': test_env['test_package'], 'version': version, } assert quay.get_release(test_env['test_namespace'], test_env['test_package'], '1.0.0', authorization=None) quay_bundle = Bundle(quay.get_bundle(test_env['test_namespace'], test_env['test_package'], '1.0.0', authorization=None)) koji_data = tmp_path_factory.mktemp('koji_data') flattened = tmp_path_factory.mktemp('flattened') koji.download_manifest(nvr, koji_data) courier.flatten(koji_data.as_posix(), flattened.as_posix()) koji_bundle = Bundle( courier.build_and_verify(source_dir=flattened.as_posix()).bundle) # Note: this only confirms that OMPS used the right data from Koji, # but tells nothing about the correctness of that data. assert quay_bundle == koji_bundle
def flatten(self, args): """Parse the flatten command """ api.flatten(args.source_dir, args.dest_dir)