Skip to content

Commit

Permalink
feat: 安装预设插件锁定版本(closed #2482)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpyoung3 committed Nov 12, 2024
1 parent ab9249e commit a9b1fcc
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions apps/backend/components/collections/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ def _execute(self, data, parent_data, common_data: PluginCommonData):
version_str = tag_name__obj_map[package.version].target_version
biz_version = self.get_biz_version(package, bk_biz_id)
if biz_version and version.Version(version_str) > version.Version(biz_version):
version_str = self.get_biz_package_version(
policy_step_adapter, package.project, os_type, cpu_arch, biz_version
)
version_str = biz_version
process_status_property = dict(
bk_host_id=bk_host_id,
name=plugin_name,
Expand Down Expand Up @@ -335,20 +333,20 @@ def _execute(self, data, parent_data, common_data: PluginCommonData):
batch_size=self.batch_size,
)

def get_biz_package_version(
self, policy_step_adapter: PolicyStepAdapter, plugin_name: str, os_type: str, cpu_arch: str, biz_version: str
):
packages = policy_step_adapter.get_packages(plugin_name, biz_version, biz_version)
os_cpu__biz_pkg_map = {
policy_step_adapter.get_os_key(package.os, package.cpu_arch): package for package in packages
}
if not os_cpu__biz_pkg_map:
raise errors.PluginValidationError(
msg="插件 [{name}-{versions}] 不存在".format(name=self.plugin_name, versions=biz_version)
)
package = os_cpu__biz_pkg_map[policy_step_adapter.get_os_key(os_type, cpu_arch)]
version_str = getattr(package, "version", "")
return version_str
# def get_biz_package_version(
# self, policy_step_adapter: PolicyStepAdapter, plugin_name: str, os_type: str, cpu_arch: str, biz_version: str
# ):
# packages = policy_step_adapter.get_packages(plugin_name, biz_version, biz_version)
# os_cpu__biz_pkg_map = {
# policy_step_adapter.get_os_key(package.os, package.cpu_arch): package for package in packages
# }
# if not os_cpu__biz_pkg_map:
# raise errors.PluginValidationError(
# msg="插件 [{name}-{versions}] 不存在".format(name=self.plugin_name, versions=biz_version)
# )
# package = os_cpu__biz_pkg_map[policy_step_adapter.get_os_key(os_type, cpu_arch)]
# version_str = getattr(package, "version", "")
# return version_str

@staticmethod
def get_biz_version(package: models.Packages, bk_biz_id: int):
Expand Down

0 comments on commit a9b1fcc

Please sign in to comment.