From cc08b9bd847a2ab99db6b9cefcc0acf7b7485b91 Mon Sep 17 00:00:00 2001 From: gqp <446105468@qq.com> Date: Tue, 12 Nov 2024 11:57:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=90=E4=BE=9B=20Agent=20=E5=8C=85?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0=E5=9F=BA=E7=A1=80=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20(closed=20#1683)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/node_man/handlers/gse_package.py | 10 ++++++---- apps/node_man/tools/gse_package.py | 3 ++- apps/node_man/views/package_manage.py | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/node_man/handlers/gse_package.py b/apps/node_man/handlers/gse_package.py index 7f2870075..8a4cd51f1 100644 --- a/apps/node_man/handlers/gse_package.py +++ b/apps/node_man/handlers/gse_package.py @@ -186,9 +186,10 @@ def handle_add_tag(cls, tag_description: str, package_obj: GsePackages, package_ :param package_desc_obj: Gse包描述记录 """ # 如果新增的是内置标签,将原有的内置标签中的target_version进行修改即可,否则创建一个新的标签 - if tag_description in constants.BUILT_IN_TAG_DESCRIPTIONS: + if tag_description in constants.BUILT_IN_TAG_DESCRIPTIONS + constants.BUILT_IN_TAG_NAMES: Tag.objects.filter( - name=constants.TAG_DESCRIPTION__TAG_NAME[tag_description], target_id=package_desc_obj.id + name=constants.TAG_DESCRIPTION__TAG_NAME.get(tag_description, tag_description), + target_id=package_desc_obj.id, ).update(target_version=package_obj.version) else: tag: Tag = Tag.objects.filter(description=tag_description, target_id=package_desc_obj.id).first() @@ -219,9 +220,10 @@ def handle_update_tag( # 如果目标标签为内置标签的话,将内置标签的target_version进行覆盖,并对原来的标签进行删除或者清空 # 如果目标标签为自定义标签,原有标签为内置标签的话,原有标签target_version置空,并新增自定义标签 # 否则(目标和原有都为自定义标签)将直接修改原有标签的target_version - if tag_description in constants.BUILT_IN_TAG_DESCRIPTIONS: + if tag_description in constants.BUILT_IN_TAG_DESCRIPTIONS + constants.BUILT_IN_TAG_NAMES: Tag.objects.filter( - name=constants.TAG_DESCRIPTION__TAG_NAME[tag_description], target_id=package_desc_obj.id + name=constants.TAG_DESCRIPTION__TAG_NAME.get(tag_description, tag_description), + target_id=package_desc_obj.id, ).update(target_version=package_obj.version) cls.handle_delete_tag(tag_obj.name, tag_obj) elif tag_obj.name in constants.BUILT_IN_TAG_NAMES: diff --git a/apps/node_man/tools/gse_package.py b/apps/node_man/tools/gse_package.py index 7f153c884..15a96b4eb 100644 --- a/apps/node_man/tools/gse_package.py +++ b/apps/node_man/tools/gse_package.py @@ -112,9 +112,10 @@ def create_agent_tags(cls, tag_descriptions, project): project=project, category=CategoryType.official ) - if tag_description in constants.BUILT_IN_TAG_DESCRIPTIONS: + if tag_description in constants.BUILT_IN_TAG_DESCRIPTIONS + constants.BUILT_IN_TAG_NAMES: # 内置标签,手动指定name和description name: str = constants.TAG_DESCRIPTION__TAG_NAME[tag_description] + tag_description = constants.TAG_NAME__TAG_DESCRIPTION.get(tag_description, tag_description) else: # 自定义标签,自动生成name name: str = GsePackageTools.generate_name_by_description(tag_description) diff --git a/apps/node_man/views/package_manage.py b/apps/node_man/views/package_manage.py index e270b5835..bd70240f6 100644 --- a/apps/node_man/views/package_manage.py +++ b/apps/node_man/views/package_manage.py @@ -657,6 +657,8 @@ def version(self, request): } machine_latest_version: str = "" + if validated_data.get("versions", ""): + machine_latest_version = max(validated_data["versions"], key=GsePackageTools.extract_numbers) package_latest_version = list(version__pkg_version_info_map.keys())[0] if version__pkg_version_info_map else "" return Response(