def verify_pack_version(pack_dir): """ Verify that the pack works with the currently running StackStorm version. """ pack_metadata = get_pack_metadata(pack_dir=pack_dir) pack_name = pack_metadata.get('name', None) required_stackstorm_version = pack_metadata.get('stackstorm_version', None) supported_python_versions = pack_metadata.get('python_versions', None) # If stackstorm_version attribute is specified, verify that the pack works with currently # running version of StackStorm if required_stackstorm_version: if not complex_semver_match(CURRENT_STACKSTORM_VERSION, required_stackstorm_version): msg = ('Pack "%s" requires StackStorm "%s", but current version is "%s". ' 'You can override this restriction by providing the "force" flag, but ' 'the pack is not guaranteed to work.' % (pack_name, required_stackstorm_version, CURRENT_STACKSTORM_VERSION)) raise ValueError(msg) if supported_python_versions: if set(supported_python_versions) == set(['2']) and not six.PY2: msg = ('Pack "%s" requires Python 2.x, but current Python version is "%s". ' 'You can override this restriction by providing the "force" flag, but ' 'the pack is not guaranteed to work.' % (pack_name, CURRENT_PYTHON_VERSION)) raise ValueError(msg) elif set(supported_python_versions) == set(['3']) and not six.PY3: msg = ('Pack "%s" requires Python 3.x, but current Python version is "%s". ' 'You can override this restriction by providing the "force" flag, but ' 'the pack is not guaranteed to work.' % (pack_name, CURRENT_PYTHON_VERSION)) raise ValueError(msg) else: # Pack support Python 2.x and 3.x so no check is needed pass return True
def _verify_pack_version(pack_dir): pack_metadata = DownloadGitRepoAction._get_pack_metadata(pack_dir=pack_dir) pack_name = pack_metadata.get('name', None) required_stackstorm_version = pack_metadata.get('stackstorm_version', None) # If stackstorm_version attribute is speficied, verify that the pack works with currently # running version of StackStorm if required_stackstorm_version: if not complex_semver_match(CURRENT_STACKSTROM_VERSION, required_stackstorm_version): msg = ('Pack "%s" requires StackStorm "%s", but current version is "%s"' % (pack_name, required_stackstorm_version, CURRENT_STACKSTROM_VERSION)) raise ValueError(msg)
def _verify_pack_version(pack_dir): pack_metadata = DownloadGitRepoAction._get_pack_metadata(pack_dir=pack_dir) pack_name = pack_metadata.get('name', None) required_stackstorm_version = pack_metadata.get('stackstorm_version', None) # If stackstorm_version attribute is speficied, verify that the pack works with currently # running version of StackStorm if required_stackstorm_version: if not complex_semver_match(CURRENT_STACKSTROM_VERSION, required_stackstorm_version): msg = ('Pack "%s" requires StackStorm "%s", but current version is "%s". ' % (pack_name, required_stackstorm_version, CURRENT_STACKSTROM_VERSION), 'You can override this restriction by providing the "force" flag, but ', 'the pack is not guaranteed to work.') raise ValueError(msg)
def _verify_pack_version(pack_dir): pack_metadata = DownloadGitRepoAction._get_pack_metadata( pack_dir=pack_dir) pack_name = pack_metadata.get('name', None) required_stackstorm_version = pack_metadata.get( 'stackstorm_version', None) # If stackstorm_version attribute is speficied, verify that the pack works with currently # running version of StackStorm if required_stackstorm_version: if not complex_semver_match(CURRENT_STACKSTROM_VERSION, required_stackstorm_version): msg = ( 'Pack "%s" requires StackStorm "%s", but current version is "%s". ' % (pack_name, required_stackstorm_version, CURRENT_STACKSTROM_VERSION), 'You can override this restriction by providing the "force" flag, but ', 'the pack is not guaranteed to work.') raise ValueError(msg)
def test_complex_semver_match(self): # Positive test case self.assertTrue(complex_semver_match('1.6.0', '>=1.6.0, <2.2.0')) self.assertTrue(complex_semver_match('1.6.1', '>=1.6.0, <2.2.0')) self.assertTrue(complex_semver_match('2.0.0', '>=1.6.0, <2.2.0')) self.assertTrue(complex_semver_match('2.1.0', '>=1.6.0, <2.2.0')) self.assertTrue(complex_semver_match('2.1.9', '>=1.6.0, <2.2.0')) self.assertTrue(complex_semver_match('1.6.0', 'all')) self.assertTrue(complex_semver_match('1.6.1', 'all')) self.assertTrue(complex_semver_match('2.0.0', 'all')) self.assertTrue(complex_semver_match('2.1.0', 'all')) self.assertTrue(complex_semver_match('1.6.0', '>=1.6.0')) self.assertTrue(complex_semver_match('1.6.1', '>=1.6.0')) self.assertTrue(complex_semver_match('2.1.0', '>=1.6.0')) # Negative test case self.assertFalse(complex_semver_match('1.5.0', '>=1.6.0, <2.2.0')) self.assertFalse(complex_semver_match('0.1.0', '>=1.6.0, <2.2.0')) self.assertFalse(complex_semver_match('2.2.1', '>=1.6.0, <2.2.0')) self.assertFalse(complex_semver_match('2.3.0', '>=1.6.0, <2.2.0')) self.assertFalse(complex_semver_match('3.0.0', '>=1.6.0, <2.2.0')) self.assertFalse(complex_semver_match('1.5.0', '>=1.6.0')) self.assertFalse(complex_semver_match('0.1.0', '>=1.6.0')) self.assertFalse(complex_semver_match('1.5.9', '>=1.6.0'))
def test_complex_semver_match(self): # Positive test case self.assertTrue(complex_semver_match("1.6.0", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("1.6.1", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("2.0.0", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("2.1.0", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("2.1.9", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("1.6.0", ">=1.6.0")) self.assertTrue(complex_semver_match("1.6.1", ">=1.6.0")) self.assertTrue(complex_semver_match("2.1.0", ">=1.6.0")) # Negative test case self.assertFalse(complex_semver_match("1.5.0", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("0.1.0", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("2.2.1", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("2.3.0", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("3.0.0", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("1.5.0", ">=1.6.0")) self.assertFalse(complex_semver_match("0.1.0", ">=1.6.0")) self.assertFalse(complex_semver_match("1.5.9", ">=1.6.0"))
def test_complex_semver_match(self): # Positive test case self.assertTrue(complex_semver_match("1.6.0", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("1.6.1", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("2.0.0", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("2.1.0", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("2.1.9", ">=1.6.0, <2.2.0")) self.assertTrue(complex_semver_match("1.6.0", "all")) self.assertTrue(complex_semver_match("1.6.1", "all")) self.assertTrue(complex_semver_match("2.0.0", "all")) self.assertTrue(complex_semver_match("2.1.0", "all")) self.assertTrue(complex_semver_match("1.6.0", ">=1.6.0")) self.assertTrue(complex_semver_match("1.6.1", ">=1.6.0")) self.assertTrue(complex_semver_match("2.1.0", ">=1.6.0")) # Negative test case self.assertFalse(complex_semver_match("1.5.0", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("0.1.0", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("2.2.1", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("2.3.0", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("3.0.0", ">=1.6.0, <2.2.0")) self.assertFalse(complex_semver_match("1.5.0", ">=1.6.0")) self.assertFalse(complex_semver_match("0.1.0", ">=1.6.0")) self.assertFalse(complex_semver_match("1.5.9", ">=1.6.0"))