From 7758c4e67bc61b9eb3a83e4d41128a7661b2303f Mon Sep 17 00:00:00 2001 From: schnee Date: Mon, 21 Oct 2024 19:58:45 +0800 Subject: [PATCH] feat: update apiserver python version to 3.11.10 (#1655) --- apiserver/Dockerfile | 22 +- apiserver/Makefile | 2 +- apiserver/README.md | 27 +- .../unittest/Dockerfile.devops.unittest | 27 +- apiserver/paasng/conf.yaml.tpl | 2 +- .../paas_wl/bk_app/applications/constants.py | 6 +- .../paas_wl/bk_app/cnative/specs/constants.py | 36 +-- .../paas_wl/bk_app/dev_sandbox/entities.py | 4 +- .../bk_app/monitoring/bklog/constants.py | 4 +- .../paas_wl/bk_app/processes/constants.py | 8 +- .../paas_wl/infras/cluster/constants.py | 6 +- .../infras/resource_templates/constants.py | 4 +- .../paas_wl/infras/resources/base/kres.py | 14 +- .../paas_wl/infras/resources/utils/basic.py | 7 +- apiserver/paasng/paas_wl/utils/basic.py | 2 +- apiserver/paasng/paas_wl/utils/blobstore.py | 8 +- apiserver/paasng/paas_wl/utils/constants.py | 10 +- apiserver/paasng/paas_wl/utils/kubestatus.py | 4 +- .../workloads/autoscaling/constants.py | 12 +- .../paas_wl/workloads/networking/constants.py | 6 +- .../networking/entrance/allocator/domains.py | 5 +- .../networking/entrance/allocator/subpaths.py | 5 +- .../networking/entrance/constants.py | 8 +- .../workloads/networking/ingress/constants.py | 6 +- .../workloads/release_controller/constants.py | 6 +- .../paasng/paasng/accessories/ci/constants.py | 4 +- .../paasng/accessories/cloudapi/constants.py | 14 +- .../paasng/paasng/accessories/log/client.py | 9 +- .../paasng/accessories/log/constants.py | 8 +- .../accessories/paas_analysis/constants.py | 10 +- .../accessories/publish/market/constant.py | 8 +- .../accessories/servicehub/constants.py | 9 +- .../accessories/servicehub/remote/manager.py | 6 +- .../services/providers/mysql/constants.py | 5 +- .../accessories/smart_advisor/constants.py | 4 +- .../paasng/bk_plugins/bk_plugins/constants.py | 4 +- .../pluginscenter/bk_devops/constants.py | 4 +- .../bk_plugins/pluginscenter/constants.py | 36 +-- .../pluginscenter/iam_adaptor/constants.py | 6 +- .../pluginscenter/itsm_adaptor/constants.py | 6 +- .../bk_plugins/pluginscenter/log/client.py | 2 +- .../paasng/infras/accounts/constants.py | 11 +- .../infras/accounts/permissions/constants.py | 4 +- .../paasng/paasng/infras/bk_ci/constants.py | 4 +- .../paasng/paasng/infras/bk_log/constatns.py | 8 +- .../paasng/infras/bkmonitorv3/constants.py | 4 +- .../paasng/paasng/infras/iam/constants.py | 6 +- apiserver/paasng/paasng/infras/iam/legacy.py | 4 +- .../paasng/infras/iam/open_apis/constants.py | 4 +- .../iam/permissions/resources/application.py | 4 +- .../paasng/paasng/misc/audit/constants.py | 12 +- .../misc/monitoring/metrics/constants.py | 9 +- .../monitor/alert_rules/config/entities.py | 4 +- .../paasng/paasng/misc/operations/models.py | 2 +- .../management/commands/adm_mapper_v1.py | 24 +- .../paasng/paasng/plat_admin/numbers/app.py | 4 +- .../paasng/plat_admin/system/constants.py | 5 +- .../paasng/platform/applications/constants.py | 28 +-- .../management/commands/force_del_app.py | 4 +- .../paasng/platform/bkapp_model/constants.py | 24 +- .../paasng/platform/bkapp_model/utils.py | 4 +- .../paasng/platform/declarative/constants.py | 8 +- .../paasng/platform/engine/constants.py | 20 +- .../paasng/platform/engine/models/phases.py | 4 +- .../platform/engine/processes/events.py | 10 +- .../paasng/platform/engine/utils/output.py | 4 +- .../paasng/platform/environments/constants.py | 5 +- .../paasng/platform/evaluation/constants.py | 10 +- .../paasng/platform/mgrlegacy/constants.py | 4 +- .../paasng/platform/modules/constants.py | 17 +- .../paasng/platform/smart_app/constants.py | 4 +- .../paasng/platform/sourcectl/client.py | 6 +- .../paasng/platform/sourcectl/constants.py | 12 +- .../paasng/platform/sourcectl/exceptions.py | 4 + .../paasng/platform/sourcectl/source_types.py | 3 +- .../paasng/platform/templates/constants.py | 4 +- apiserver/paasng/paasng/utils/blobstore.py | 4 +- .../paasng/paasng/utils/patternmatcher.py | 4 +- .../paasng/utils/rate_limit/constants.py | 4 +- apiserver/poetry.lock | 234 +++++++----------- apiserver/pyproject.toml | 25 +- pyproject.toml | 5 +- 82 files changed, 416 insertions(+), 520 deletions(-) diff --git a/apiserver/Dockerfile b/apiserver/Dockerfile index fb06ccfaa0..6f016d0969 100644 --- a/apiserver/Dockerfile +++ b/apiserver/Dockerfile @@ -22,29 +22,19 @@ ADD ./configs ./configs RUN EDITION=${EDITION} npm run build ################# PaaS ################# -FROM python:3.8.13-slim-buster +FROM python:3.11.10-slim-bullseye USER root -RUN apt-get update && apt-get install -y gcc subversion ssh default-libmysqlclient-dev pkg-config vim +RUN apt-get update && apt-get install -y gcc subversion ssh default-libmysqlclient-dev pkg-config vim git -# Add buster-backports to sources.list -RUN echo "deb http://archive.debian.org/debian buster-backports main" >> /etc/apt/sources.list -# Install git from backports, because the version(git:v2.20.1) in buster will leak usernames from the url -# And this bug is fixed in v2.22.0, so we should install git from buster-backports, which is v2.30.2-1 -# See more info at: https://packages.debian.org/buster-backports/git -# -# Update(2024-05-07): The GitClient class has added a new logic to remove sensitive information -# in the git command output, so a newer git version is no longer required to fix the username leakage. -RUN apt-get update && apt-get -y install -t buster-backports git - -RUN mkdir ~/.pip && printf '[global]\nindex-url = https://mirrors.cloud.tencent.com/pypi/simple/\n' > ~/.pip/pip.conf +RUN mkdir ~/.pip && printf '[global]\nindex-url = https://mirrors.cloud.tencent.com/pypi/simple/\n' > ~/.pip/pip.conf ENV LC_ALL=C.UTF-8 \ LANG=C.UTF-8 RUN pip install --upgrade 'pip<24.1' -RUN pip install poetry==1.3.2 +RUN pip install poetry==1.8.3 # Change security level of openssl to lower value in order to avoid "CA_MD_TOO_WEAK" error # See https://stackoverflow.com/questions/52218876/how-to-fix-ssl-issue-ssl-ctx-use-certificate-ca-md-too-weak-on-python-zeep?rq=1 @@ -56,8 +46,7 @@ ADD ./pyproject.toml . ADD ./poetry.lock . # Install dependecies in system -# Disable "new installer" to fix https://github.com/python-poetry/poetry/issues/6301 -RUN poetry config virtualenvs.create false && poetry config experimental.new-installer false && poetry install --no-dev +RUN poetry config virtualenvs.create false && poetry install --no-dev ARG BKPAAS_BUILD_VERSION="tag: null, commitID: ^HEAD, buildID: null, buildTime: null" ENV BKPAAS_BUILD_VERSION=${BKPAAS_BUILD_VERSION} @@ -67,7 +56,6 @@ RUN mkdir -p ./public COPY --from=admin42 /build/paasng/public ./public ADD ./paasng . - # Add extra files: static assets & I18N .mo translation file. # "gettext" package is required for running "compilemessages" diff --git a/apiserver/Makefile b/apiserver/Makefile index 0c4c829695..fc13a993cb 100644 --- a/apiserver/Makefile +++ b/apiserver/Makefile @@ -8,7 +8,7 @@ init-pre-commit: ## 初始化 pre-commit pre-commit install init-py-dep: ## 初始化 python 依赖包 - pip install poetry==1.3.2 + pip install poetry==1.8.3 poetry install init-node-dep: ## 初始化 nodejs diff --git a/apiserver/README.md b/apiserver/README.md index 21c8791ed3..2ebfe50611 100644 --- a/apiserver/README.md +++ b/apiserver/README.md @@ -28,16 +28,16 @@ apiserver 为 blueking-paas 项目的主控模块。 ### 准备 Python 开发环境 -1. 安装 Python 3.8 +1. 安装 Python 3.11 我们推荐使用 [pyenv](https://github.com/pyenv/pyenv) 管理本地的 python 环境 - 依照 [相关指引](https://github.com/pyenv/pyenv#getting-pyenv) 安装 pyenv -- 使用 pyenv 安装 Python 3.8 +- 使用 pyenv 安装 Python 3.11 ```shell -❯ pyenv install 3.8.13 +❯ pyenv install 3.11.10 ``` 2. 安装项目依赖 @@ -62,11 +62,12 @@ apiserver 项目的管理端(Admin42)使用 Nodejs 进行开发, 如需开 1. 安装 [Nodejs](https://github.com/nodejs),推荐使用 v14.21.1 版本 我们推荐使用 [nvm](https://github.com/nvm-sh/nvm) 管理本地的 nodejs 环境 + - 依照 [相关指引](https://github.com/nvm-sh/nvm#installing-and-updating) 安装 nvm - 使用 nvm 安装 nodejs 14 ```shell -❯ nvm install 14 +❯ nvm install 14 ``` 2. 安装项目依赖 @@ -185,9 +186,9 @@ Nodejs 组件开发模式与常规的 Nodejs 项目无异, 但为了更方便地 本项目未使用任何 `JavaScript 模块化技术`, 即所有组件都需要自行往 `window` 对象挂载, 例如: ```javascript -import Vue from 'vue' +import Vue from "vue"; -window.Vue = Vue +window.Vue = Vue; ``` 否则, `Django Template` 将无法直接使用 Nodejs 中的组件。 @@ -195,7 +196,7 @@ window.Vue = Vue #### Template 页面开发指引 Template 页面开发模式与常规的 Django 项目无异, 但是使用了 [Vuejs](https://cn.vuejs.org/) -和 [MagicBox Vue组件库](https://magicbox.bk.tencent.com/static_api/v3/components_vue/2.0/example/index.html#/) +和 [MagicBox Vue 组件库](https://magicbox.bk.tencent.com/static_api/v3/components_vue/2.0/example/index.html#/) 完成前端的功能开发。 在开发新的 Template 模板时应该遵循以下规范: @@ -242,7 +243,7 @@ class SysBkPluginLogsViewset(viewsets.ViewSet): 要点如下: 1. 使用 `@ForceAllowAuthedApp.mark_view_set` 装饰视图类后,如果请求携带了经认证的有效应用身份(经由 API 网关完成认证与权限校验),平台将自动创建一个角色为 `SYSTEM_API_BASIC_READER` 的系统账号,由它完成请求。 - - 后续如需要调整该账号的角色,可在 PaaS Admin 中完成。 + - 后续如需要调整该账号的角色,可在 PaaS Admin 中完成。 2. 使用 `@site_perm_required` 装饰视图函数,以保证请求只允许那些拥有系统级权限的账号访问(**非常重要,因为系统 API 一般都是用户无关,极容易发生越权问题。**) ## FAQ @@ -251,16 +252,6 @@ class SysBkPluginLogsViewset(viewsets.ViewSet): 如果在安装 docker 时, 安装了 docker-compose-plugin, 需要修改'blueking-paas/apiserver/dev_utils/bundle/start.sh' 中的 docker-compose 改为 docker compose -### poetry install 时 hash 值对不上问题 - -先执行 - -```shell -poetry config experimental.new-installer false -``` - -再重新执行 poetry install 即可 - ### admin42 页面 403 问题 需要进入数据库执行以下命令 diff --git a/apiserver/dev_utils/unittest/Dockerfile.devops.unittest b/apiserver/dev_utils/unittest/Dockerfile.devops.unittest index e4e721f194..342f1d44bc 100644 --- a/apiserver/dev_utils/unittest/Dockerfile.devops.unittest +++ b/apiserver/dev_utils/unittest/Dockerfile.devops.unittest @@ -22,41 +22,30 @@ ADD ./configs ./configs RUN EDITION=${EDITION} npm run build ################# PaaS ################# -FROM python:3.8.13-slim-buster +FROM python:3.11.10-slim-bullseye USER root -RUN apt-get update && apt-get install -y gcc subversion ssh default-libmysqlclient-dev pkg-config vim +RUN apt-get update && apt-get install -y gcc subversion ssh default-libmysqlclient-dev pkg-config vim git -# Add buster-backports to sources.list -RUN echo "deb http://archive.debian.org/debian buster-backports main" >> /etc/apt/sources.list -# Install git from backports, because the version(git:v2.20.1) in buster will leak usernames from the url -# And this bug is fixed in v2.22.0, so we should install git from buster-backports, which is v2.30.2-1 -# See more info at: https://packages.debian.org/buster-backports/git -# -# Update(2024-05-07): The GitClient class has added a new logic to remove sensitive information -# in the git command output, so a newer git version is no longer required to fix the username leakage. -RUN apt-get update && apt-get -y install -t buster-backports git - -RUN mkdir ~/.pip && printf '[global]\nindex-url = https://mirrors.cloud.tencent.com/pypi/simple/\n' > ~/.pip/pip.conf +RUN mkdir ~/.pip && printf '[global]\nindex-url = https://mirrors.cloud.tencent.com/pypi/simple/\n' > ~/.pip/pip.conf ENV LC_ALL=C.UTF-8 \ LANG=C.UTF-8 +RUN pip install --upgrade 'pip<24.1' + +RUN pip install poetry==1.8.3 + # Change security level of openssl to lower value in order to avoid "CA_MD_TOO_WEAK" error # See https://stackoverflow.com/questions/52218876/how-to-fix-ssl-issue-ssl-ctx-use-certificate-ca-md-too-weak-on-python-zeep?rq=1 RUN sed -i "s/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=0/g" /etc/ssl/openssl.cnf -RUN pip install --upgrade pip -RUN pip install poetry==1.3.2 - WORKDIR /app ADD ./pyproject.toml . ADD ./poetry.lock . -# Disable "new installer" to fix https://github.com/python-poetry/poetry/issues/6301 -RUN poetry config virtualenvs.create false && poetry config experimental.new-installer false && poetry install - +RUN poetry config virtualenvs.create false && poetry install WORKDIR /app ADD ./paasng ./paasng diff --git a/apiserver/paasng/conf.yaml.tpl b/apiserver/paasng/conf.yaml.tpl index 5240fe6667..1f263bc7b1 100644 --- a/apiserver/paasng/conf.yaml.tpl +++ b/apiserver/paasng/conf.yaml.tpl @@ -3,7 +3,7 @@ ## 用于加密数据库内容的 Secret # BKKRILL_ENCRYPT_SECRET_KEY: '' -## 选择加密数据库内容的算法,可选择:'SHANGMI' , 'CLASSIC',分别对应 'SM4CTR'和'Fernet' 算法 +## 选择加密数据库内容的算法,可选值:'SHANGMI', 'CLASSIC',分别对应 'SM4CTR' 和 'FernetCipher' 算法 # BK_CRYPTO_TYPE : '' ## (Django)特定 Django 安装的密钥。用于提供 加密签名,默认值为:${BKKRILL_ENCRYPT_SECRET_KEY} diff --git a/apiserver/paasng/paas_wl/bk_app/applications/constants.py b/apiserver/paasng/paas_wl/bk_app/applications/constants.py index 2c21040431..55dda7edf4 100644 --- a/apiserver/paasng/paas_wl/bk_app/applications/constants.py +++ b/apiserver/paasng/paas_wl/bk_app/applications/constants.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum -class WlAppType(str, StructuredEnum): +class WlAppType(StrStructuredEnum): """type of workloads app""" DEFAULT = EnumField("default") # 默认类型:无任何定制逻辑 @@ -28,7 +28,7 @@ class WlAppType(str, StructuredEnum): CLOUD_NATIVE = EnumField("cloud_native") -class ArtifactType(str, StructuredEnum): +class ArtifactType(StrStructuredEnum): """type of build artifact""" SLUG = EnumField("slug") diff --git a/apiserver/paasng/paas_wl/bk_app/cnative/specs/constants.py b/apiserver/paasng/paas_wl/bk_app/cnative/specs/constants.py index f84835fdd3..1141e816ce 100644 --- a/apiserver/paasng/paas_wl/bk_app/cnative/specs/constants.py +++ b/apiserver/paasng/paas_wl/bk_app/cnative/specs/constants.py @@ -15,7 +15,7 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ # Default resource limitations for each process @@ -66,14 +66,14 @@ PROC_SERVICES_ENABLED_ANNOTATION_KEY = "bkapp.paas.bk.tencent.com/proc-services-feature-enabled" -class ApiVersion(str, StructuredEnum): +class ApiVersion(StrStructuredEnum): """Kubernetes CRD API versions""" V1ALPHA1 = "paas.bk.tencent.com/v1alpha1" V1ALPHA2 = "paas.bk.tencent.com/v1alpha2" -class DeployStatus(str, StructuredEnum): +class DeployStatus(StrStructuredEnum): """Cloud-native app's deployment statuses""" PENDING = EnumField("pending", label=_("待实施")) @@ -90,7 +90,7 @@ def is_stable(cls, val: "DeployStatus") -> bool: return val in [DeployStatus.READY, DeployStatus.ERROR] -class DomainGroupSource(str, StructuredEnum): +class DomainGroupSource(StrStructuredEnum): """The source types for DomainGroup data""" SUBDOMAIN = "subdomain" @@ -98,14 +98,14 @@ class DomainGroupSource(str, StructuredEnum): CUSTOM = "custom" -class MResConditionType(str, StructuredEnum): +class MResConditionType(StrStructuredEnum): APP_AVAILABLE = EnumField("AppAvailable") APP_PROGRESSING = EnumField("AppProgressing") ADDONS_PROVISIONED = EnumField("AddOnsProvisioned") HOOKS_FINISHED = EnumField("HooksFinished") -class ConditionStatus(str, StructuredEnum): +class ConditionStatus(StrStructuredEnum): """k8s metav1.ConditionStatus""" TRUE = EnumField("True") @@ -113,7 +113,7 @@ class ConditionStatus(str, StructuredEnum): UNKNOWN = EnumField("Unknown") -class MResPhaseType(str, StructuredEnum): +class MResPhaseType(StrStructuredEnum): """a label for the condition of a BkApp at the current time.""" AppPending = EnumField("Pending") @@ -121,20 +121,14 @@ class MResPhaseType(str, StructuredEnum): AppFailed = EnumField("Failed") -class ScalingPolicy(str, StructuredEnum): +class ScalingPolicy(StrStructuredEnum): """ScalingPolicy is used to specify which policy should be used while scaling""" # the default autoscaling policy (cpu utilization 85%) DEFAULT = EnumField("default") - # simulate `ReprEnum` behavior to work well with DRF serializer - # see also: - # - https://docs.python.org/3/library/enum.html#enum.ReprEnum - # - https://docs.python.org/3/library/enum.html#enum.Enum.__str__ - __str__ = str.__str__ - -class ResQuotaPlan(str, StructuredEnum): +class ResQuotaPlan(StrStructuredEnum): """ResQuotaPlan is used to specify process resource quota""" P_DEFAULT = EnumField("default", label="default") @@ -142,14 +136,8 @@ class ResQuotaPlan(str, StructuredEnum): P_4C2G = EnumField("4C2G", label="4C2G") P_4C4G = EnumField("4C4G", label="4C4G") - # simulate `ReprEnum` behavior to work well with DRF serializer - # see also: - # - https://docs.python.org/3/library/enum.html#enum.ReprEnum - # - https://docs.python.org/3/library/enum.html#enum.Enum.__str__ - __str__ = str.__str__ - -class MountEnvName(str, StructuredEnum): +class MountEnvName(StrStructuredEnum): """Environment name for managing mount volume""" STAG = EnumField("stag", label="仅测试环境") @@ -157,12 +145,12 @@ class MountEnvName(str, StructuredEnum): GLOBAL = EnumField("_global_", label="所有环境") -class VolumeSourceType(str, StructuredEnum): +class VolumeSourceType(StrStructuredEnum): ConfigMap = EnumField("ConfigMap") PersistentStorage = EnumField("PersistentStorage") -class PersistentStorageSize(str, StructuredEnum): +class PersistentStorageSize(StrStructuredEnum): P_1G = EnumField("1Gi") P_2G = EnumField("2Gi") P_4G = EnumField("4Gi") diff --git a/apiserver/paasng/paas_wl/bk_app/dev_sandbox/entities.py b/apiserver/paasng/paas_wl/bk_app/dev_sandbox/entities.py index 80454b62f9..88a52b4fee 100644 --- a/apiserver/paasng/paas_wl/bk_app/dev_sandbox/entities.py +++ b/apiserver/paasng/paas_wl/bk_app/dev_sandbox/entities.py @@ -18,12 +18,12 @@ from dataclasses import dataclass, field from typing import Dict, List, Optional -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from paas_wl.workloads.release_controller.constants import ImagePullPolicy -class HealthPhase(str, StructuredEnum): +class HealthPhase(StrStructuredEnum): HEALTHY = EnumField("Healthy") PROGRESSING = EnumField("Progressing") UNHEALTHY = EnumField("Unhealthy") diff --git a/apiserver/paasng/paas_wl/bk_app/monitoring/bklog/constants.py b/apiserver/paasng/paas_wl/bk_app/monitoring/bklog/constants.py index 605b340db9..1b3dbc0c9d 100644 --- a/apiserver/paasng/paas_wl/bk_app/monitoring/bklog/constants.py +++ b/apiserver/paasng/paas_wl/bk_app/monitoring/bklog/constants.py @@ -15,7 +15,7 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum # 注解或标签中存储应用名称的键名 BKAPP_NAME_ANNO_KEY = "bkapp.paas.bk.tencent.com/name" @@ -29,7 +29,7 @@ WLAPP_NAME_ANNO_KEY = "bkapp.paas.bk.tencent.com/wl-app-name" -class BkLogConfigType(str, StructuredEnum): +class BkLogConfigType(StrStructuredEnum): STD_LOG = EnumField("std_log_config", label="标准输出日志") CONTAINER_LOG = EnumField("container_log_config", label="容器日志") NODE_LOG = EnumField("node_log_config", label="节点日志") diff --git a/apiserver/paasng/paas_wl/bk_app/processes/constants.py b/apiserver/paasng/paas_wl/bk_app/processes/constants.py index deb48535d0..fc140d0810 100644 --- a/apiserver/paasng/paas_wl/bk_app/processes/constants.py +++ b/apiserver/paasng/paas_wl/bk_app/processes/constants.py @@ -15,7 +15,7 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum # 注解或标签中存储进程名称的键名 PROCESS_NAME_KEY = "bkapp.paas.bk.tencent.com/process-name" @@ -26,7 +26,7 @@ DEFAULT_CNATIVE_MAX_REPLICAS = 10 -class ProcessUpdateType(str, StructuredEnum): +class ProcessUpdateType(StrStructuredEnum): """Type of updating processes""" START = EnumField("start") @@ -35,14 +35,14 @@ class ProcessUpdateType(str, StructuredEnum): SCALE = EnumField("scale") -class ProcessTargetStatus(str, StructuredEnum): +class ProcessTargetStatus(StrStructuredEnum): """Choices of process status""" START = EnumField("start") STOP = EnumField("stop") -class ProbeType(str, StructuredEnum): +class ProbeType(StrStructuredEnum): """Choices of probe type""" READINESS = EnumField("readiness", label="readinessProbe") diff --git a/apiserver/paasng/paas_wl/infras/cluster/constants.py b/apiserver/paasng/paas_wl/infras/cluster/constants.py index 8ffe67514f..13252f5173 100644 --- a/apiserver/paasng/paas_wl/infras/cluster/constants.py +++ b/apiserver/paasng/paas_wl/infras/cluster/constants.py @@ -17,16 +17,16 @@ from typing import Dict -from blue_krill.data_types.enum import EnumField, FeatureFlag, FeatureFlagField, StructuredEnum +from blue_krill.data_types.enum import EnumField, FeatureFlag, FeatureFlagField, IntStructuredEnum, StrStructuredEnum from django.conf import settings from django.utils.translation import gettext_lazy as _ -class ClusterTokenType(int, StructuredEnum): +class ClusterTokenType(IntStructuredEnum): SERVICE_ACCOUNT = 1 -class ClusterType(str, StructuredEnum): +class ClusterType(StrStructuredEnum): """集群类别""" NORMAL = EnumField("normal", label=_("普通集群")) diff --git a/apiserver/paasng/paas_wl/infras/resource_templates/constants.py b/apiserver/paasng/paas_wl/infras/resource_templates/constants.py index b348c728e5..64012cda32 100644 --- a/apiserver/paasng/paas_wl/infras/resource_templates/constants.py +++ b/apiserver/paasng/paas_wl/infras/resource_templates/constants.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum -class AppAddOnType(int, StructuredEnum): +class AppAddOnType(IntStructuredEnum): SIMPLE_SIDECAR = EnumField(1, label="SideCar Container") READINESS_PROBE = EnumField(2, label="Readiness Probe") VOLUME_MOUNT = EnumField(3, label="Volume Mount Point") diff --git a/apiserver/paasng/paas_wl/infras/resources/base/kres.py b/apiserver/paasng/paas_wl/infras/resources/base/kres.py index 6f7985d144..81d6c4c01d 100644 --- a/apiserver/paasng/paas_wl/infras/resources/base/kres.py +++ b/apiserver/paasng/paas_wl/infras/resources/base/kres.py @@ -15,20 +15,20 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -"""kres is a well capsuled package for playing with kubernetes resources -""" +"""kres is a well capsuled package for playing with kubernetes resources""" + import functools import json import logging import time from contextlib import contextmanager from datetime import datetime -from enum import Enum from types import ModuleType from typing import Any, Callable, Collection, Dict, Iterator, List, Optional, Tuple, Type, Union, overload import cattr from attrs import define +from blue_krill.data_types.enum import StrStructuredEnum from kubernetes import client as client_mod from kubernetes.client.api_client import ApiClient from kubernetes.client.exceptions import ApiException @@ -66,7 +66,7 @@ def set_default_options(options: ClientOptionsDict): _default_options = options -class PatchType(str, Enum): +class PatchType(StrStructuredEnum): """Different merge types when patching a kubernetes resource See also: https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/ """ @@ -116,12 +116,10 @@ def __set_name__(self, owner, name: str): self.method_name = name @overload - def __get__(self, instance: None, owner: None) -> "NameBasedMethodProxy": - ... + def __get__(self, instance: None, owner: None) -> "NameBasedMethodProxy": ... @overload - def __get__(self, instance: object, owner: Type) -> Callable: - ... + def __get__(self, instance: object, owner: Type) -> Callable: ... def __get__(self, instance, owner: Optional[Type] = None) -> Union["NameBasedMethodProxy", Callable]: if not instance: diff --git a/apiserver/paasng/paas_wl/infras/resources/utils/basic.py b/apiserver/paasng/paas_wl/infras/resources/utils/basic.py index 920d3fad88..b8eed6c418 100644 --- a/apiserver/paasng/paas_wl/infras/resources/utils/basic.py +++ b/apiserver/paasng/paas_wl/infras/resources/utils/basic.py @@ -15,10 +15,11 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -"""Basic utils for scheduler -""" +"""Basic utils for scheduler""" + import logging -from collections import Callable, OrderedDict +from collections import OrderedDict +from collections.abc import Callable from typing import TYPE_CHECKING, Dict, List, Optional from paas_wl.bk_app.applications.models import WlApp diff --git a/apiserver/paasng/paas_wl/utils/basic.py b/apiserver/paasng/paas_wl/utils/basic.py index f253ad0722..d9bc1e62de 100644 --- a/apiserver/paasng/paas_wl/utils/basic.py +++ b/apiserver/paasng/paas_wl/utils/basic.py @@ -17,7 +17,7 @@ import datetime import hashlib -from collections import MutableMapping +from collections.abc import MutableMapping from typing import Any, Collection, Dict from uuid import UUID diff --git a/apiserver/paasng/paas_wl/utils/blobstore.py b/apiserver/paasng/paas_wl/utils/blobstore.py index 615cc1daea..aeb327b8d0 100644 --- a/apiserver/paasng/paas_wl/utils/blobstore.py +++ b/apiserver/paasng/paas_wl/utils/blobstore.py @@ -15,12 +15,12 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -"""BlobStore client -""" +"""BlobStore client""" + import logging from typing import Optional -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from blue_krill.storages.blobstore.base import BlobStore from blue_krill.storages.blobstore.bkrepo import BKGenericRepo from blue_krill.storages.blobstore.s3 import S3Store @@ -29,7 +29,7 @@ logger = logging.getLogger(__name__) -class StoreType(str, StructuredEnum): +class StoreType(StrStructuredEnum): S3 = EnumField("s3") BKREPO = EnumField("bkrepo") diff --git a/apiserver/paasng/paas_wl/utils/constants.py b/apiserver/paasng/paas_wl/utils/constants.py index e7165bb82c..939a97902e 100644 --- a/apiserver/paasng/paas_wl/utils/constants.py +++ b/apiserver/paasng/paas_wl/utils/constants.py @@ -17,12 +17,12 @@ from typing import List -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from paasng.platform.engine.constants import JobStatus -class BuildStatus(str, StructuredEnum): +class BuildStatus(StrStructuredEnum): SUCCESSFUL = EnumField("successful", "成功") FAILED = EnumField("failed", "失败") PENDING = EnumField("pending", "等待") @@ -34,7 +34,7 @@ def get_finished_states(cls) -> List[str]: return [cls.FAILED, cls.SUCCESSFUL, cls.INTERRUPTED] -class CommandStatus(str, StructuredEnum): +class CommandStatus(StrStructuredEnum): SCHEDULED = EnumField("scheduled", label="已调度") SUCCESSFUL = EnumField("successful", "成功") FAILED = EnumField("failed", "失败") @@ -55,7 +55,7 @@ def to_job_status(self) -> JobStatus: return JobStatus(self.value) -class CommandType(str, StructuredEnum): +class CommandType(StrStructuredEnum): PRE_RELEASE_HOOK = EnumField("pre-release-hook", label="发布前置指令") def get_step_name(self): @@ -77,7 +77,7 @@ def make_enum_choices(obj): return [(member.value, name) for name, member in obj.__members__.items()] -class PodPhase(str, StructuredEnum): +class PodPhase(StrStructuredEnum): SUCCEEDED = EnumField("Succeeded", "成功") FAILED = EnumField("Failed", "失败") RUNNING = EnumField("Running", "运行中") diff --git a/apiserver/paasng/paas_wl/utils/kubestatus.py b/apiserver/paasng/paas_wl/utils/kubestatus.py index b2a1daef44..f76d393a3e 100644 --- a/apiserver/paasng/paas_wl/utils/kubestatus.py +++ b/apiserver/paasng/paas_wl/utils/kubestatus.py @@ -20,13 +20,13 @@ import kubernetes.client.models as kmodels from attrs import define -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import StrStructuredEnum from blue_krill.text import remove_prefix from kubernetes.client import ApiClient from kubernetes.dynamic.resource import ResourceField, ResourceInstance -class HealthStatusType(StructuredEnum): +class HealthStatusType(StrStructuredEnum): HEALTHY = "Healthy" UNHEALTHY = "Unhealthy" PROGRESSING = "progressing" diff --git a/apiserver/paasng/paas_wl/workloads/autoscaling/constants.py b/apiserver/paasng/paas_wl/workloads/autoscaling/constants.py index 1d812b3dac..aafc4ec994 100644 --- a/apiserver/paasng/paas_wl/workloads/autoscaling/constants.py +++ b/apiserver/paasng/paas_wl/workloads/autoscaling/constants.py @@ -15,7 +15,7 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext as _ # 添加注解 compute-by-limits=true 后,CPU 计算 Utilization 时 @@ -23,14 +23,14 @@ GPA_COMPUTE_BY_LIMITS_ANNO_KEY = "compute-by-limits" -class ScalingMetricName(str, StructuredEnum): +class ScalingMetricName(StrStructuredEnum): """扩缩容指标名称(用于组装 CPA 的指标)""" CPU = EnumField("cpu") MEMORY = EnumField("memory") -class ScalingMetricSourceType(str, StructuredEnum): +class ScalingMetricSourceType(StrStructuredEnum): """扩缩容指标类型""" RESOURCE = EnumField("Resource") @@ -38,14 +38,14 @@ class ScalingMetricSourceType(str, StructuredEnum): OBJECT = EnumField("Object") -class ScalingMetricTargetType(str, StructuredEnum): +class ScalingMetricTargetType(StrStructuredEnum): """扩缩容指标计量类型(用于组装 CPA 的指标类型)""" UTILIZATION = EnumField("Utilization") AVERAGE_VALUE = EnumField("AverageValue") -class ScalingEnvName(str, StructuredEnum): +class ScalingEnvName(StrStructuredEnum): """扩缩容生效环境""" STAG = EnumField("stag", label="仅测试环境") @@ -53,7 +53,7 @@ class ScalingEnvName(str, StructuredEnum): GLOBAL = EnumField("_global_", label="所有环境") -class ScalingMetric(str, StructuredEnum): +class ScalingMetric(StrStructuredEnum): """扩缩容指标(用户可选指标)""" CPU_UTILIZATION = EnumField("cpuUtilization", label=_("CPU 使用率")) diff --git a/apiserver/paasng/paas_wl/workloads/networking/constants.py b/apiserver/paasng/paas_wl/workloads/networking/constants.py index ab9b34fa2f..ad0114aebd 100644 --- a/apiserver/paasng/paas_wl/workloads/networking/constants.py +++ b/apiserver/paasng/paas_wl/workloads/networking/constants.py @@ -14,13 +14,13 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum -class NetworkProtocol(str, StructuredEnum): +class NetworkProtocol(StrStructuredEnum): TCP = EnumField("TCP", label="TCP") UDP = EnumField("UDP", label="UDP") -class ExposedTypeName(str, StructuredEnum): +class ExposedTypeName(StrStructuredEnum): BK_HTTP = "bk/http" diff --git a/apiserver/paasng/paas_wl/workloads/networking/entrance/allocator/domains.py b/apiserver/paasng/paas_wl/workloads/networking/entrance/allocator/domains.py index 072f77ee07..4ab966a441 100644 --- a/apiserver/paasng/paas_wl/workloads/networking/entrance/allocator/domains.py +++ b/apiserver/paasng/paas_wl/workloads/networking/entrance/allocator/domains.py @@ -16,11 +16,12 @@ # to the current version of the project delivered to anyone in the future. """Domain management""" + from dataclasses import dataclass, field from operator import attrgetter from typing import Dict, List, Optional -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum from paas_wl.infras.cluster.models import Domain as DomainCfg from paas_wl.infras.cluster.models import IngressConfig, PortMap @@ -31,7 +32,7 @@ from paasng.platform.engine.constants import AppEnvName -class DomainPriorityType(int, StructuredEnum): +class DomainPriorityType(IntStructuredEnum): STABLE = EnumField(1, label="无缩写,完整域名") WITHOUT_MODULE = EnumField(2, label="无模块,指向主模块") ONLY_CODE = EnumField(3, label="无模块无环境,指向主模块生产环境") diff --git a/apiserver/paasng/paas_wl/workloads/networking/entrance/allocator/subpaths.py b/apiserver/paasng/paas_wl/workloads/networking/entrance/allocator/subpaths.py index 2d82305041..012ae65d32 100644 --- a/apiserver/paasng/paas_wl/workloads/networking/entrance/allocator/subpaths.py +++ b/apiserver/paasng/paas_wl/workloads/networking/entrance/allocator/subpaths.py @@ -16,11 +16,12 @@ # to the current version of the project delivered to anyone in the future. """Subpaths management""" + from dataclasses import dataclass, field from operator import attrgetter from typing import Dict, List, Optional -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum from django.conf import settings from paas_wl.infras.cluster.models import Domain as DomainCfg @@ -32,7 +33,7 @@ from paasng.platform.engine.constants import AppEnvName -class SubpathPriorityType(int, StructuredEnum): +class SubpathPriorityType(IntStructuredEnum): STABLE = EnumField(1, label="无缩写") WITHOUT_MODULE = EnumField(2, label="无模块,指向主模块") ONLY_CODE = EnumField(3, label="无模块无环境,指向主模块生产环境") diff --git a/apiserver/paasng/paas_wl/workloads/networking/entrance/constants.py b/apiserver/paasng/paas_wl/workloads/networking/entrance/constants.py index 1408c683ad..41f39b0e8e 100644 --- a/apiserver/paasng/paas_wl/workloads/networking/entrance/constants.py +++ b/apiserver/paasng/paas_wl/workloads/networking/entrance/constants.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import IntStructuredEnum, StrStructuredEnum -class AppDomainSource(int, StructuredEnum): +class AppDomainSource(IntStructuredEnum): # "BUILT_IN" is reserved for the default ingress's domain, it looks like '{engine_app_name}.apps.com' BUILT_IN = 1 # Auto-generated sub-domains @@ -26,11 +26,11 @@ class AppDomainSource(int, StructuredEnum): INDEPENDENT = 3 -class AppSubpathSource(int, StructuredEnum): +class AppSubpathSource(IntStructuredEnum): DEFAULT = 1 -class AddressType(str, StructuredEnum): +class AddressType(StrStructuredEnum): """Address types, different value means different source. For example, "custom" means the address was provided by a custom domain created by user. """ diff --git a/apiserver/paasng/paas_wl/workloads/networking/ingress/constants.py b/apiserver/paasng/paas_wl/workloads/networking/ingress/constants.py index 8d6df30e98..5127427cee 100644 --- a/apiserver/paasng/paas_wl/workloads/networking/ingress/constants.py +++ b/apiserver/paasng/paas_wl/workloads/networking/ingress/constants.py @@ -15,7 +15,7 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import IntStructuredEnum ANNOT_SERVER_SNIPPET = "nginx.ingress.kubernetes.io/server-snippet" ANNOT_CONFIGURATION_SNIPPET = "nginx.ingress.kubernetes.io/configuration-snippet" @@ -37,7 +37,7 @@ } -class AppDomainSource(int, StructuredEnum): +class AppDomainSource(IntStructuredEnum): # "BUILT_IN" is reserved for the default ingress's domain, it looks like '{engine_app_name}.apps.com' BUILT_IN = 1 # Auto-generated sub-domains @@ -45,5 +45,5 @@ class AppDomainSource(int, StructuredEnum): INDEPENDENT = 3 -class AppSubpathSource(int, StructuredEnum): +class AppSubpathSource(IntStructuredEnum): DEFAULT = 1 diff --git a/apiserver/paasng/paas_wl/workloads/release_controller/constants.py b/apiserver/paasng/paas_wl/workloads/release_controller/constants.py index e23488a79d..431dd6f5f2 100644 --- a/apiserver/paasng/paas_wl/workloads/release_controller/constants.py +++ b/apiserver/paasng/paas_wl/workloads/release_controller/constants.py @@ -15,17 +15,17 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum -class RuntimeType(str, StructuredEnum): +class RuntimeType(StrStructuredEnum): BUILDPACK = EnumField("buildpack", label="Runtime for buildpack") CUSTOM_IMAGE = EnumField("custom_image", label="Custom Image") BK_SMART = EnumField("bk-smart", label="Runtime for buildpack, but build as image") DOCKERFILE = EnumField("dockerfile", label="Runtime for dockerfile") -class ImagePullPolicy(str, StructuredEnum): +class ImagePullPolicy(StrStructuredEnum): ALWAYS = EnumField("Always") IF_NOT_PRESENT = EnumField("IfNotPresent") NEVER = EnumField("Never") diff --git a/apiserver/paasng/paasng/accessories/ci/constants.py b/apiserver/paasng/paasng/accessories/ci/constants.py index 4bb0e2db54..900cec005c 100644 --- a/apiserver/paasng/paasng/accessories/ci/constants.py +++ b/apiserver/paasng/paasng/accessories/ci/constants.py @@ -15,8 +15,8 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum -class CIBackend(str, StructuredEnum): +class CIBackend(StrStructuredEnum): CODECC = EnumField("codecc", label="CodeCC") diff --git a/apiserver/paasng/paasng/accessories/cloudapi/constants.py b/apiserver/paasng/paasng/accessories/cloudapi/constants.py index 2c96de1e8d..b935ba8b05 100644 --- a/apiserver/paasng/paasng/accessories/cloudapi/constants.py +++ b/apiserver/paasng/paasng/accessories/cloudapi/constants.py @@ -15,17 +15,17 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum, StrStructuredEnum -class ApplyStatusEnum(StructuredEnum): +class ApplyStatusEnum(StrStructuredEnum): PARTIAL_APPROVED = EnumField("partial_approved", label="部分通过") APPROVED = EnumField("approved", label="通过") REJECTED = EnumField("rejected", label="驳回") PENDING = EnumField("pending", label="待审批") -class PermissionStatusEnum(StructuredEnum): +class PermissionStatusEnum(StrStructuredEnum): OWNED = EnumField("owned", label="已拥有") REJECTED = EnumField("rejected", label="已拒绝") EXPIRED = EnumField("expired", label="已过期") @@ -33,24 +33,24 @@ class PermissionStatusEnum(StructuredEnum): NEED_APPLY = EnumField("need_apply", label="未申请") -class PermissionLevelEnum(StructuredEnum): +class PermissionLevelEnum(StrStructuredEnum): UNLIMITED = EnumField("unlimited", label="无限制") NORMAL = EnumField("normal", label="普通") SENSITIVE = EnumField("sensitive", label="敏感") SPECIAL = EnumField("special", label="特殊") -class PermissionActionEnum(StructuredEnum): +class PermissionActionEnum(StrStructuredEnum): APPLY = EnumField("apply", label="申请") RENEW = EnumField("renew", label="续期") -class PermissionApplyExpireDaysEnum(StructuredEnum): +class PermissionApplyExpireDaysEnum(IntStructuredEnum): PERMANENT = EnumField(0, label="永久") SIX_MONTH = EnumField(180, label="6个月") TWELVE_MONTH = EnumField(360, label="12个月") -class GrantDimensionEnum(StructuredEnum): +class GrantDimensionEnum(StrStructuredEnum): API = EnumField("api", label="按网关") RESOURCE = EnumField("resource", label="按资源") diff --git a/apiserver/paasng/paasng/accessories/log/client.py b/apiserver/paasng/paasng/accessories/log/client.py index db91355391..bce2ffd0aa 100644 --- a/apiserver/paasng/paasng/accessories/log/client.py +++ b/apiserver/paasng/paasng/accessories/log/client.py @@ -106,7 +106,8 @@ def execute_scroll_search( resp = self._call_api(self._esclient.esquery_dsl, data=data, timeout=timeout) if not resp["result"]: - # 有可能是 scroll id 失效了, 反正抛异常就对了 + # API 返回异常可能原因:scroll 失效,这里统一返回 ScanError,如果为空则设置为 none 防止类型异常 + scroll_id = scroll_id or "none" raise ScanError(scroll_id, "Scroll request has failed on `{}`".format(resp["message"])) response = Response(search.search, resp["data"]) @@ -221,6 +222,8 @@ def execute_scroll_search( ), ) if not response.success(): + # API 返回异常可能原因:scroll 失效,这里统一返回 ScanError,如果为空则设置为 none 防止类型异常 + scroll_id = scroll_id or "none" failed = response._shards.failed total = response._shards.total raise ScanError( @@ -272,7 +275,7 @@ def get_mappings(self, index: str, time_range: SmartTimeRange, timeout: int) -> # 当前假设同一批次的 index(类似 aa-2021.04.20,aa-2021.04.19) 拥有相同的 mapping, 因此直接获取最新的 mapping # 如果同一批次 index mapping 发生变化,可能会导致日志查询为空 es_index = self._get_indexes(index, time_range, timeout) - all_mappings = self._client.indices.get_mapping(es_index, params={"request_timeout": timeout}) + all_mappings = self._client.indices.get_mapping(index=es_index, params={"request_timeout": timeout}) # 由于手动创建会没有 properties, 需要将无 properties 的 mappings 过滤掉 all_not_empty_mappings = { key: mapping for key, mapping in all_mappings.items() if mapping["mappings"].get("properties") @@ -290,7 +293,7 @@ def _get_indexes(self, index: str, time_range: SmartTimeRange, timeout: int) -> # Note: 使用 stats 接口优化查询性能 all_indexes = list( self._client.indices.stats( - index, metric="fielddata", params={"request_timeout": timeout, "level": "indices"} + index=index, metric="fielddata", params={"request_timeout": timeout, "level": "indices"} )["indices"].keys() ) if filtered_indexes := filter_indexes_by_time_range(all_indexes, time_range=time_range): diff --git a/apiserver/paasng/paasng/accessories/log/constants.py b/apiserver/paasng/paasng/accessories/log/constants.py index f84d2c92e9..e69b54414b 100644 --- a/apiserver/paasng/paasng/accessories/log/constants.py +++ b/apiserver/paasng/paasng/accessories/log/constants.py @@ -15,7 +15,7 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum # 如果日志配置是所有进程通用的, process_type 填充为 "-" DEFAULT_LOG_CONFIG_PLACEHOLDER = "-" @@ -27,7 +27,7 @@ MAX_RESULT_WINDOW = 10000 -class LogTimeChoices(str, StructuredEnum): +class LogTimeChoices(StrStructuredEnum): """日志搜索-日期范围可选值""" FIVE_MINUTES = EnumField("5m", label="5分钟") @@ -41,7 +41,7 @@ class LogTimeChoices(str, StructuredEnum): CUSTOMIZED = EnumField("customized", label="自定义") -class LogType(str, StructuredEnum): +class LogType(StrStructuredEnum): """ 日志类型 """ @@ -51,7 +51,7 @@ class LogType(str, StructuredEnum): INGRESS = EnumField("INGRESS", label="接入层日志") -class LogCollectorType(str, StructuredEnum): +class LogCollectorType(StrStructuredEnum): """日志采集器类型""" BK_LOG = EnumField("BK_LOG", label="蓝鲸日志平台采集器") diff --git a/apiserver/paasng/paasng/accessories/paas_analysis/constants.py b/apiserver/paasng/paasng/accessories/paas_analysis/constants.py index 1b64a378c8..77471715e1 100644 --- a/apiserver/paasng/paasng/accessories/paas_analysis/constants.py +++ b/apiserver/paasng/paasng/accessories/paas_analysis/constants.py @@ -14,25 +14,25 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum, StrStructuredEnum -class PAMetadataKey(str, StructuredEnum): +class PAMetadataKey(StrStructuredEnum): SITE_ID = "bkpa_site_id" -class MetricSourceType(int, StructuredEnum): +class MetricSourceType(IntStructuredEnum): INGRESS = EnumField(1, label="ingress") USER_TRACKER = EnumField(2, label="user_tracker") -class MetricsDimensionType(str, StructuredEnum): +class MetricsDimensionType(StrStructuredEnum): PATH = EnumField("path", label="path") USER = EnumField("user", label="user") ACTION = EnumField("action", label="action") -class MetricsInterval(str, StructuredEnum): +class MetricsInterval(StrStructuredEnum): """Available interval for metrics""" FIVE_MINUTES = EnumField("5m", label="5m") diff --git a/apiserver/paasng/paasng/accessories/publish/market/constant.py b/apiserver/paasng/paasng/accessories/publish/market/constant.py index 4523cc6ba7..baf8b304f2 100644 --- a/apiserver/paasng/paasng/accessories/publish/market/constant.py +++ b/apiserver/paasng/paasng/accessories/publish/market/constant.py @@ -17,13 +17,13 @@ from enum import Enum -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum, StrStructuredEnum from django.utils.translation import gettext_lazy as _ from paasng.core.region.states import RegionType -class ProductSourceUrlType(int, StructuredEnum): +class ProductSourceUrlType(IntStructuredEnum): """访问地址类型""" DISABLED = EnumField(1, label="未开启") @@ -63,14 +63,14 @@ def get_choices(cls): TAG_REGION_CHOICES = list(RegionType.get_choices()) + [("all", "所有版本")] -class OpenMode(str, StructuredEnum): +class OpenMode(StrStructuredEnum): """应用在桌面的打开方式""" DESKTOP = EnumField(real_value="desktop", label="桌面") NEW_TAB = EnumField(real_value="new_tab", label="新标签页") -class TagName(str, StructuredEnum): +class TagName(StrStructuredEnum): """应用分类名称""" OPSTOOlS = EnumField("OpsTools", label=_("运维工具")) diff --git a/apiserver/paasng/paasng/accessories/servicehub/constants.py b/apiserver/paasng/paasng/accessories/servicehub/constants.py index e5974841d0..3d34c72373 100644 --- a/apiserver/paasng/paasng/accessories/servicehub/constants.py +++ b/apiserver/paasng/paasng/accessories/servicehub/constants.py @@ -16,9 +16,8 @@ # to the current version of the project delivered to anyone in the future. import uuid -from enum import Enum -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import IntStructuredEnum, StrStructuredEnum # 需要在平台侧完全隐藏的字段名称,用户无法在产品上查看该字段内容,只能通过环境变量查看 SERVICE_SENSITIVE_FIELDS: dict = {} @@ -42,19 +41,19 @@ ) -class Category(int, Enum): +class Category(IntStructuredEnum): """Paas service categories""" DATA_STORAGE = 1 MONITORING_HEALTHY = 2 -class ServiceType(str, StructuredEnum): +class ServiceType(StrStructuredEnum): LOCAL = "local" REMOTE = "remote" -class ServiceBindingType(int, Enum): +class ServiceBindingType(IntStructuredEnum): """Type of service binding relationship""" NORMAL = 1 diff --git a/apiserver/paasng/paasng/accessories/servicehub/remote/manager.py b/apiserver/paasng/paasng/accessories/servicehub/remote/manager.py index ed4f7e6dd3..4a94add879 100644 --- a/apiserver/paasng/paasng/accessories/servicehub/remote/manager.py +++ b/apiserver/paasng/paasng/accessories/servicehub/remote/manager.py @@ -15,8 +15,8 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -"""The universal services module, handles both services from database and remote REST API -""" +"""The universal services module, handles both services from database and remote REST API""" + import json import logging import uuid @@ -124,7 +124,7 @@ def from_data(cls, data: Dict): @dataclass class RemoteServiceObj(ServiceObj): plans: List[RemotePlanObj] = field(default_factory=list) - meta_info: MetaInfo = DEFAULT_META_INFO + meta_info: MetaInfo = field(default_factory=lambda: MetaInfo(version=None)) _data = None category_id = None diff --git a/apiserver/paasng/paasng/accessories/services/providers/mysql/constants.py b/apiserver/paasng/paasng/accessories/services/providers/mysql/constants.py index aad78cf2ee..e1e9c6d767 100644 --- a/apiserver/paasng/paasng/accessories/services/providers/mysql/constants.py +++ b/apiserver/paasng/paasng/accessories/services/providers/mysql/constants.py @@ -14,11 +14,10 @@ # # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. +from blue_krill.data_types.enum import IntStructuredEnum -from enum import IntEnum - -class MySQLAuthTypeEnum(IntEnum): +class MySQLAuthTypeEnum(IntStructuredEnum): GRANT = 1 REVOKE = 2 diff --git a/apiserver/paasng/paasng/accessories/smart_advisor/constants.py b/apiserver/paasng/paasng/accessories/smart_advisor/constants.py index 4ece7b1f49..e6fc42f6c8 100644 --- a/apiserver/paasng/paasng/accessories/smart_advisor/constants.py +++ b/apiserver/paasng/paasng/accessories/smart_advisor/constants.py @@ -15,8 +15,8 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from enum import Enum +from blue_krill.data_types.enum import IntStructuredEnum -class DeployFailurePatternType(int, Enum): +class DeployFailurePatternType(IntStructuredEnum): REGULAR_EXPRESSION = 1 diff --git a/apiserver/paasng/paasng/bk_plugins/bk_plugins/constants.py b/apiserver/paasng/paasng/bk_plugins/bk_plugins/constants.py index 7aac464d78..1a025d94a4 100644 --- a/apiserver/paasng/paasng/bk_plugins/bk_plugins/constants.py +++ b/apiserver/paasng/paasng/bk_plugins/bk_plugins/constants.py @@ -15,8 +15,8 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum -class PluginTagIdType(int, StructuredEnum): +class PluginTagIdType(IntStructuredEnum): UNTAGGED = EnumField(-1, label="未分类") diff --git a/apiserver/paasng/paasng/bk_plugins/pluginscenter/bk_devops/constants.py b/apiserver/paasng/paasng/bk_plugins/pluginscenter/bk_devops/constants.py index d65b3f4ec9..8e23fa5101 100644 --- a/apiserver/paasng/paasng/bk_plugins/pluginscenter/bk_devops/constants.py +++ b/apiserver/paasng/paasng/bk_plugins/pluginscenter/bk_devops/constants.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum -class PipelineBuildStatus(str, StructuredEnum): +class PipelineBuildStatus(StrStructuredEnum): """蓝盾流水线构建状态""" # 由于蓝盾接口文档未提供所有枚举值, 因此这里只列举目前已知的状态 diff --git a/apiserver/paasng/paasng/bk_plugins/pluginscenter/constants.py b/apiserver/paasng/paasng/bk_plugins/pluginscenter/constants.py index 1daa88d257..87d9a9ab64 100644 --- a/apiserver/paasng/paasng/bk_plugins/pluginscenter/constants.py +++ b/apiserver/paasng/paasng/bk_plugins/pluginscenter/constants.py @@ -15,11 +15,11 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class PluginReleaseMethod(str, StructuredEnum): +class PluginReleaseMethod(StrStructuredEnum): """插件发布方式""" CODE = EnumField("code", label="源码发布") @@ -27,14 +27,14 @@ class PluginReleaseMethod(str, StructuredEnum): IMAGE = EnumField("image", label="镜像发布") -class PluginBasicInfoAccessMode(str, StructuredEnum): +class PluginBasicInfoAccessMode(StrStructuredEnum): """插件基本信息查看模式""" READONLY = EnumField("readonly", label="只读") READWRITE = EnumField("readwrite", label="读写") -class PluginReleaseVersionRule(str, StructuredEnum): +class PluginReleaseVersionRule(StrStructuredEnum): """插件发布版本号规则""" AUTOMATIC = EnumField("automatic", label="自动生成 semver") @@ -44,7 +44,7 @@ class PluginReleaseVersionRule(str, StructuredEnum): SELF_FILL = EnumField("self-fill", label="用户自助填写") -class SemverAutomaticType(str, StructuredEnum): +class SemverAutomaticType(StrStructuredEnum): """语义化版本生成规则""" MAJOR = EnumField("major", label="重大版本") @@ -52,7 +52,7 @@ class SemverAutomaticType(str, StructuredEnum): PATCH = EnumField("patch", label="修正版本") -class ReleaseStageInvokeMethod(str, StructuredEnum): +class ReleaseStageInvokeMethod(StrStructuredEnum): """发布步骤触发方式""" DEPLOY_API = EnumField("deployAPI", label="部署接口") @@ -63,7 +63,7 @@ class ReleaseStageInvokeMethod(str, StructuredEnum): BUILTIN = EnumField("builtin", label="内置功能(完善市场信息market, 灰度grayScale, 上线online)") -class PluginStatus(str, StructuredEnum): +class PluginStatus(StrStructuredEnum): """插件状态""" WAITING_APPROVAL = EnumField("waiting-approval", label="创建审批中") @@ -84,14 +84,14 @@ def approval_status(cls): return [cls.APPROVAL_FAILED, cls.WAITING_APPROVAL] -class PluginRole(int, StructuredEnum): +class PluginRole(IntStructuredEnum): """插件角色""" ADMINISTRATOR = EnumField(2, label="管理员") DEVELOPER = EnumField(3, label="开发者") -class MarketInfoStorageType(str, StructuredEnum): +class MarketInfoStorageType(StrStructuredEnum): """市场信息存储类型""" THIRD_PARTY = EnumField("third-party", label="仅存储在第三方系统") @@ -99,7 +99,7 @@ class MarketInfoStorageType(str, StructuredEnum): BOTH = EnumField("both", label="同时存储在插件开发中心和第三方系统") -class PluginReleaseStatus(str, StructuredEnum): +class PluginReleaseStatus(StrStructuredEnum): """插件发布状态""" SUCCESSFUL = EnumField("successful", label="成功") @@ -121,7 +121,7 @@ def terminated_status(cls): return [cls.FAILED, cls.INTERRUPTED, cls.SUCCESSFUL] -class LogTimeChoices(str, StructuredEnum): +class LogTimeChoices(StrStructuredEnum): """日志搜索-日期范围可选值""" FIVE_MINUTES = EnumField("5m", label="5分钟") @@ -135,7 +135,7 @@ class LogTimeChoices(str, StructuredEnum): CUSTOMIZED = EnumField("customized", label="自定义") -class ActionTypes(str, StructuredEnum): +class ActionTypes(StrStructuredEnum): """操作记录-动作类型""" CREATE = EnumField("create", label=_("创建")) @@ -149,7 +149,7 @@ class ActionTypes(str, StructuredEnum): ROLLBACK = EnumField("rollback", label=_("回滚")) -class SubjectTypes(str, StructuredEnum): +class SubjectTypes(StrStructuredEnum): """操作记录-主体""" PLUGIN = EnumField("plugin", label=_("插件")) @@ -164,28 +164,28 @@ class SubjectTypes(str, StructuredEnum): RELEASE_STRATEGY = EnumField("release_strategy", label=_("发布策略")) -class PluginReleaseType(str, StructuredEnum): +class PluginReleaseType(StrStructuredEnum): """插件版本发布类型""" PROD = EnumField("prod", label=_("正式发布")) TEST = EnumField("test", label=_("测试发布")) -class ReleaseStrategy(str, StructuredEnum): +class ReleaseStrategy(StrStructuredEnum): """插件发布策略""" GRAY = EnumField("gray", label=_("灰度发布")) FULL = EnumField("full", label=_("全量发布")) -class StatusPollingMethod(str, StructuredEnum): +class StatusPollingMethod(StrStructuredEnum): """发布阶段的状态轮询方式""" API = EnumField("api", label=_("后台 API 轮询")) FRONTEND = EnumField("frontend", label=_("前端轮询,如通过 Iframe message 通信等")) -class PluginRevisionType(str, StructuredEnum): +class PluginRevisionType(StrStructuredEnum): """代码版本类型""" ALL = EnumField("all", label=_("不限制")) @@ -194,7 +194,7 @@ class PluginRevisionType(str, StructuredEnum): TESTED_VERSION = EnumField("tested_version", label=_("已经测试通过的版本")) -class GrayReleaseStatus(str, StructuredEnum): +class GrayReleaseStatus(StrStructuredEnum): """插件灰度发布展示的状态,提供给前端展示的字段不需要国际化标记""" GRAY_APPROVAL_IN_PROGRESS = EnumField("gray_approval_in_progress", label="灰度发布审批中") diff --git a/apiserver/paasng/paasng/bk_plugins/pluginscenter/iam_adaptor/constants.py b/apiserver/paasng/paasng/bk_plugins/pluginscenter/iam_adaptor/constants.py index 3d69b0f932..079c2262d6 100644 --- a/apiserver/paasng/paasng/bk_plugins/pluginscenter/iam_adaptor/constants.py +++ b/apiserver/paasng/paasng/bk_plugins/pluginscenter/iam_adaptor/constants.py @@ -17,7 +17,7 @@ from typing import List -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ from paasng.bk_plugins.pluginscenter.constants import PluginRole @@ -41,7 +41,7 @@ NEVER_EXPIRE_DAYS = -1 -class PluginPermissionActions(str, StructuredEnum): +class PluginPermissionActions(StrStructuredEnum): """插件相关的操作权限""" BASIC_DEVELOPMENT = EnumField("basic_development", label=_("基础开发")) @@ -75,5 +75,5 @@ def get_choices_by_role(cls, role: PluginRole) -> List["PluginPermissionActions" raise NotImplementedError -class ResourceType(str, StructuredEnum): +class ResourceType(StrStructuredEnum): PLUGIN = EnumField("plugin", label=_("蓝鲸插件")) diff --git a/apiserver/paasng/paasng/bk_plugins/pluginscenter/itsm_adaptor/constants.py b/apiserver/paasng/paasng/bk_plugins/pluginscenter/itsm_adaptor/constants.py index 4dfdbbfbbd..37d047d0ab 100644 --- a/apiserver/paasng/paasng/bk_plugins/pluginscenter/itsm_adaptor/constants.py +++ b/apiserver/paasng/paasng/bk_plugins/pluginscenter/itsm_adaptor/constants.py @@ -15,11 +15,11 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class ApprovalServiceName(str, StructuredEnum): +class ApprovalServiceName(StrStructuredEnum): """审批流程服务名""" CREATE_APPROVAL = EnumField("create_approval", label=_("插件上线审批")) @@ -35,7 +35,7 @@ class ApprovalServiceName(str, StructuredEnum): ) -class ItsmTicketStatus(str, StructuredEnum): +class ItsmTicketStatus(StrStructuredEnum): """ITSM 流程状态""" RUNNING = EnumField("RUNNING", label=_("处理中")) diff --git a/apiserver/paasng/paasng/bk_plugins/pluginscenter/log/client.py b/apiserver/paasng/paasng/bk_plugins/pluginscenter/log/client.py index 3045046484..ee91ded503 100644 --- a/apiserver/paasng/paasng/bk_plugins/pluginscenter/log/client.py +++ b/apiserver/paasng/paasng/bk_plugins/pluginscenter/log/client.py @@ -182,7 +182,7 @@ def _get_properties_filters(self, index: str, timeout: int) -> Dict[str, FieldFi """获取属性映射""" # 当前假设同一批次的 index(类似 aa-2021.04.20,aa-2021.04.19) 拥有相同的 mapping, 因此直接获取最新的 mapping # 如果同一批次 index mapping 发生变化,可能会导致日志查询为空 - all_mappings = self._client.indices.get_mapping(index, params={"request_timeout": timeout}) + all_mappings = self._client.indices.get_mapping(index=index, params={"request_timeout": timeout}) if not all_mappings: raise error_codes.QUERY_ES_ERROR.f( _("No mappings available, maybe index does not exist or no logs at all") diff --git a/apiserver/paasng/paasng/infras/accounts/constants.py b/apiserver/paasng/paasng/infras/accounts/constants.py index e107a1b212..6043e93ac0 100644 --- a/apiserver/paasng/paasng/infras/accounts/constants.py +++ b/apiserver/paasng/paasng/infras/accounts/constants.py @@ -90,13 +90,20 @@ def get_default_flags(cls) -> Dict[str, bool]: return flags.copy() @classmethod - def register_ext_feature_flag(cls, feature_flag: FeatureFlagField): + def register_ext_feature_flag(cls, feature_flag: FeatureFlagField) -> None: """注册额外的用户特性到枚举类中""" name, label, default = feature_flag.name, feature_flag.label, feature_flag.default + # 无名的不允许注册 + if not name: + raise ValueError("feature flag's name can not be empty.") + + # 已经注册过的,需要跳过 + if getattr(cls, name, None): + return + extend_enum(cls, name, name) cls._choices_labels.value.append((name, label)) cls._defaults[name] = default # type: ignore - return name class FunctionType(ChoicesEnum): diff --git a/apiserver/paasng/paasng/infras/accounts/permissions/constants.py b/apiserver/paasng/paasng/infras/accounts/permissions/constants.py index 16cac8e04e..69af46406d 100644 --- a/apiserver/paasng/paasng/infras/accounts/permissions/constants.py +++ b/apiserver/paasng/paasng/infras/accounts/permissions/constants.py @@ -15,11 +15,11 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class SiteAction(str, StructuredEnum): +class SiteAction(StrStructuredEnum): """蓝鲸 PaaS 平台全局功能相关权限""" VISIT_SITE = EnumField("visit_site", label=_("平台页面查看")) diff --git a/apiserver/paasng/paasng/infras/bk_ci/constants.py b/apiserver/paasng/paasng/infras/bk_ci/constants.py index c15298cfd1..4bc48138ea 100644 --- a/apiserver/paasng/paasng/infras/bk_ci/constants.py +++ b/apiserver/paasng/paasng/infras/bk_ci/constants.py @@ -15,11 +15,11 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class PipelineBuildStatus(str, StructuredEnum): +class PipelineBuildStatus(StrStructuredEnum): """蓝盾流水线构建状态""" SUCCEED = EnumField("SUCCEED", label=_("成功")) diff --git a/apiserver/paasng/paasng/infras/bk_log/constatns.py b/apiserver/paasng/paasng/infras/bk_log/constatns.py index 6612d552c8..a55d6865db 100644 --- a/apiserver/paasng/paasng/infras/bk_log/constatns.py +++ b/apiserver/paasng/paasng/infras/bk_log/constatns.py @@ -15,17 +15,17 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum -class ETLType(str, StructuredEnum): +class ETLType(StrStructuredEnum): DELIMITER = EnumField("bk_log_delimiter") REGEXP = EnumField("bk_log_regexp") JSON = EnumField("bk_log_json") TEXT = EnumField("bk_log_text") -class FieldType(str, StructuredEnum): +class FieldType(StrStructuredEnum): INT = EnumField("int") LONG = EnumField("long") DOUBLE = EnumField("double") @@ -34,6 +34,6 @@ class FieldType(str, StructuredEnum): NESTED = EnumField("nested") -class BkLogType(str, StructuredEnum): +class BkLogType(StrStructuredEnum): JSON = EnumField("json") STDOUT = EnumField("stdout") diff --git a/apiserver/paasng/paasng/infras/bkmonitorv3/constants.py b/apiserver/paasng/paasng/infras/bkmonitorv3/constants.py index 17bbc92d2f..6673643d5b 100644 --- a/apiserver/paasng/paasng/infras/bkmonitorv3/constants.py +++ b/apiserver/paasng/paasng/infras/bkmonitorv3/constants.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class SpaceType(str, StructuredEnum): +class SpaceType(StrStructuredEnum): SAAS = EnumField("bksaas", label=_("蓝鲸应用")) BKCC = EnumField("bkcc", label=_("业务")) diff --git a/apiserver/paasng/paasng/infras/iam/constants.py b/apiserver/paasng/paasng/infras/iam/constants.py index 655442a6b6..a9b0b42033 100644 --- a/apiserver/paasng/paasng/infras/iam/constants.py +++ b/apiserver/paasng/paasng/infras/iam/constants.py @@ -15,7 +15,7 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import IntStructuredEnum, StrStructuredEnum from paasng.platform.applications.constants import ApplicationRole @@ -41,7 +41,7 @@ LIST_GRADE_MANAGERS_LIMIT = 15000 -class ResourceType(str, StructuredEnum): +class ResourceType(StrStructuredEnum): """ iam 上注册的资源类型 """ @@ -61,7 +61,7 @@ class ResourceType(str, StructuredEnum): BkLogEsSource = "es_source" -class IAMErrorCodes(int, StructuredEnum): +class IAMErrorCodes(IntStructuredEnum): """ iam api 返回错误码 https://bk.tencent.com/docs/document/7.0/236/39801 diff --git a/apiserver/paasng/paasng/infras/iam/legacy.py b/apiserver/paasng/paasng/infras/iam/legacy.py index d2c197afea..e51b54b825 100644 --- a/apiserver/paasng/paasng/infras/iam/legacy.py +++ b/apiserver/paasng/paasng/infras/iam/legacy.py @@ -18,7 +18,7 @@ # PaaS 2.0 相关权限 import logging -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.conf import settings from iam import IAM, Action, Request, Subject from iam.contrib.converter.sql import SQLConverter @@ -27,7 +27,7 @@ logger = logging.getLogger(__name__) -class LegacyAction(str, StructuredEnum): +class LegacyAction(StrStructuredEnum): DEVELOP_APP = EnumField("develop_app", label="开发 SaaS 应用及外链应用") MANAGE_SMART = EnumField("manage_smart", label="管理 S-mart 应用") diff --git a/apiserver/paasng/paasng/infras/iam/open_apis/constants.py b/apiserver/paasng/paasng/infras/iam/open_apis/constants.py index d846736645..de60eece91 100644 --- a/apiserver/paasng/paasng/infras/iam/open_apis/constants.py +++ b/apiserver/paasng/paasng/infras/iam/open_apis/constants.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import StrStructuredEnum -class MethodType(str, StructuredEnum): +class MethodType(StrStructuredEnum): """ 权限中心拉取资源的 method 参数值 字段协议说明 https://bk.tencent.com/docs/document/6.0/160/8427?r=1 diff --git a/apiserver/paasng/paasng/infras/iam/permissions/resources/application.py b/apiserver/paasng/paasng/infras/iam/permissions/resources/application.py index 45dae4137a..4f766ad099 100644 --- a/apiserver/paasng/paasng/infras/iam/permissions/resources/application.py +++ b/apiserver/paasng/paasng/infras/iam/permissions/resources/application.py @@ -21,7 +21,7 @@ from attrs import define, field, validators from bkpaas_auth.core.encoder import user_id_encoder -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.conf import settings from django.db.models import Q from django.utils.translation import gettext_lazy as _ @@ -34,7 +34,7 @@ logger = logging.getLogger(__name__) -class AppAction(str, StructuredEnum): +class AppAction(StrStructuredEnum): """蓝鲸 PaaS 应用相关权限""" # 应用基础信息查看 diff --git a/apiserver/paasng/paasng/misc/audit/constants.py b/apiserver/paasng/paasng/misc/audit/constants.py index 519be9744c..238951a400 100644 --- a/apiserver/paasng/paasng/misc/audit/constants.py +++ b/apiserver/paasng/paasng/misc/audit/constants.py @@ -15,18 +15,18 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class AccessType(int, StructuredEnum): +class AccessType(IntStructuredEnum): """访问方式""" WEB = EnumField(0, label=_("网页")) API = EnumField(1, label="API") -class ResultCode(int, StructuredEnum): +class ResultCode(IntStructuredEnum): """操作结果""" SUCCESS = EnumField(0, label=_("成功")) @@ -39,7 +39,7 @@ def get_terminated_codes(cls): return [cls.SUCCESS, cls.FAILURE, cls.INTERRUPT] -class DataType(str, StructuredEnum): +class DataType(StrStructuredEnum): """记录操作前后数据的数据类型,前端会根据该字段做不同的展示 前端不需要展示相关的 label, 故不用做国际化标记 """ @@ -54,7 +54,7 @@ class DataType(str, StructuredEnum): ) -class OperationTarget(str, StructuredEnum): +class OperationTarget(StrStructuredEnum): """操作对象""" APP = EnumField("app", label=_("应用")) @@ -92,7 +92,7 @@ class OperationTarget(str, StructuredEnum): SLUGRUNNER = EnumField("slugrunner", label="Slugrunner") -class OperationEnum(str, StructuredEnum): +class OperationEnum(StrStructuredEnum): """操作类型""" CREATE = EnumField("create", label=_("新建")) diff --git a/apiserver/paasng/paasng/misc/monitoring/metrics/constants.py b/apiserver/paasng/paasng/misc/monitoring/metrics/constants.py index 61b71a77bd..904c88a51c 100644 --- a/apiserver/paasng/paasng/misc/monitoring/metrics/constants.py +++ b/apiserver/paasng/paasng/misc/monitoring/metrics/constants.py @@ -15,16 +15,16 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum -class MetricsSeriesType(str, StructuredEnum): +class MetricsSeriesType(StrStructuredEnum): CURRENT = EnumField("current", "使用量") REQUEST = EnumField("request", "保留量") LIMIT = EnumField("limit", "配额上限") -class MetricsResourceType(str, StructuredEnum): +class MetricsResourceType(StrStructuredEnum): MEM = EnumField("mem") CPU = EnumField("cpu") @@ -41,7 +41,8 @@ def choices(cls): "current": "sum by(container_name)(container_memory_working_set_bytes{{" 'pod_name="{instance_name}", container_name!="POD", cluster_id="{cluster_id}"}})', # 内存预留值 - "request": 'kube_pod_container_resource_requests_memory_bytes{{pod="{instance_name}", cluster_id="{cluster_id}"}}', + "request": "kube_pod_container_resource_requests_memory_bytes" + + '{{pod="{instance_name}", cluster_id="{cluster_id}"}}', # 内存上限值 "limit": 'kube_pod_container_resource_limits_memory_bytes{{pod="{instance_name}", cluster_id="{cluster_id}"}}', }, diff --git a/apiserver/paasng/paasng/misc/monitoring/monitor/alert_rules/config/entities.py b/apiserver/paasng/paasng/misc/monitoring/monitor/alert_rules/config/entities.py index 9fdcac4086..9fd6f29dd6 100644 --- a/apiserver/paasng/paasng/misc/monitoring/monitor/alert_rules/config/entities.py +++ b/apiserver/paasng/paasng/misc/monitoring/monitor/alert_rules/config/entities.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import StrStructuredEnum -class AlertCode(str, StructuredEnum): +class AlertCode(StrStructuredEnum): HIGH_CPU_USAGE = "high_cpu_usage" HIGH_MEM_USAGE = "high_mem_usage" POD_RESTART = "pod_restart" diff --git a/apiserver/paasng/paasng/misc/operations/models.py b/apiserver/paasng/paasng/misc/operations/models.py index 6d61e0b318..d90c809917 100644 --- a/apiserver/paasng/paasng/misc/operations/models.py +++ b/apiserver/paasng/paasng/misc/operations/models.py @@ -118,7 +118,7 @@ class DeployOpValues: env_name: str has_succeeded: bool # `status` is optional to be compatible with legacy database data - status: Optional[bool] = None + status: Optional[str] = None class AppDeploymentOperationObj(OperationObj): diff --git a/apiserver/paasng/paasng/plat_admin/admin_cli/management/commands/adm_mapper_v1.py b/apiserver/paasng/paasng/plat_admin/admin_cli/management/commands/adm_mapper_v1.py index cad408e273..69c32efc95 100644 --- a/apiserver/paasng/paasng/plat_admin/admin_cli/management/commands/adm_mapper_v1.py +++ b/apiserver/paasng/paasng/plat_admin/admin_cli/management/commands/adm_mapper_v1.py @@ -37,9 +37,11 @@ python manage.py adm_mapper_v1 --action rollback --env-id {ENV_ID} """ + import sys -from enum import Enum +from blue_krill.data_types.enum import StrStructuredEnum +from django.core.exceptions import ObjectDoesNotExist from django.core.management.base import BaseCommand from paas_wl.bk_app.applications.api import get_latest_build_id @@ -53,7 +55,7 @@ from paasng.platform.engine.deploy.release.legacy import release_by_engine -class CommandAction(str, Enum): +class CommandAction(StrStructuredEnum): """A command action.""" # Upgrade to resource mapper v2 @@ -77,17 +79,17 @@ def add_arguments(self, parser): def handle(self, *args, **options): try: env = ModuleEnvironment.objects.get(id=options["env_id"]) - except ModuleEnvironment.DoesNotExist: + except ObjectDoesNotExist: self.exit_with_error(f"Environment {options['env_id']} does not exist") - - if options["action"] == CommandAction.UPGRADE.value: - self._handle_upgrade(env) - elif options["action"] == CommandAction.ROLLBACK.value: - self._handle_rollback(env) - elif options["action"] == CommandAction.CLEAN_V1.value: - self._handle_clean_v1(env) else: - raise RuntimeError("Invalid action") + if options["action"] == CommandAction.UPGRADE: + self._handle_upgrade(env) + elif options["action"] == CommandAction.ROLLBACK: + self._handle_rollback(env) + elif options["action"] == CommandAction.CLEAN_V1: + self._handle_clean_v1(env) + else: + raise RuntimeError("Invalid action") def _handle_upgrade(self, env: ModuleEnvironment): """Upgrade the environment to use resource mapper v2, it will re-deploy the environment diff --git a/apiserver/paasng/paasng/plat_admin/numbers/app.py b/apiserver/paasng/paasng/plat_admin/numbers/app.py index b04de5c864..c6f1d1a275 100644 --- a/apiserver/paasng/paasng/plat_admin/numbers/app.py +++ b/apiserver/paasng/paasng/plat_admin/numbers/app.py @@ -23,12 +23,12 @@ from collections import Counter, defaultdict from dataclasses import dataclass from datetime import date, datetime, timedelta -from enum import IntEnum from functools import lru_cache, reduce from typing import Any, Collection, Dict, Generator, Iterable, List, Optional, Set, Tuple, Type, Union, cast from bkpaas_auth import get_user_by_user_id from bkpaas_auth.models import user_id_encoder +from blue_krill.data_types.enum import IntStructuredEnum from django.conf import settings from django.utils.translation import gettext as _ from rest_framework.fields import get_attribute @@ -72,7 +72,7 @@ def get_pv_uv_for_env(*args, **kwargs) -> Tuple[int, int]: # type: ignore logger = logging.getLogger(__name__) -class DeployStatus(IntEnum): +class DeployStatus(IntStructuredEnum): PRODUCTION = 1 STAGING = 2 DEVELOPING = 3 diff --git a/apiserver/paasng/paasng/plat_admin/system/constants.py b/apiserver/paasng/paasng/plat_admin/system/constants.py index cf780ea838..6ae9f0d7f6 100644 --- a/apiserver/paasng/paasng/plat_admin/system/constants.py +++ b/apiserver/paasng/paasng/plat_admin/system/constants.py @@ -14,10 +14,9 @@ # # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. +from blue_krill.data_types.enum import IntStructuredEnum -from enum import IntEnum - -class SimpleAppSource(IntEnum): +class SimpleAppSource(IntStructuredEnum): DEFAULT = 1 LEGACY = 2 diff --git a/apiserver/paasng/paasng/platform/applications/constants.py b/apiserver/paasng/paasng/platform/applications/constants.py index 7013ac72c6..79567f9b3a 100644 --- a/apiserver/paasng/paasng/platform/applications/constants.py +++ b/apiserver/paasng/paasng/platform/applications/constants.py @@ -17,11 +17,11 @@ from typing import Type -from blue_krill.data_types.enum import EnumField, FeatureFlag, FeatureFlagField, StructuredEnum +from blue_krill.data_types.enum import EnumField, FeatureFlag, FeatureFlagField, IntStructuredEnum, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class ApplicationType(str, StructuredEnum): +class ApplicationType(StrStructuredEnum): DEFAULT = EnumField("default", label="普通应用") # 默认类型:无任何定制逻辑 ENGINELESS_APP = EnumField( "engineless_app", label="外链应用" @@ -31,7 +31,7 @@ class ApplicationType(str, StructuredEnum): CLOUD_NATIVE = EnumField("cloud_native", label="云原生应用") -class ApplicationRole(int, StructuredEnum): +class ApplicationRole(IntStructuredEnum): NOBODY = EnumField(-1, label="无身份用户") COLLABORATOR = EnumField(1, label="协作者") ADMINISTRATOR = EnumField(2, label="管理员") @@ -39,7 +39,7 @@ class ApplicationRole(int, StructuredEnum): OPERATOR = EnumField(4, label="运营") @classmethod - def get_roles(cls: Type[StructuredEnum]): + def get_roles(cls: Type[IntStructuredEnum]): return [ {"id": role.value, "name": role.name.lower()} for role in cls @@ -47,7 +47,7 @@ def get_roles(cls: Type[StructuredEnum]): ] -class AppLanguage(str, StructuredEnum): +class AppLanguage(StrStructuredEnum): PYTHON = EnumField("Python", label="Python") PHP = EnumField("PHP", label="PHP") GO = EnumField("Go", label="Go") @@ -74,7 +74,7 @@ def __str__(self): } -class AppEnvironment(str, StructuredEnum): +class AppEnvironment(StrStructuredEnum): STAGING = EnumField("stag", label="预发布环境") PRODUCTION = EnumField("prod", label="生产环境") @@ -102,11 +102,11 @@ class AppFeatureFlag(FeatureFlag): # type: ignore ENABLE_PERSISTENT_STORAGE = FeatureFlagField(label=_("开启持久存储挂载卷"), default=False) -class LightApplicationViewSetErrorCode(str, StructuredEnum): - SUCCESS = 0 - PARAM_NOT_VALID = 1301100 - CREATE_APP_ERROR = 1301101 - EDIT_APP_ERROR = 1301102 - ESB_NOT_VALID = 1301103 - APP_NOT_EXIST = 1301104 - NO_PERMISSION = 1301105 +class LightApplicationViewSetErrorCode(StrStructuredEnum): + SUCCESS = "0" + PARAM_NOT_VALID = "1301100" + CREATE_APP_ERROR = "1301101" + EDIT_APP_ERROR = "1301102" + ESB_NOT_VALID = "1301103" + APP_NOT_EXIST = "1301104" + NO_PERMISSION = "1301105" diff --git a/apiserver/paasng/paasng/platform/applications/management/commands/force_del_app.py b/apiserver/paasng/paasng/platform/applications/management/commands/force_del_app.py index c127a240ea..2930d05156 100644 --- a/apiserver/paasng/paasng/platform/applications/management/commands/force_del_app.py +++ b/apiserver/paasng/paasng/platform/applications/management/commands/force_del_app.py @@ -17,7 +17,7 @@ import logging -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import StrStructuredEnum from django.core.management.base import BaseCommand from paasng.accessories.publish.sync_market.managers import AppManger @@ -28,7 +28,7 @@ logger = logging.getLogger(__name__) -class DelKeyType(str, StructuredEnum): +class DelKeyType(StrStructuredEnum): """Source origin defines the origin of module's source code""" CODE = "code" diff --git a/apiserver/paasng/paasng/platform/bkapp_model/constants.py b/apiserver/paasng/paasng/platform/bkapp_model/constants.py index bdf8e840a7..d6ec529515 100644 --- a/apiserver/paasng/paasng/platform/bkapp_model/constants.py +++ b/apiserver/paasng/paasng/platform/bkapp_model/constants.py @@ -15,7 +15,7 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum # legacy: Slug runner 默认的 entrypoint, 平台所有 slug runner 镜像都以该值作为入口 # TODO: 需验证存量所有镜像是否都设置了默认的 entrypoint, 如是, 即可移除所有 DEFAULT_SLUG_RUNNER_ENTRYPOINT @@ -25,7 +25,7 @@ PORT_PLACEHOLDER = "${PORT}" -class ExposedTypeName(str, StructuredEnum): +class ExposedTypeName(StrStructuredEnum): """与 paas_wl.workloads.networking.constants.ExposedTypeName 重复定义 # TODO 将 paasng 和 paas_wl 中重复定义的一些常量, 合并放到更底层的模块中, 避免破坏当前 importlinter 的依赖规则? """ @@ -33,7 +33,7 @@ class ExposedTypeName(str, StructuredEnum): BK_HTTP = "bk/http" -class NetworkProtocol(str, StructuredEnum): +class NetworkProtocol(StrStructuredEnum): """与 paas_wl.workloads.networking.constants.NetworkProtocol 重复定义 # TODO 将 paasng 和 paas_wl 中重复定义的一些常量, 合并放到更底层的模块中, 避免破坏当前 importlinter 的依赖规则? """ @@ -42,7 +42,7 @@ class NetworkProtocol(str, StructuredEnum): UDP = EnumField("UDP", label="UDP") -class ImagePullPolicy(str, StructuredEnum): +class ImagePullPolicy(StrStructuredEnum): """duplicated from paas_wl.workloads.release_controller.constants.ImagePullPolicy to decouple dependencies TODO 统一放置到一个独立于 paas_wl 和 paasng 的模块下? """ @@ -52,7 +52,7 @@ class ImagePullPolicy(str, StructuredEnum): NEVER = EnumField("Never") -class ResQuotaPlan(str, StructuredEnum): +class ResQuotaPlan(StrStructuredEnum): """duplicated from paas_wl.bk_app.cnative.specs.constants.ResQuotaPlan to decouple dependencies TODO 统一放置到一个独立于 paas_wl 和 paasng 的模块下? """ @@ -62,23 +62,11 @@ class ResQuotaPlan(str, StructuredEnum): P_4C2G = EnumField("4C2G", label="4C2G") P_4C4G = EnumField("4C4G", label="4C4G") - # simulate `ReprEnum` behavior to work well with DRF serializer - # see also: - # - https://docs.python.org/3/library/enum.html#enum.ReprEnum - # - https://docs.python.org/3/library/enum.html#enum.Enum.__str__ - __str__ = str.__str__ - -class ScalingPolicy(str, StructuredEnum): +class ScalingPolicy(StrStructuredEnum): """duplicated from paas_wl.bk_app.cnative.specs.constants.ScalingPolicy to decouple dependencies TODO 统一放置到一个独立于 paas_wl 和 paasng 的模块下? """ # the default autoscaling policy (cpu utilization 85%) DEFAULT = EnumField("default") - - # simulate `ReprEnum` behavior to work well with DRF serializer - # see also: - # - https://docs.python.org/3/library/enum.html#enum.ReprEnum - # - https://docs.python.org/3/library/enum.html#enum.Enum.__str__ - __str__ = str.__str__ diff --git a/apiserver/paasng/paasng/platform/bkapp_model/utils.py b/apiserver/paasng/paasng/platform/bkapp_model/utils.py index f7d95b06c8..ef719d5c4d 100644 --- a/apiserver/paasng/paasng/platform/bkapp_model/utils.py +++ b/apiserver/paasng/paasng/platform/bkapp_model/utils.py @@ -17,7 +17,7 @@ import copy from typing import List, Optional, Tuple -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import StrStructuredEnum from paas_wl.bk_app.cnative.specs.crd.bk_app import EnvVar, EnvVarOverlay from paasng.platform.applications.constants import ApplicationType @@ -27,7 +27,7 @@ from paasng.platform.modules.models import BuildConfig, Module -class MergeStrategy(str, StructuredEnum): +class MergeStrategy(StrStructuredEnum): """Different strategy when merging env vars""" OVERRIDE = "Override" diff --git a/apiserver/paasng/paasng/platform/declarative/constants.py b/apiserver/paasng/paasng/platform/declarative/constants.py index 4436b13870..12d7631072 100644 --- a/apiserver/paasng/paasng/platform/declarative/constants.py +++ b/apiserver/paasng/paasng/platform/declarative/constants.py @@ -17,7 +17,7 @@ from typing import Any, TypeVar -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum, StrStructuredEnum T = TypeVar("T") @@ -43,7 +43,7 @@ def dict(self, *args, **kwargs): OMITTED_VALUE = OmittedType() -class AppSpecVersion(StructuredEnum): +class AppSpecVersion(IntStructuredEnum): # VER_1 meaning app.yaml is provided by S-Mart App VER_1 = 1 VER_2 = 2 @@ -51,12 +51,12 @@ class AppSpecVersion(StructuredEnum): VER_3 = 3 -class AppDescPluginType(str, StructuredEnum): +class AppDescPluginType(StrStructuredEnum): APP_VERSION = EnumField("app_version", label="应用版本") APP_LIBRARIES = EnumField("app_libraries", label="应用依赖库") -class DiffType(str, StructuredEnum): +class DiffType(StrStructuredEnum): ADDED = EnumField("added", label="新增") DELETED = EnumField("deleted", label="删除") NOT_MODIFIED = EnumField("not_modified", label="未改动") diff --git a/apiserver/paasng/paasng/platform/engine/constants.py b/apiserver/paasng/paasng/platform/engine/constants.py index 62a4bb325b..a125c27648 100644 --- a/apiserver/paasng/paasng/platform/engine/constants.py +++ b/apiserver/paasng/paasng/platform/engine/constants.py @@ -17,7 +17,7 @@ from typing import List -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ from paasng.utils.basic import ChoicesEnum @@ -27,21 +27,21 @@ IMAGE_RELEASE_STEPSET_NAME = "image-release" -class ClusterType(str, StructuredEnum): +class ClusterType(StrStructuredEnum): """集群类别""" NORMAL = EnumField("normal", label=_("普通集群")) VIRTUAL = EnumField("virtual", label=_("虚拟集群")) -class AppEnvName(str, StructuredEnum): +class AppEnvName(StrStructuredEnum): """The default environment names""" STAG = EnumField("stag", label=_("预发布环境")) PROD = EnumField("prod", label=_("生产环境")) -class JobStatus(str, StructuredEnum): +class JobStatus(StrStructuredEnum): SUCCESSFUL = EnumField("successful", label="成功") FAILED = EnumField("failed", label="失败") PENDING = EnumField("pending", label="等待") @@ -53,7 +53,7 @@ def get_finished_states(cls) -> List[str]: return [cls.FAILED, cls.SUCCESSFUL, cls.INTERRUPTED] -class BuildStatus(str, StructuredEnum): +class BuildStatus(StrStructuredEnum): """While `BuildStatus` has same members with `JobStatus`, different statuses might be added in the future""" SUCCESSFUL = "successful" @@ -67,7 +67,7 @@ def get_finished_states(cls) -> List[str]: return [cls.FAILED, cls.SUCCESSFUL, cls.INTERRUPTED] -class ReleaseStatus(str, StructuredEnum): +class ReleaseStatus(StrStructuredEnum): """While `ReleaseStatus` has same members with `JobStatus`, different statuses might be added in the future""" SUCCESSFUL = "successful" @@ -109,7 +109,7 @@ class MetricsType(ChoicesEnum): _choices_labels = ((MEM, "mem"), (CPU, "cpu"), (__ALL__, "__all__")) -class ConfigVarEnvName(str, StructuredEnum): +class ConfigVarEnvName(StrStructuredEnum): """Environment name for managing config var""" STAG = EnumField("stag", label="仅测试环境") @@ -141,20 +141,20 @@ class DeployConditions(ChoicesEnum): ) -class RuntimeType(str, StructuredEnum): +class RuntimeType(StrStructuredEnum): BUILDPACK = EnumField("buildpack", label=_("使用 Buildpacks 构建")) DOCKERFILE = EnumField("dockerfile", label=_("使用 Dockerfile 构建")) CUSTOM_IMAGE = EnumField("custom_image", label="Custom Image(云原生和旧镜像应用)") -class AppInfoBuiltinEnv(str, StructuredEnum): +class AppInfoBuiltinEnv(StrStructuredEnum): """应用基本信息的内置环境变量built-in""" APP_ID = EnumField("APP_ID", label=_("蓝鲸应用ID")) APP_SECRET = EnumField("APP_SECRET", label=_("蓝鲸应用密钥")) -class AppRunTimeBuiltinEnv(str, StructuredEnum): +class AppRunTimeBuiltinEnv(StrStructuredEnum): """Built-in envs in the app runtime""" APP_MODULE_NAME = EnumField("APP_MODULE_NAME", label=_("应用当前模块名")) diff --git a/apiserver/paasng/paasng/platform/engine/models/phases.py b/apiserver/paasng/paasng/platform/engine/models/phases.py index 85d953625f..89725d6d80 100644 --- a/apiserver/paasng/paasng/platform/engine/models/phases.py +++ b/apiserver/paasng/paasng/platform/engine/models/phases.py @@ -17,7 +17,7 @@ from typing import TYPE_CHECKING, Dict -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.db import models from django.utils.translation import gettext_lazy as _ @@ -32,7 +32,7 @@ from paasng.platform.engine.models.steps import DeployStep -class DeployPhaseTypes(str, StructuredEnum): +class DeployPhaseTypes(StrStructuredEnum): """部署阶段""" PREPARATION = EnumField("preparation", label=_("准备阶段")) diff --git a/apiserver/paasng/paasng/platform/engine/processes/events.py b/apiserver/paasng/paasng/platform/engine/processes/events.py index 882520209c..1809bdb379 100644 --- a/apiserver/paasng/paasng/platform/engine/processes/events.py +++ b/apiserver/paasng/paasng/platform/engine/processes/events.py @@ -16,11 +16,13 @@ # to the current version of the project delivered to anyone in the future. """Process events related functions""" + import logging from dataclasses import dataclass -from enum import IntEnum from typing import Any, Dict, Iterator, List, Tuple +from blue_krill.data_types.enum import IntStructuredEnum + from paas_wl.bk_app.processes.processes import PlainInstance, PlainProcess from paasng.platform.engine.processes.utils import diff_list @@ -29,11 +31,11 @@ @dataclass class ProcessBaseEvent: - type: IntEnum + type: IntStructuredEnum invoker: Any -class ProcessEventType(IntEnum): +class ProcessEventType(IntStructuredEnum): CREATED = 1 REMOVED = 2 UPDATED_COMMAND = 3 @@ -47,7 +49,7 @@ class ProcessEvent(ProcessBaseEvent): message: str -class ProcInstEventType(IntEnum): +class ProcInstEventType(IntStructuredEnum): CREATED = 1 REMOVED = 2 UPDATED_BECOME_READY = 3 diff --git a/apiserver/paasng/paasng/platform/engine/utils/output.py b/apiserver/paasng/paasng/platform/engine/utils/output.py index 3b4c583b6c..878aed7463 100644 --- a/apiserver/paasng/paasng/platform/engine/utils/output.py +++ b/apiserver/paasng/paasng/platform/engine/utils/output.py @@ -17,9 +17,9 @@ import abc import json import sys -from enum import Enum from typing import Optional, Protocol +from blue_krill.data_types.enum import StrStructuredEnum from blue_krill.redis_tools.messaging import StreamChannel from django.conf import settings @@ -67,7 +67,7 @@ class Style: White = make_style(fg="white", opts=("bold",)) -class StreamType(str, Enum): +class StreamType(StrStructuredEnum): STDOUT = "STDOUT" STDERR = "STDERR" diff --git a/apiserver/paasng/paasng/platform/environments/constants.py b/apiserver/paasng/paasng/platform/environments/constants.py index ad9964db7c..a65f5e7179 100644 --- a/apiserver/paasng/paasng/platform/environments/constants.py +++ b/apiserver/paasng/paasng/platform/environments/constants.py @@ -14,6 +14,7 @@ # # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. +from typing import List from paasng.platform.applications.constants import ApplicationRole from paasng.utils.basic import ChoicesEnum @@ -29,5 +30,5 @@ class EnvRoleOperation(ChoicesEnum): } @classmethod - def get_default_role(cls, operation: str): - return cls.__default.value[operation] + def get_default_role(cls, operation: str) -> List[int]: + return cls.__default[operation] # type: ignore diff --git a/apiserver/paasng/paasng/platform/evaluation/constants.py b/apiserver/paasng/paasng/platform/evaluation/constants.py index 3e1ffad489..93f76e106d 100644 --- a/apiserver/paasng/paasng/platform/evaluation/constants.py +++ b/apiserver/paasng/paasng/platform/evaluation/constants.py @@ -15,31 +15,31 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class BatchTaskStatus(str, StructuredEnum): +class BatchTaskStatus(StrStructuredEnum): """任务状态""" RUNNING = EnumField("running", label=_("运行中")) FINISHED = EnumField("finished", label=_("已完成")) -class EmailNotificationType(str, StructuredEnum): +class EmailNotificationType(StrStructuredEnum): """邮件通知类型""" IDLE_APP_MODULE_ENVS = EnumField("idle_app_module_envs", label=_("闲置应用模块")) -class EmailReceiverType(str, StructuredEnum): +class EmailReceiverType(StrStructuredEnum): """邮件接收者类型""" PLAT_ADMIN = EnumField("plat_admin", label=_("平台管理员")) APP_DEVELOPER = EnumField("app_developer", label=_("应用开发者")) -class OperationIssueType(str, StructuredEnum): +class OperationIssueType(StrStructuredEnum): """应用运营问题类型""" NONE = EnumField("none", label=_("无")) diff --git a/apiserver/paasng/paasng/platform/mgrlegacy/constants.py b/apiserver/paasng/paasng/platform/mgrlegacy/constants.py index 6db8b1ad02..ecadc31910 100644 --- a/apiserver/paasng/paasng/platform/mgrlegacy/constants.py +++ b/apiserver/paasng/paasng/platform/mgrlegacy/constants.py @@ -17,7 +17,7 @@ from dataclasses import dataclass -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import StrStructuredEnum from paasng.utils.basic import ChoicesEnum @@ -121,7 +121,7 @@ class AppMember: role: int -class CNativeMigrationStatus(str, StructuredEnum): +class CNativeMigrationStatus(StrStructuredEnum): DEFAULT = "default" ON_MIGRATION = "on_migration" MIGRATION_SUCCEEDED = "migration_succeeded" diff --git a/apiserver/paasng/paasng/platform/modules/constants.py b/apiserver/paasng/paasng/platform/modules/constants.py index 43f8228d13..8f6d5f4004 100644 --- a/apiserver/paasng/paasng/platform/modules/constants.py +++ b/apiserver/paasng/paasng/platform/modules/constants.py @@ -15,26 +15,25 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from enum import Enum, IntEnum from typing import Dict, List -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, IntStructuredEnum, StrStructuredEnum DEFAULT_ENGINE_APP_PREFIX = "bkapp" -class ModuleName(str, Enum): +class ModuleName(StrStructuredEnum): DEFAULT = "default" -class ExposedURLType(IntEnum): +class ExposedURLType(IntStructuredEnum): # eg: http://foo.com/region-bkapp-code-stag/ SUBPATH = 1 # eg: http://code.foo-apps.com/ SUBDOMAIN = 2 -class SourceOrigin(int, StructuredEnum): +class SourceOrigin(IntStructuredEnum): """Source origin defines the origin of module's source code""" AUTHORIZED_VCS = EnumField(1, "Authorized VCS") @@ -58,7 +57,7 @@ def get_package_origins(cls) -> List["SourceOrigin"]: return [SourceOrigin.BK_LESS_CODE, SourceOrigin.S_MART, SourceOrigin.AI_AGENT] -class APP_CATEGORY(str, StructuredEnum): +class APP_CATEGORY(StrStructuredEnum): """Application category, used when setting label to images""" NORMAL_APP = "normal_app" @@ -67,7 +66,7 @@ class APP_CATEGORY(str, StructuredEnum): LEGACY_APP = "legacy_app" -class DeployHookType(str, StructuredEnum): +class DeployHookType(StrStructuredEnum): """DeployHook Type""" PRE_RELEASE_HOOK = EnumField("pre-release-hook", label="部署前置钩子") @@ -80,7 +79,7 @@ def _missing_(cls, value): return super()._missing_(value) -class BuildPackType(str, StructuredEnum): +class BuildPackType(StrStructuredEnum): # legacy heroku buildpack format, just a tarball TAR = EnumField("tar", label="tar") @@ -102,7 +101,7 @@ def get_buildpack_builder_type_map(cls) -> Dict["BuildPackType", "AppImageType"] } -class AppImageType(str, StructuredEnum): +class AppImageType(StrStructuredEnum): LEGACY = EnumField("legacy", label="legacy") CNB = EnumField("cnb", label="cnb") diff --git a/apiserver/paasng/paasng/platform/smart_app/constants.py b/apiserver/paasng/paasng/platform/smart_app/constants.py index af1d403c2d..a37ceaaca6 100644 --- a/apiserver/paasng/paasng/platform/smart_app/constants.py +++ b/apiserver/paasng/paasng/platform/smart_app/constants.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from enum import Enum +from blue_krill.data_types.enum import StrStructuredEnum -class SMartPackageBuilderVersionFlag(str, Enum): +class SMartPackageBuilderVersionFlag(StrStructuredEnum): """s-mart 包构建器版本, 不同版本的构建器输出的产物类型不一样""" # 源码包 diff --git a/apiserver/paasng/paasng/platform/sourcectl/client.py b/apiserver/paasng/paasng/platform/sourcectl/client.py index f7f7dedb54..92686023d4 100644 --- a/apiserver/paasng/paasng/platform/sourcectl/client.py +++ b/apiserver/paasng/paasng/platform/sourcectl/client.py @@ -21,7 +21,7 @@ from typing import Any, Dict, Generator, List, Optional import requests -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ from oauthlib.oauth2.rfc6749.errors import OAuth2Error @@ -43,7 +43,7 @@ RETRY_TIME = 3 -class GitRepoProvider(str, StructuredEnum): +class GitRepoProvider(StrStructuredEnum): """Git 仓库服务提供方""" GitHub = EnumField("github", label="GitHub") @@ -70,7 +70,7 @@ def __init__(self, api_url: str, **kwargs): raise exceptions.AccessTokenMissingError("oauth_token required") self.session.headers.update(headers) - self.__token_holder: Oauth2TokenHolder = kwargs.get("__token_holder", None) + self.__token_holder: Optional[Oauth2TokenHolder] = kwargs.get("__token_holder") @abc.abstractmethod def list_repo(self, **kwargs) -> List[Dict]: diff --git a/apiserver/paasng/paasng/platform/sourcectl/constants.py b/apiserver/paasng/paasng/platform/sourcectl/constants.py index 76cb29482a..d28b4280c2 100644 --- a/apiserver/paasng/paasng/platform/sourcectl/constants.py +++ b/apiserver/paasng/paasng/platform/sourcectl/constants.py @@ -14,20 +14,19 @@ # # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. - -from blue_krill.data_types.enum import EnumField, FeatureFlagField, StructuredEnum +from blue_krill.data_types.enum import EnumField, FeatureFlagField, StrStructuredEnum from paasng.infras.accounts.constants import AccountFeatureFlag -class DiffFeatureType(str, StructuredEnum): +class DiffFeatureType(StrStructuredEnum): """代码对比类型""" INTERNAL = "internal" EXTERNAL = "external" -class BasicSourceType(str, StructuredEnum): +class BasicSourceType(StrStructuredEnum): """基础源码类型""" GIT = "git" @@ -35,16 +34,15 @@ class BasicSourceType(str, StructuredEnum): PACKAGE = "package" -def register_new_sourcectl_type(name: str, feature_flag: FeatureFlagField): +def register_new_sourcectl_type(feature_flag: FeatureFlagField): """暴露给 TE 版本的注册 SourcectlType 的方法 - :param name: 源码类型名称 :param feature_flag: 用于控制该源码系统的黑/白名单 """ AccountFeatureFlag.register_ext_feature_flag(feature_flag) -class VersionType(str, StructuredEnum): +class VersionType(StrStructuredEnum): """版本类型. 对应 VersionInfo.version_type""" TAG = EnumField("tag", label="用于 Git 仓库、云原生镜像应用、旧镜像应用、镜像模式的 S-Mart 应用") diff --git a/apiserver/paasng/paasng/platform/sourcectl/exceptions.py b/apiserver/paasng/paasng/platform/sourcectl/exceptions.py index a5d8ed05dc..1306eb9999 100644 --- a/apiserver/paasng/paasng/platform/sourcectl/exceptions.py +++ b/apiserver/paasng/paasng/platform/sourcectl/exceptions.py @@ -45,6 +45,10 @@ class AccessTokenError(Exception): """access token 校验失败""" +class AccessTokenHolderError(Exception): + """token holder 异常(如:未提供)""" + + class RequestError(Exception): """请求异常""" diff --git a/apiserver/paasng/paasng/platform/sourcectl/source_types.py b/apiserver/paasng/paasng/platform/sourcectl/source_types.py index f41bf8c423..d0bc6460f7 100644 --- a/apiserver/paasng/paasng/platform/sourcectl/source_types.py +++ b/apiserver/paasng/paasng/platform/sourcectl/source_types.py @@ -16,6 +16,7 @@ # to the current version of the project delivered to anyone in the future. """Sourcectl type specifications""" + import logging from collections import OrderedDict, defaultdict from dataclasses import dataclass @@ -227,7 +228,7 @@ def load_from_configs(self, configs: List): type_specs = cls(**conf["attrs"]) self.data[type_specs.name] = type_specs - register_new_sourcectl_type(type_specs.name, type_specs.make_feature_flag_field()) + register_new_sourcectl_type(type_specs.make_feature_flag_field()) self.initialized = True diff --git a/apiserver/paasng/paasng/platform/templates/constants.py b/apiserver/paasng/paasng/platform/templates/constants.py index ef5813774b..c0dc726fd7 100644 --- a/apiserver/paasng/paasng/platform/templates/constants.py +++ b/apiserver/paasng/paasng/platform/templates/constants.py @@ -15,11 +15,11 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from django.utils.translation import gettext_lazy as _ -class TemplateType(str, StructuredEnum): +class TemplateType(StrStructuredEnum): """模板类型""" NORMAL = EnumField("normal", _("普通应用")) diff --git a/apiserver/paasng/paasng/utils/blobstore.py b/apiserver/paasng/paasng/utils/blobstore.py index b2212d48b5..a58073b1bc 100644 --- a/apiserver/paasng/paasng/utils/blobstore.py +++ b/apiserver/paasng/paasng/utils/blobstore.py @@ -27,7 +27,7 @@ import boto3 from bkstorages.backends.bkrepo import BKRepoStorage from bkstorages.backends.rgw import RGWBoto3Storage -from blue_krill.data_types.enum import EnumField, StructuredEnum +from blue_krill.data_types.enum import EnumField, StrStructuredEnum from blue_krill.storages.blobstore.base import BlobStore from blue_krill.storages.blobstore.bkrepo import BKGenericRepo from blue_krill.storages.blobstore.s3 import S3Store @@ -39,7 +39,7 @@ logger = logging.getLogger(__name__) -class StoreType(str, StructuredEnum): +class StoreType(StrStructuredEnum): S3 = EnumField("s3") BKREPO = EnumField("bkrepo") # 向前兼容, 支持 http/https 协议 diff --git a/apiserver/paasng/paasng/utils/patternmatcher.py b/apiserver/paasng/paasng/utils/patternmatcher.py index c840d78c41..910161a8d2 100644 --- a/apiserver/paasng/paasng/utils/patternmatcher.py +++ b/apiserver/paasng/paasng/utils/patternmatcher.py @@ -21,10 +21,10 @@ from dataclasses import dataclass from typing import Optional -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import IntStructuredEnum -class MatchType(int, StructuredEnum): +class MatchType(IntStructuredEnum): Unknown = 0 Excat = 1 Prefix = 2 diff --git a/apiserver/paasng/paasng/utils/rate_limit/constants.py b/apiserver/paasng/paasng/utils/rate_limit/constants.py index a8a0b07422..a906373013 100644 --- a/apiserver/paasng/paasng/utils/rate_limit/constants.py +++ b/apiserver/paasng/paasng/utils/rate_limit/constants.py @@ -15,10 +15,10 @@ # We undertake not to change the open source license (MIT license) applicable # to the current version of the project delivered to anyone in the future. -from blue_krill.data_types.enum import StructuredEnum +from blue_krill.data_types.enum import IntStructuredEnum -class UserAction(int, StructuredEnum): +class UserAction(IntStructuredEnum): """ 用于频率限制的用户操作 diff --git a/apiserver/poetry.lock b/apiserver/poetry.lock index 0e99b72e7b..277a8f8829 100644 --- a/apiserver/poetry.lock +++ b/apiserver/poetry.lock @@ -2,15 +2,15 @@ [[package]] name = "aenum" -version = "2.1.2" +version = "3.1.15" description = "Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants" category = "main" optional = false python-versions = "*" files = [ - {file = "aenum-2.1.2-py2-none-any.whl", hash = "sha256:7a77c205c4bc9d7fe9bd73b3193002d724aebf5909fa0d297534208953891ec8"}, - {file = "aenum-2.1.2-py3-none-any.whl", hash = "sha256:3df9b84cce5dc9ed77c337079f97b66c44c0053eb87d6f4d46b888dc45801e38"}, - {file = "aenum-2.1.2.tar.gz", hash = "sha256:a3208e4b28db3a7b232ff69b934aef2ea1bf27286d9978e1e597d46f490e4687"}, + {file = "aenum-3.1.15-py2-none-any.whl", hash = "sha256:27b1710b9d084de6e2e695dab78fe9f269de924b51ae2850170ee7e1ca6288a5"}, + {file = "aenum-3.1.15-py3-none-any.whl", hash = "sha256:e0dfaeea4c2bd362144b87377e2c61d91958c5ed0b4daf89cb6f45ae23af6288"}, + {file = "aenum-3.1.15.tar.gz", hash = "sha256:8cbd76cd18c4f870ff39b24284d3ea028fbe8731a58df3aa581e434c575b9559"}, ] [package.source] @@ -136,9 +136,6 @@ files = [ {file = "asgiref-3.8.1.tar.gz", hash = "sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590"}, ] -[package.dependencies] -typing-extensions = {version = ">=4", markers = "python_version < \"3.11\""} - [package.extras] tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] @@ -165,58 +162,21 @@ reference = "tencent-mirror" [[package]] name = "attrs" -version = "21.4.0" +version = "22.1.0" description = "Classes Without Boilerplate" category = "main" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = ">=3.5" files = [ - {file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, - {file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, + {file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"}, + {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"}, ] [package.extras] -dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "six", "sphinx", "sphinx-notfound-page", "zope.interface"] +dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"] docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"] -tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "six", "zope.interface"] -tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "six"] - -[package.source] -type = "legacy" -url = "https://mirrors.tencent.com/pypi/simple" -reference = "tencent-mirror" - -[[package]] -name = "backports-zoneinfo" -version = "0.2.1" -description = "Backport of the standard library zoneinfo module" -category = "main" -optional = false -python-versions = ">=3.6" -files = [ - {file = "backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:da6013fd84a690242c310d77ddb8441a559e9cb3d3d59ebac9aca1a57b2e18bc"}, - {file = "backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:89a48c0d158a3cc3f654da4c2de1ceba85263fafb861b98b59040a5086259722"}, - {file = "backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:1c5742112073a563c81f786e77514969acb58649bcdf6cdf0b4ed31a348d4546"}, - {file = "backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl", hash = "sha256:e8236383a20872c0cdf5a62b554b27538db7fa1bbec52429d8d106effbaeca08"}, - {file = "backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl", hash = "sha256:8439c030a11780786a2002261569bdf362264f605dfa4d65090b64b05c9f79a7"}, - {file = "backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:f04e857b59d9d1ccc39ce2da1021d196e47234873820cbeaad210724b1ee28ac"}, - {file = "backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf"}, - {file = "backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5c144945a7752ca544b4b78c8c41544cdfaf9786f25fe5ffb10e838e19a27570"}, - {file = "backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl", hash = "sha256:e55b384612d93be96506932a786bbcde5a2db7a9e6a4bb4bffe8b733f5b9036b"}, - {file = "backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a76b38c52400b762e48131494ba26be363491ac4f9a04c1b7e92483d169f6582"}, - {file = "backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:8961c0f32cd0336fb8e8ead11a1f8cd99ec07145ec2931122faaac1c8f7fd987"}, - {file = "backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e81b76cace8eda1fca50e345242ba977f9be6ae3945af8d46326d776b4cf78d1"}, - {file = "backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9"}, - {file = "backports.zoneinfo-0.2.1-cp38-cp38-win32.whl", hash = "sha256:1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328"}, - {file = "backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl", hash = "sha256:4a0f800587060bf8880f954dbef70de6c11bbe59c673c3d818921f042f9954a6"}, - {file = "backports.zoneinfo-0.2.1.tar.gz", hash = "sha256:fadbfe37f74051d024037f223b8e001611eac868b5c5b06144ef4d8b799862f2"}, -] - -[package.dependencies] -tzdata = {version = "*", optional = true, markers = "extra == \"tzdata\""} - -[package.extras] -tzdata = ["tzdata"] +tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "zope.interface"] +tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"] [package.source] type = "legacy" @@ -283,14 +243,14 @@ reference = "tencent-mirror" [[package]] name = "bk-crypto-python-sdk" -version = "1.1.1" +version = "2.0.0" description = "bk-crypto-python-sdk is a lightweight cryptography toolkit for Python applications based on Cryptodome / tongsuopy and other encryption libraries." category = "main" optional = false -python-versions = ">=3.6.2,<3.11" +python-versions = ">=3.8,<3.12" files = [ - {file = "bk-crypto-python-sdk-1.1.1.tar.gz", hash = "sha256:dee920ca58d402cc203a4cc704993685c626a801ff3c60942ec7c412d6b194b2"}, - {file = "bk_crypto_python_sdk-1.1.1-py3-none-any.whl", hash = "sha256:042f1651a927cbf3e3cae2b3c2688b8151d572032e480bff7aa9d96405632c0a"}, + {file = "bk_crypto_python_sdk-2.0.0-py3-none-any.whl", hash = "sha256:7ae6b83b9ffc708bb8f756e245e69cbc59cca3cb6b942c75a0bf3a9c9cb0918d"}, + {file = "bk_crypto_python_sdk-2.0.0.tar.gz", hash = "sha256:6d76c27678950fa6713b51a42e81063ff3074c2ce5c30057e4f83f10903b9060"}, ] [package.dependencies] @@ -438,14 +398,14 @@ reference = "tencent-mirror" [[package]] name = "bkstorages" -version = "1.1.0" +version = "1.1.1" description = "File storage backends for blueking PaaS platform" category = "main" optional = false -python-versions = ">=3.6.2,<3.11" +python-versions = ">=3.6.2,<3.12" files = [ - {file = "bkstorages-1.1.0-py3-none-any.whl", hash = "sha256:24bd939e9e7c0073b23b5fb5a54fd936f50d20dd0e3be2b37cf693ec9b0d3a13"}, - {file = "bkstorages-1.1.0.tar.gz", hash = "sha256:7af8a440520a218c634b6ef0cf3dadcc37016c7db3ea690a146c45970e8be707"}, + {file = "bkstorages-1.1.1-py3-none-any.whl", hash = "sha256:2b617a3519cb63013fd85a581201cdf9daf4ab7b6e9d61fb4314f4463b736cd8"}, + {file = "bkstorages-1.1.1.tar.gz", hash = "sha256:8ad9431857636f4c4576dec9deb8ee0dcab267ace943076c4cbf27b357022274"}, ] [package.dependencies] @@ -483,29 +443,30 @@ reference = "tencent-mirror" [[package]] name = "blue-krill" -version = "2.0.3" +version = "2.0.7" description = "Tools and common packages for blueking PaaS platform." category = "main" optional = false -python-versions = ">=3.8,<3.11" +python-versions = ">=3.8,<3.12" files = [ - {file = "blue_krill-2.0.3-py3-none-any.whl", hash = "sha256:f30ae9bbce3cc038b0f4a3d092935147a8f58ee18a225d1dbf25daf561fa7304"}, - {file = "blue_krill-2.0.3.tar.gz", hash = "sha256:7c8b1073f687ac4fa84d585a053bb62ce4056f6d0158db2389c1803dfa93994f"}, + {file = "blue_krill-2.0.7-py3-none-any.whl", hash = "sha256:3b7cbd86a8ed1721fe853981d48b19485115f4db8f6b69d3cf33f34b7299b8e3"}, + {file = "blue_krill-2.0.7.tar.gz", hash = "sha256:7d0e42762033e63881ec7ab978f04558d17f1971ac132ef55812cbc7733561d5"}, ] [package.dependencies] -bk-crypto-python-sdk = ">=1.0.4,<2.0.0" +bk-crypto-python-sdk = ">=2.0.0,<3.0.0" click = "*" cryptography = ">=3.0.0" curlify = ">=2.2.1,<3.0.0" -django-environ = ">=0.8.1,<0.9.0" +django-environ = ">=0.8.1" pydantic = "*" pyjwt = ">=1.7.1" python-editor = ">=1.0.4,<2.0.0" requests = "*" six = "*" toml = "*" -watchdog = ">=1.0.2,<2.0.0" +urllib3 = ">=1.26.16,<2.0.0" +watchdog = "*" [package.source] type = "legacy" @@ -569,10 +530,7 @@ files = [ [package.dependencies] jmespath = ">=0.7.1,<2.0.0" python-dateutil = ">=2.1,<3.0.0" -urllib3 = [ - {version = ">=1.25.4,<1.27", markers = "python_version < \"3.10\""}, - {version = ">=1.25.4,<2.1", markers = "python_version >= \"3.10\""}, -] +urllib3 = {version = ">=1.25.4,<2.1", markers = "python_version >= \"3.10\""} [package.extras] crt = ["awscrt (==0.19.17)"] @@ -632,7 +590,6 @@ files = [ ] [package.dependencies] -"backports.zoneinfo" = {version = ">=0.2.1", markers = "python_version < \"3.9\""} billiard = ">=4.2.0,<5.0" click = ">=8.1.2,<9.0" click-didyoumean = ">=0.3.0" @@ -684,14 +641,14 @@ reference = "tencent-mirror" [[package]] name = "certifi" -version = "2024.2.2" +version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." category = "main" optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, - {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, + {file = "certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"}, + {file = "certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"}, ] [package.source] @@ -1104,9 +1061,6 @@ files = [ {file = "coverage-7.4.4.tar.gz", hash = "sha256:c901df83d097649e257e803be22592aedfd5182f07b3cc87d640bbb9afd50f49"}, ] -[package.dependencies] -tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} - [package.extras] toml = ["tomli"] @@ -1559,7 +1513,6 @@ files = [ ] [package.dependencies] -"backports.zoneinfo" = {version = "*", markers = "python_version < \"3.9\""} django = ">=3.0" [package.source] @@ -1673,21 +1626,23 @@ reference = "tencent-mirror" [[package]] name = "elasticsearch" -version = "7.5.1" +version = "7.17.12" description = "Python client for Elasticsearch" category = "main" optional = false -python-versions = "*" +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4" files = [ - {file = "elasticsearch-7.5.1-py2.py3-none-any.whl", hash = "sha256:1815ee1377e7d3cf32770738a70785fe4ab1f05be28336a330ed71cb295a7c6c"}, - {file = "elasticsearch-7.5.1.tar.gz", hash = "sha256:2a0ca516378ae9b87ac840e7bb529ec508f3010360dd9feed605dff2a898aff5"}, + {file = "elasticsearch-7.17.12-py2.py3-none-any.whl", hash = "sha256:468fd5eef703c0d9238e29bcaf3a6fe4d6b092f917959fbf41f48f8fea3df2f8"}, + {file = "elasticsearch-7.17.12.tar.gz", hash = "sha256:a1f5733ae8cf1dbf0a78593389f2503c87dd97429976099832bf0626cdfaac8b"}, ] [package.dependencies] -urllib3 = ">=1.21.1" +certifi = "*" +urllib3 = ">=1.21.1,<2" [package.extras] -develop = ["black", "coverage", "jinja2", "mock", "nose", "nosexcover", "pyaml", "requests (>=2.0.0,<3.0.0)", "sphinx (<1.7)", "sphinx-rtd-theme"] +async = ["aiohttp (>=3,<4)"] +develop = ["black", "coverage", "jinja2", "mock", "pytest", "pytest-cov", "pyyaml", "requests (>=2.0.0,<3.0.0)", "sphinx (<1.7)", "sphinx-rtd-theme"] docs = ["sphinx (<1.7)", "sphinx-rtd-theme"] requests = ["requests (>=2.4.0,<3.0.0)"] @@ -1833,7 +1788,7 @@ files = [ [package.dependencies] cffi = {version = ">=1.12.2", markers = "platform_python_implementation == \"CPython\" and sys_platform == \"win32\""} -greenlet = {version = ">=2.0.0", markers = "platform_python_implementation == \"CPython\" and python_version < \"3.11\""} +greenlet = {version = ">=3.0rc3", markers = "platform_python_implementation == \"CPython\" and python_version >= \"3.11\""} "zope.event" = "*" "zope.interface" = "*" @@ -2134,23 +2089,24 @@ reference = "tencent-mirror" [[package]] name = "gunicorn" -version = "20.1.0" +version = "22.0.0" description = "WSGI HTTP Server for UNIX" category = "main" optional = false -python-versions = ">=3.5" +python-versions = ">=3.7" files = [ - {file = "gunicorn-20.1.0-py3-none-any.whl", hash = "sha256:9dcc4547dbb1cb284accfb15ab5667a0e5d1881cc443e0677b4882a4067a807e"}, - {file = "gunicorn-20.1.0.tar.gz", hash = "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"}, + {file = "gunicorn-22.0.0-py3-none-any.whl", hash = "sha256:350679f91b24062c86e386e198a15438d53a7a8207235a78ba1b53df4c4378d9"}, + {file = "gunicorn-22.0.0.tar.gz", hash = "sha256:4a0b436239ff76fb33f11c07a16482c521a7e09c1ce3cc293c2330afe01bec63"}, ] [package.dependencies] -setuptools = ">=3.0" +packaging = "*" [package.extras] -eventlet = ["eventlet (>=0.24.1)"] +eventlet = ["eventlet (>=0.24.1,!=0.36.0)"] gevent = ["gevent (>=1.4.0)"] setproctitle = ["setproctitle"] +testing = ["coverage", "eventlet", "gevent", "pytest", "pytest-cov"] tornado = ["tornado (>=0.2)"] [package.source] @@ -2210,7 +2166,6 @@ files = [ [package.dependencies] click = ">=6" grimp = ">=3.0" -tomli = {version = ">=1.2.1", markers = "python_version < \"3.11\""} typing-extensions = ">=3.10.0.0" [package.source] @@ -2279,14 +2234,14 @@ reference = "tencent-mirror" [[package]] name = "jinja2" -version = "3.1.3" +version = "3.1.4" description = "A very fast and expressive template engine." category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, - {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, + {file = "jinja2-3.1.4-py3-none-any.whl", hash = "sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d"}, + {file = "jinja2-3.1.4.tar.gz", hash = "sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369"}, ] [package.dependencies] @@ -2351,8 +2306,6 @@ files = [ [package.dependencies] amqp = ">=5.1.1,<6.0.0" -"backports.zoneinfo" = {version = ">=0.2.1", extras = ["tzdata"], markers = "python_version < \"3.9\""} -typing-extensions = {version = "*", markers = "python_version < \"3.10\""} vine = "*" [package.extras] @@ -2421,9 +2374,6 @@ files = [ {file = "Markdown-3.6.tar.gz", hash = "sha256:ed4f41f6daecbeeb96e576ce414c41d2d876daa9a16cb35fa8ed8c2ddfad0224"}, ] -[package.dependencies] -importlib-metadata = {version = ">=4.4", markers = "python_version < \"3.10\""} - [package.extras] docs = ["mdx-gh-links (>=0.2)", "mkdocs (>=1.5)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"] testing = ["coverage", "pyyaml"] @@ -2685,7 +2635,6 @@ files = [ [package.dependencies] mypy-extensions = ">=0.4.3" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} typing-extensions = ">=3.10" [package.extras] @@ -4070,14 +4019,14 @@ reference = "tencent-mirror" [[package]] name = "requests" -version = "2.31.0" +version = "2.32.3" description = "Python HTTP for Humans." category = "main" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"}, - {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, + {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, + {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, ] [package.dependencies] @@ -4157,7 +4106,6 @@ files = [ [package.dependencies] markdown-it-py = ">=2.2.0" pygments = ">=2.13.0,<3.0.0" -typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""} [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] @@ -4266,20 +4214,24 @@ reference = "tencent-mirror" [[package]] name = "setuptools" -version = "69.5.1" +version = "75.1.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "setuptools-69.5.1-py3-none-any.whl", hash = "sha256:c636ac361bc47580504644275c9ad802c50415c7522212252c033bd15f301f32"}, - {file = "setuptools-69.5.1.tar.gz", hash = "sha256:6c1fccdac05a97e598fb0ae3bbed5904ccb317337a51139dcd51453611bbb987"}, + {file = "setuptools-75.1.0-py3-none-any.whl", hash = "sha256:35ab7fd3bcd95e6b7fd704e4a1539513edad446c097797f2985e0e4b960772f2"}, + {file = "setuptools-75.1.0.tar.gz", hash = "sha256:d59a21b17a275fb872a9c3dae73963160ae079f1049ed956880cd7c09b120538"}, ] [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6,!=8.1.1)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] -testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)", "ruff (>=0.5.2)"] +core = ["importlib-metadata (>=6)", "importlib-resources (>=5.10.2)", "jaraco.collections", "jaraco.functools", "jaraco.text (>=3.7)", "more-itertools", "more-itertools (>=8.8)", "packaging", "packaging (>=24)", "platformdirs (>=2.6.2)", "tomli (>=2.0.1)", "wheel (>=0.43.0)"] +cover = ["pytest-cov"] +doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "pyproject-hooks (!=1.1)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier", "towncrier (<24.7)"] +enabler = ["pytest-enabler (>=2.2)"] +test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "jaraco.test", "packaging (>=23.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-home (>=0.5)", "pytest-perf", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"] +type = ["importlib-metadata (>=7.0.2)", "jaraco.develop (>=7.21)", "mypy (>=1.11.0,<1.12.0)", "pytest-mypy"] [package.source] type = "legacy" @@ -4390,20 +4342,19 @@ reference = "tencent-mirror" [[package]] name = "sqlparse" -version = "0.4.4" +version = "0.5.1" description = "A non-validating SQL parser." category = "main" optional = false -python-versions = ">=3.5" +python-versions = ">=3.8" files = [ - {file = "sqlparse-0.4.4-py3-none-any.whl", hash = "sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3"}, - {file = "sqlparse-0.4.4.tar.gz", hash = "sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c"}, + {file = "sqlparse-0.5.1-py3-none-any.whl", hash = "sha256:773dcbf9a5ab44a090f3441e2180efe2560220203dc2f8c0b0fa141e18b505e4"}, + {file = "sqlparse-0.5.1.tar.gz", hash = "sha256:bb6b4df465655ef332548e24f08e205afc81b9ab86cb1c45657a7ff173a3a00e"}, ] [package.extras] -dev = ["build", "flake8"] +dev = ["build", "hatch"] doc = ["sphinx"] -test = ["pytest", "pytest-cov"] [package.source] type = "legacy" @@ -4505,23 +4456,6 @@ type = "legacy" url = "https://mirrors.tencent.com/pypi/simple" reference = "tencent-mirror" -[[package]] -name = "tomli" -version = "2.0.1" -description = "A lil' TOML parser" -category = "dev" -optional = false -python-versions = ">=3.7" -files = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, -] - -[package.source] -type = "legacy" -url = "https://mirrors.tencent.com/pypi/simple" -reference = "tencent-mirror" - [[package]] name = "tongsuopy-crayon" version = "1.0.2b6" @@ -4914,14 +4848,14 @@ reference = "tencent-mirror" [[package]] name = "urllib3" -version = "1.26.18" +version = "1.26.20" description = "HTTP library with thread-safe connection pooling, file post, and more." category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" files = [ - {file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07"}, - {file = "urllib3-1.26.18.tar.gz", hash = "sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0"}, + {file = "urllib3-1.26.20-py2.py3-none-any.whl", hash = "sha256:0ed14ccfbf1c30a9072c7ca157e4319b70d65f623e91e7b32fadb2853431016e"}, + {file = "urllib3-1.26.20.tar.gz", hash = "sha256:40c2dc0c681e47eb8f90e7e27bf6ff7df2e677421fd46756da1161c39ca70d32"}, ] [package.extras] @@ -5044,14 +4978,14 @@ reference = "tencent-mirror" [[package]] name = "werkzeug" -version = "3.0.2" +version = "3.0.3" description = "The comprehensive WSGI web application library." category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "werkzeug-3.0.2-py3-none-any.whl", hash = "sha256:3aac3f5da756f93030740bc235d3e09449efcf65f2f55e3602e1d851b8f48795"}, - {file = "werkzeug-3.0.2.tar.gz", hash = "sha256:e39b645a6ac92822588e7b39a692e7828724ceae0b0d702ef96701f90e70128d"}, + {file = "werkzeug-3.0.3-py3-none-any.whl", hash = "sha256:fc9645dc43e03e4d630d23143a04a7f947a9a3b5727cd535fdfe155a17cc48c8"}, + {file = "werkzeug-3.0.3.tar.gz", hash = "sha256:097e5bfda9f0aba8da6b8545146def481d06aa7d3266e7448e2cccf67dd8bd18"}, ] [package.dependencies] @@ -5210,19 +5144,23 @@ reference = "tencent-mirror" [[package]] name = "zipp" -version = "3.18.1" +version = "3.20.2" description = "Backport of pathlib-compatible object wrapper for zip files" category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "zipp-3.18.1-py3-none-any.whl", hash = "sha256:206f5a15f2af3dbaee80769fb7dc6f249695e940acca08dfb2a4769fe61e538b"}, - {file = "zipp-3.18.1.tar.gz", hash = "sha256:2884ed22e7d8961de1c9a05142eb69a247f120291bc0206a00a7642f09b5b715"}, + {file = "zipp-3.20.2-py3-none-any.whl", hash = "sha256:a817ac80d6cf4b23bf7f2828b7cabf326f15a001bea8b1f9b49631780ba28350"}, + {file = "zipp-3.20.2.tar.gz", hash = "sha256:bc9eb26f4506fda01b81bcde0ca78103b6e62f991b381fec825435c836edbc29"}, ] [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] +cover = ["pytest-cov"] +doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +enabler = ["pytest-enabler (>=2.2)"] +test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-ignore-flaky"] +type = ["pytest-mypy"] [package.source] type = "legacy" @@ -5314,5 +5252,5 @@ reference = "tencent-mirror" [metadata] lock-version = "2.0" -python-versions = ">=3.8.1,<3.11" -content-hash = "561999131f2c6e0873924232a90a425f9b0c42a178ea217146cd0a03a9fafad3" +python-versions = ">=3.11,<3.12" +content-hash = "a58e48ca22c120be4413c9e412d5d1afa49af6fff43f55a47c1f5b25db46eb40" diff --git a/apiserver/pyproject.toml b/apiserver/pyproject.toml index a07bec9fae..4b0d379125 100644 --- a/apiserver/pyproject.toml +++ b/apiserver/pyproject.toml @@ -2,21 +2,21 @@ [tool.poetry] authors = ["blueking "] -description = "bluekign PaaS platform" +description = "Tencent Blueking PaaS Platform" name = "apiserver" version = "0.0.1" [tool.poetry.dependencies] -python = ">=3.8.1,<3.11" -aenum = "2.1.2" +python = ">=3.11,<3.12" +aenum = "3.1.15" apscheduler = "3.6.0" arrow = "0.12.1" bk-iam = "1.1.20" bkpaas-auth = "2.1.0" apigw-manager = "3.0.2" -bkstorages = "1.1.0" +bkstorages = "1.1.1" bleach = "3.3.0" -blue-krill = "2.0.3" +blue-krill = "2.0.7" bkapi-component-open = {version = "1.1.0"} boto = "2.49.0" boto3 = "1.33.13" @@ -40,13 +40,13 @@ djangorestframework = "3.15.1" django-prometheus = "2.2.0" "dogpile.cache" = "1.1.6" drf-yasg = "1.21.7" -elasticsearch = "7.5.1" +elasticsearch = "7.17.12" elasticsearch-dsl = "<8.0.0,>=7.0.0" future = "1.0.0" gevent = "24.2.1" -gunicorn = "20.1.0" +gunicorn = "22.0.0" grpcio = "1.55.3" -jinja2 = "3.1.3" +jinja2 = "3.1.4" jsonfield = "3.1.0" markdown = "3.6" msgpack = "1.0.4" @@ -63,16 +63,15 @@ python-logstash = "0.4.6" pyyaml = "6.0.1" packaging = "24.0" redis = "3.5.3" -requests = "2.31.0" +requests = "2.32.3" requests-oauthlib = "1.0.0" sentry-sdk = "0.19.4" sqlalchemy = "1.4.52" -sqlparse = "0.4.4" svn = "0.3.44" typing-extensions = "4.11.0" tzlocal = "2.1" unipath = "1.1" -werkzeug = "3.0.2" +werkzeug = "3.0.3" whitenoise = "5.3.0" wrapt = "1.15.0" xlwt = "1.3.0" @@ -82,7 +81,7 @@ bkapi-bk-apigateway = {version = "1.0.11"} moby-distribution = "0.8.2" pillow = "10.3.0" cattrs = "1.10.0" -attrs = "21.4.0" +attrs = "22.1.0" django-translated-fields = "^0.12.0" dynaconf = "^3.1.8" opentelemetry-api = "1.24.0" @@ -99,7 +98,7 @@ semver = "^2.13.0" protobuf = ">=3.15.0,<4" kubernetes = "24.2.0" bk-notice-sdk = ">=1.2.0" -urllib3 = "1.26.18" +urllib3 = "1.26.20" python-json-logger = "^2.0.7" concurrent-log-handler = "^0.9.25" humanize = "4.9.0" diff --git a/pyproject.toml b/pyproject.toml index 6031122d44..8a27c61a6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,11 +5,10 @@ description = "Tencent Blueking PaaS platform(https://bk.tencent.com/)" authors = ["blueking "] [tool.poetry.dependencies] -python = ">=3.8.1,<3.9" -urllib3 = "1.26.18" +python = ">=3.11,<3.12" [tool.poetry.group.dev.dependencies] -ruff = "^0.5.0" +ruff = "^0.6.9" black = "24.3.0" [tool.ruff]