def validate(plugin_path, logger): """Validate a plugin This will try to validate the plugin's archive is not corrupted. A valid plugin is a wagon (http://github.com/cloudify-cosomo/wagon) in the tar.gz format. `PLUGIN_PATH` is the path to wagon archive to validate. """ logger.info('Validating plugin {0}...'.format(plugin_path)) wagon.validate(plugin_path) logger.info('Plugin validated successfully')
def _load_plugin_package_json(wagon_source): if wagon.validate(wagon_source): # wagon returns a list of validation issues. raise manager_exceptions.InvalidPluginError( 'the provided wagon can not be read.') return wagon.show(wagon_source)
def test_fail_validation_exclude_and_missing_wheel(self): test_package = os.path.join('tests', 'resources', 'test-package') requirement_files = [os.path.join(test_package, 'requirements.txt')] archive_path = wagon.create(source=test_package, requirement_files=requirement_files, force=True) archive_name = os.path.basename(archive_path) tempdir = tempfile.mkdtemp() try: wagon._unzip(archive_name, tempdir) wheels_dir = os.path.join(tempdir, 'test-package', wagon.DEFAULT_WHEELS_PATH) for wheel in os.listdir(wheels_dir): if wheel.startswith('wheel'): break wheel_to_delete = os.path.join(wheels_dir, wheel) os.remove(wheel_to_delete) wagon._tar(os.path.join(tempdir, 'test-package'), archive_name) result = wagon.validate(archive_name) assert len(result) == 1 finally: shutil.rmtree(tempdir, ignore_errors=True) if os.path.isfile(archive_name): os.remove(archive_name)
def test_fail_validate_in_nonexisting_venv(self, _): result = wagon.validate(self.archive_path) assert 'failed to install' in result[0] assert len(result) == 1
def test_fail_validate_package_not_installed(self, _): result = wagon.validate(self.archive_path) assert 'failed to install' in result[0] assert len(result) == 1
def test_create_with_validation_no_virtualenv_installed(self): with pytest.raises(wagon.WagonError) as ex: wagon.validate(self.archive_path) assert 'virtualenv is not installed' in str(ex.value)