diff --git a/apps_schema/__init__.py b/apps_schema/__init__.py new file mode 100644 index 0000000..6e6ae06 --- /dev/null +++ b/apps_schema/__init__.py @@ -0,0 +1 @@ +# FIXME: We need to account for migration apps_schema diff --git a/apps_validation/schema/attrs/__init__.py b/apps_schema/attrs/__init__.py similarity index 100% rename from apps_validation/schema/attrs/__init__.py rename to apps_schema/attrs/__init__.py diff --git a/apps_validation/schema/attrs/array.py b/apps_schema/attrs/array.py similarity index 90% rename from apps_validation/schema/attrs/array.py rename to apps_schema/attrs/array.py index 07bd996..c3304ce 100644 --- a/apps_validation/schema/attrs/array.py +++ b/apps_schema/attrs/array.py @@ -12,7 +12,7 @@ def __init__(self, data): self._skip_data_values = ['items'] def initialize_values(self, data): - from apps_validation.schema.variable import Variable + from apps_schema.variable import Variable super().initialize_values(data) self.items = [Variable(d) for d in (data.get('items') or [])] diff --git a/apps_validation/schema/attrs/base.py b/apps_schema/attrs/base.py similarity index 94% rename from apps_validation/schema/attrs/base.py rename to apps_schema/attrs/base.py index a89c429..e1b90e0 100644 --- a/apps_validation/schema/attrs/base.py +++ b/apps_schema/attrs/base.py @@ -10,7 +10,7 @@ class SchemaMeta(type): def __new__(cls, name, bases, dct): klass = type.__new__(cls, name, bases, dct) if klass.__name__ != 'BaseSchema' and getattr(klass, 'SCHEMA_NAME', NotImplementedError) is NotImplementedError: - raise ValueError(f'{name!r} attr schema does not has SCHEMA_NAME defined') + raise ValueError(f'{name!r} attr apps_schema does not has SCHEMA_NAME defined') ATTRIBUTES_SCHEMA[klass.SCHEMA_NAME] = klass return klass @@ -47,18 +47,18 @@ def validate(self, schema, data=None): self.initialize_values(data) if not self._schema_data: - raise Exception('Schema data must be initialized before validating schema') + raise Exception('Schema data must be initialized before validating apps_schema') verrors = ValidationErrors() try: json_schema_validate(self._schema_data, self.json_schema()) except JsonValidationError as e: - verrors.add(schema, f'Failed to validate schema: {e}') + verrors.add(schema, f'Failed to validate apps_schema: {e}') verrors.check() if '$ref' in self._schema_data: - from apps_validation.schema.features import FEATURES + from apps_schema.features import FEATURES for index, ref in enumerate(self._schema_data['$ref']): if not isinstance(ref, str): verrors.add(f'{schema}.$ref.{index}', 'Must be a string') diff --git a/apps_validation/schema/attrs/bool.py b/apps_schema/attrs/bool.py similarity index 100% rename from apps_validation/schema/attrs/bool.py rename to apps_schema/attrs/bool.py diff --git a/apps_validation/schema/attrs/dictionary.py b/apps_schema/attrs/dictionary.py similarity index 85% rename from apps_validation/schema/attrs/dictionary.py rename to apps_schema/attrs/dictionary.py index f9b6072..db8fbd7 100644 --- a/apps_validation/schema/attrs/dictionary.py +++ b/apps_schema/attrs/dictionary.py @@ -12,7 +12,7 @@ def __init__(self, data): self._skip_data_values = ['attrs'] def initialize_values(self, data): - from apps_validation.schema.variable import Variable + from apps_schema.variable import Variable super().initialize_values(data) self.attrs = [Variable(d) for d in (data.get('attrs') or [])] @@ -22,7 +22,7 @@ def json_schema(self): schema['properties']['attrs'] = {'type': 'array'} schema['required'].append('attrs') # We do not validate nested children and hence do not add it in the - # json schema as it makes it very complex to handle all the possibilities + # json apps_schema as it makes it very complex to handle all the possibilities return schema diff --git a/apps_validation/schema/attrs/integer.py b/apps_schema/attrs/integer.py similarity index 100% rename from apps_validation/schema/attrs/integer.py rename to apps_schema/attrs/integer.py diff --git a/apps_validation/schema/attrs/string.py b/apps_schema/attrs/string.py similarity index 100% rename from apps_validation/schema/attrs/string.py rename to apps_schema/attrs/string.py diff --git a/apps_validation/schema/attrs/utils.py b/apps_schema/attrs/utils.py similarity index 100% rename from apps_validation/schema/attrs/utils.py rename to apps_schema/attrs/utils.py diff --git a/apps_validation/schema/features/__init__.py b/apps_schema/features/__init__.py similarity index 100% rename from apps_validation/schema/features/__init__.py rename to apps_schema/features/__init__.py diff --git a/apps_validation/schema/features/acl.py b/apps_schema/features/acl.py similarity index 70% rename from apps_validation/schema/features/acl.py rename to apps_schema/features/acl.py index e6c5a8c..2495438 100644 --- a/apps_validation/schema/features/acl.py +++ b/apps_schema/features/acl.py @@ -1,4 +1,4 @@ -from apps_validation.schema.attrs import DictSchema +from apps_schema.attrs import DictSchema from .base import BaseFeature diff --git a/apps_validation/schema/features/base.py b/apps_schema/features/base.py similarity index 100% rename from apps_validation/schema/features/base.py rename to apps_schema/features/base.py diff --git a/apps_validation/schema/features/basic.py b/apps_schema/features/basic.py similarity index 80% rename from apps_validation/schema/features/basic.py rename to apps_schema/features/basic.py index d505f39..0fa5593 100644 --- a/apps_validation/schema/features/basic.py +++ b/apps_schema/features/basic.py @@ -1,4 +1,4 @@ -from apps_validation.schema.attrs import DictSchema, StringSchema +from apps_schema.attrs import DictSchema, StringSchema from .base import BaseFeature diff --git a/apps_validation/schema/features/certificate.py b/apps_schema/features/certificate.py similarity index 83% rename from apps_validation/schema/features/certificate.py rename to apps_schema/features/certificate.py index 4a0f107..e39940e 100644 --- a/apps_validation/schema/features/certificate.py +++ b/apps_schema/features/certificate.py @@ -1,4 +1,4 @@ -from apps_validation.schema.attrs import IntegerSchema +from apps_schema.attrs import IntegerSchema from .base import BaseFeature diff --git a/apps_validation/schema/features/container_image.py b/apps_schema/features/container_image.py similarity index 90% rename from apps_validation/schema/features/container_image.py rename to apps_schema/features/container_image.py index a1df45c..8b08160 100644 --- a/apps_validation/schema/features/container_image.py +++ b/apps_schema/features/container_image.py @@ -1,4 +1,4 @@ -from apps_validation.schema.attrs import DictSchema, StringSchema +from apps_schema.attrs import DictSchema, StringSchema from .base import BaseFeature diff --git a/apps_validation/schema/features/interface.py b/apps_schema/features/interface.py similarity index 81% rename from apps_validation/schema/features/interface.py rename to apps_schema/features/interface.py index 447cd3e..a01694c 100644 --- a/apps_validation/schema/features/interface.py +++ b/apps_schema/features/interface.py @@ -1,4 +1,4 @@ -from apps_validation.schema.attrs import DictSchema, StringSchema +from apps_schema.attrs import DictSchema, StringSchema from .base import BaseFeature diff --git a/apps_validation/schema/features/ix_volume.py b/apps_schema/features/ix_volume.py similarity index 96% rename from apps_validation/schema/features/ix_volume.py rename to apps_schema/features/ix_volume.py index 1c71bac..5a0ceec 100644 --- a/apps_validation/schema/features/ix_volume.py +++ b/apps_schema/features/ix_volume.py @@ -1,4 +1,4 @@ -from apps_validation.schema.attrs import DictSchema, StringSchema +from apps_schema.attrs import DictSchema, StringSchema from .base import BaseFeature diff --git a/apps_validation/schema/features/node.py b/apps_schema/features/node.py similarity index 79% rename from apps_validation/schema/features/node.py rename to apps_schema/features/node.py index 525a850..0aad319 100644 --- a/apps_validation/schema/features/node.py +++ b/apps_schema/features/node.py @@ -1,4 +1,4 @@ -from apps_validation.schema.attrs import IntegerSchema, StringSchema +from apps_schema.attrs import IntegerSchema, StringSchema from .base import BaseFeature diff --git a/apps_validation/schema/features/utils.py b/apps_schema/features/utils.py similarity index 100% rename from apps_validation/schema/features/utils.py rename to apps_schema/features/utils.py diff --git a/apps_validation/schema/variable.py b/apps_schema/variable.py similarity index 86% rename from apps_validation/schema/variable.py rename to apps_schema/variable.py index 4a795eb..cfbdc81 100644 --- a/apps_validation/schema/variable.py +++ b/apps_schema/variable.py @@ -21,10 +21,10 @@ def validate(self, schema): verrors.add(f'{schema}.variable', 'Variable value must be specified') if not self.schema: - verrors.add(f'{schema}.schema', 'Schema must be specified for variable') + verrors.add(f'{schema}.apps_schema', 'Schema must be specified for variable') else: try: - self.schema.validate(f'{schema}.schema') + self.schema.validate(f'{schema}.apps_schema') except ValidationErrors as ve: verrors.extend(ve) diff --git a/apps_validation/ci/git.py b/apps_validation/ci/git.py index 6737663..7d12a06 100644 --- a/apps_validation/ci/git.py +++ b/apps_validation/ci/git.py @@ -2,11 +2,11 @@ import subprocess from collections import defaultdict +from apps_validation.exceptions import CatalogDoesNotExist from catalog_reader.dev_directory import ( DEV_DIRECTORY_RELATIVE_PATH, get_ci_development_directory, OPTIONAL_METADATA_FILES ) from catalog_reader.train_utils import is_train_valid -from apps_validation.exceptions import CatalogDoesNotExist def get_changed_apps(catalog_path: str, base_branch: str = 'master') -> dict: diff --git a/apps_validation/pytest/unit/test_attr_schema.py b/apps_validation/pytest/unit/test_attr_schema.py index ea20390..eaa72e2 100644 --- a/apps_validation/pytest/unit/test_attr_schema.py +++ b/apps_validation/pytest/unit/test_attr_schema.py @@ -1,10 +1,10 @@ import pytest from apps_validation.exceptions import ValidationErrors -from apps_validation.schema.attrs import get_schema +from apps_schema.attrs import get_schema -@pytest.mark.parametrize('schema,should_work', [ +@pytest.mark.parametrize('apps_schema,should_work', [ ( { 'type': 'dict', diff --git a/apps_validation/schema/__init__.py b/apps_validation/schema/__init__.py deleted file mode 100644 index 26018be..0000000 --- a/apps_validation/schema/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# FIXME: We need to account for migration schema diff --git a/apps_validation/scripts/catalog_update.py b/apps_validation/scripts/catalog_update.py index 1e68d15..60ad2db 100644 --- a/apps_validation/scripts/catalog_update.py +++ b/apps_validation/scripts/catalog_update.py @@ -8,16 +8,16 @@ from jsonschema import validate as json_schema_validate, ValidationError as JsonValidationError +from apps_validation.ci.names import CACHED_CATALOG_FILE_NAME, CACHED_VERSION_FILE_NAME +from apps_validation.exceptions import ValidationErrors +from apps_validation.validation.json_schema_utils import CATALOG_JSON_SCHEMA +from apps_validation.validation.validate_app_version import validate_catalog_item_version_data from catalog_reader.catalog import retrieve_train_names, retrieve_trains_data, get_apps_in_trains from catalog_reader.dev_directory import ( get_app_version, get_ci_development_directory, get_to_keep_versions, OPTIONAL_METADATA_FILES, REQUIRED_METADATA_FILES, version_has_been_bumped, ) from catalog_reader.train_utils import get_train_path -from apps_validation.ci.names import CACHED_CATALOG_FILE_NAME, CACHED_VERSION_FILE_NAME -from apps_validation.exceptions import ValidationErrors -from apps_validation.validation.json_schema_utils import CATALOG_JSON_SCHEMA -from apps_validation.validation.validate_app_version import validate_catalog_item_version_data def get_trains(location: str) -> typing.Tuple[dict, dict]: diff --git a/apps_validation/validation/validate_app_version.py b/apps_validation/validation/validate_app_version.py index 585214b..a0db599 100644 --- a/apps_validation/validation/validate_app_version.py +++ b/apps_validation/validation/validate_app_version.py @@ -5,8 +5,8 @@ from jsonschema import validate as json_schema_validate, ValidationError as JsonValidationError from semantic_version import Version -from catalog_reader.questions_util import CUSTOM_PORTALS_KEY from apps_validation.exceptions import ValidationErrors +from catalog_reader.questions_util import CUSTOM_PORTALS_KEY from .app_version import validate_app_version_file from .ix_values import validate_ix_values_schema @@ -76,7 +76,7 @@ def validate_catalog_item_version( except ValidationErrors as v: verrors.extend(v) - # validate_app_migrations(verrors, version_path, f'{schema}.app_migrations') + # validate_app_migrations(verrors, version_path, f'{apps_schema}.app_migrations') # FIXME: Add validation for app migrations verrors.check() diff --git a/apps_validation/validation/validate_catalog.py b/apps_validation/validation/validate_catalog.py index 8bf2621..f74eb19 100644 --- a/apps_validation/validation/validate_catalog.py +++ b/apps_validation/validation/validate_catalog.py @@ -5,8 +5,8 @@ from jsonschema import validate as json_schema_validate, ValidationError as JsonValidationError from apps_validation.ci.names import CACHED_CATALOG_FILE_NAME -from catalog_reader.train_utils import get_train_path from apps_validation.exceptions import CatalogDoesNotExist, ValidationErrors +from catalog_reader.train_utils import get_train_path from .json_schema_utils import CATALOG_JSON_SCHEMA from .validate_app_rename_migrations import validate_migrations diff --git a/apps_validation/validation/validate_dev_directory.py b/apps_validation/validation/validate_dev_directory.py index 9b7f404..95b2f8d 100644 --- a/apps_validation/validation/validate_dev_directory.py +++ b/apps_validation/validation/validate_dev_directory.py @@ -3,12 +3,12 @@ from jsonschema import ValidationError as JsonValidationError +from apps_validation.exceptions import ValidationErrors from catalog_reader.dev_directory import ( get_app_version, get_ci_development_directory, get_to_keep_versions, REQUIRED_METADATA_FILES, version_has_been_bumped, ) from catalog_reader.names import UPGRADE_STRATEGY_FILENAME, TO_KEEP_VERSIONS -from apps_validation.exceptions import ValidationErrors from .app_version import validate_app_version_file from .validate_app_version import validate_catalog_item_version diff --git a/apps_validation/validation/validate_questions.py b/apps_validation/validation/validate_questions.py index 18e821e..31594c0 100644 --- a/apps_validation/validation/validate_questions.py +++ b/apps_validation/validation/validate_questions.py @@ -1,10 +1,10 @@ import typing import yaml +from apps_schema.variable import Variable +from apps_validation.exceptions import ValidationErrors from catalog_reader.questions import CUSTOM_PORTALS_ENABLE_KEY, CUSTOM_PORTAL_GROUP_KEY from catalog_reader.questions_util import CUSTOM_PORTALS_KEY -from apps_validation.exceptions import ValidationErrors -from apps_validation.schema.variable import Variable from .utils import validate_key_value_types @@ -49,7 +49,7 @@ def validate_questions_yaml(questions_yaml_path: str, schema: str): if not isinstance(portal_type, str): verrors.add(error_schema, 'Portal type must be a string') if not isinstance(portal_schema, dict): - verrors.add(error_schema, 'Portal schema must be a dictionary') + verrors.add(error_schema, 'Portal apps_schema must be a dictionary') else: validate_key_value_types( portal_schema, (('protocols', list), ('host', list), ('ports', list), ('path', str, False)), @@ -109,9 +109,9 @@ def validate_question( variable_type = schema_data['type'] for condition, key, schema_str in ( - (variable_type != 'list', 'subquestions', f'{schema}.schema.subquestions'), - (variable_type == 'list', 'items', f'{schema}.schema.items'), - (variable_type == 'dict', 'attrs', f'{schema}.schema.attrs'), + (variable_type != 'list', 'subquestions', f'{schema}.apps_schema.subquestions'), + (variable_type == 'list', 'items', f'{schema}.apps_schema.items'), + (variable_type == 'dict', 'attrs', f'{schema}.apps_schema.attrs'), ): if not (condition and type(schema_data.get(key)) == list): continue diff --git a/apps_validation/validation/validate_recommended_apps.py b/apps_validation/validation/validate_recommended_apps.py index 5bc4f4b..0b418b5 100644 --- a/apps_validation/validation/validate_recommended_apps.py +++ b/apps_validation/validation/validate_recommended_apps.py @@ -3,8 +3,8 @@ from jsonschema import validate as json_schema_validate, ValidationError as JsonValidationError -from catalog_reader.names import RECOMMENDED_APPS_FILENAME from apps_validation.exceptions import ValidationErrors +from catalog_reader.names import RECOMMENDED_APPS_FILENAME from .json_schema_utils import RECOMMENDED_APPS_JSON_SCHEMA diff --git a/catalog_reader/app.py b/catalog_reader/app.py index d6de873..e68cf93 100644 --- a/catalog_reader/app.py +++ b/catalog_reader/app.py @@ -152,7 +152,7 @@ def get_app_version_details( ('chart_metadata', 'app.yaml', yaml.safe_load), ('app_metadata', 'metadata.yaml', yaml.safe_load), ('schema', 'questions.yaml', yaml.safe_load), - ('readme', 'README.md', markdown.markdown), # TODO: Has been changed, make sure json schema accounts for it + ('readme', 'README.md', markdown.markdown), # TODO: Has been changed, make sure json apps_schema accounts for it ('changelog', 'CHANGELOG.md', markdown.markdown), ): if os.path.exists(os.path.join(version_path, filename)): diff --git a/catalog_reader/supported_version.py b/catalog_reader/supported_version.py index 7108501..58f9bb6 100644 --- a/catalog_reader/supported_version.py +++ b/catalog_reader/supported_version.py @@ -1,4 +1,4 @@ -from apps_validation.schema.features import FEATURES +from apps_schema.features import FEATURES def version_supported(version_details: dict) -> bool: diff --git a/setup.py b/setup.py index 4ed2471..5b6faba 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,14 @@ description='Validate TrueNAS Apps Catalog', version=VERSION, include_package_data=True, - packages=find_packages(include=['apps_validation', 'catalog_reader', 'apps_validation.*', 'catalog_reader.*']), + packages=find_packages(include=[ + 'apps_schema', + 'apps_schema.*', + 'apps_validation', + 'apps_validation.*', + 'catalog_reader', + 'catalog_reader.*' + ]), license='GNU3', platforms='any', entry_points={