def validate_gear_config(gear, config_): if len(gear.get('gear', {}).get('config', {})) > 0: invocation = gear_tools.derive_invocation_schema(gear['gear']) ci = gear_tools.isolate_config_invocation(invocation) validator = Draft4Validator(ci) try: validator.validate(fill_gear_default_values(gear, config_)) except ValidationError as err: raise APIValidationException( reason='config did not match manifest', cause=err) return True
def validate_gear_config(gear, config_): if len(gear.get('manifest', {}).get('config', {})) > 0: invocation = gear_tools.derive_invocation_schema(gear['manifest']) ci = gear_tools.isolate_config_invocation(invocation) validator = Draft4Validator(ci) try: validator.validate(config_) except ValidationError as err: key = None if len(err.relative_path) > 0: key = err.relative_path[0] raise APIValidationException({ 'reason': 'config did not match manifest', 'error': err.message.replace("u'", "'"), 'key': key }) return True
def get_invocation_schema(gear): return gear_tools.derive_invocation_schema(gear['gear'])