From 357c34c8b79d331dd55ff26226a6bcddccd83f50 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Fri, 20 Sep 2024 04:38:12 +0500 Subject: [PATCH 1/2] Grab capabilities/run as context from latest app version available --- apps_ci/scripts/catalog_update.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps_ci/scripts/catalog_update.py b/apps_ci/scripts/catalog_update.py index cb1c51d..f295ced 100644 --- a/apps_ci/scripts/catalog_update.py +++ b/apps_ci/scripts/catalog_update.py @@ -40,6 +40,17 @@ def get_trains(location: str) -> typing.Tuple[dict, dict]: else: catalog_data[train_name][app_name][k] = v + # We will add capabilities and run as context from latest version to catalog data now + latest_version = app_data.get('latest_version') + metadata_info = {'capabilities': [], 'run_as_context': []} + if latest_version in app_data.get('versions', {}): + version_metadata_info = app_data['versions'][latest_version].get('app_metadata', {}) + metadata_info.update({ + 'capabilities': version_metadata_info.get('capabilities', metadata_info['capabilities']), + 'run_as_context': version_metadata_info.get('run_as_context', metadata_info['run_as_context']), + }) + catalog_data[train_name][app_name].update(metadata_info) + return catalog_data, versions_data From a8d0da707b86b20041adac604a148583dcc32ef8 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Fri, 20 Sep 2024 23:15:55 +0500 Subject: [PATCH 2/2] Update json schema --- apps_validation/json_schema_utils.py | 57 ++++++++++++++++------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/apps_validation/json_schema_utils.py b/apps_validation/json_schema_utils.py index 573f4eb..1f06805 100644 --- a/apps_validation/json_schema_utils.py +++ b/apps_validation/json_schema_utils.py @@ -17,6 +17,34 @@ }, 'required': ['categories'], } + +APP_CAPABILITIES_SCHEMA = { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'description': {'type': 'string'}, + 'name': {'type': 'string'}, + }, + 'required': ['description', 'name'], + }, +} + +APP_RUN_AS_CONTEXT_SCHEMA = { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'description': {'type': 'string'}, + 'gid': {'type': 'integer'}, + 'group_name': {'type': 'string'}, + 'user_name': {'type': 'string'}, + 'uid': {'type': 'integer'}, + }, + 'required': ['description'], + }, +} + APP_METADATA_JSON_SCHEMA = { 'type': 'object', 'properties': { @@ -62,31 +90,8 @@ 'pattern': '[0-9]+.[0-9]+.[0-9]+', }, 'lib_version_hash': {'type': 'string'}, - 'run_as_context': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'description': {'type': 'string'}, - 'gid': {'type': 'integer'}, - 'group_name': {'type': 'string'}, - 'user_name': {'type': 'string'}, - 'uid': {'type': 'integer'}, - }, - 'required': ['description'], - }, - }, - 'capabilities': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'description': {'type': 'string'}, - 'name': {'type': 'string'}, - }, - 'required': ['description', 'name'], - }, - }, + 'run_as_context': APP_RUN_AS_CONTEXT_SCHEMA, + 'capabilities': APP_CAPABILITIES_SCHEMA, 'host_mounts': { 'type': 'array', 'items': { @@ -219,6 +224,8 @@ 'icon_url': { 'type': ['string', 'null'], }, + 'run_as_context': APP_RUN_AS_CONTEXT_SCHEMA, + 'capabilities': APP_CAPABILITIES_SCHEMA, 'maintainers': { 'type': 'array', 'items': {