diff --git a/.gitignore b/.gitignore index 65092b264..4c67d0d19 100644 --- a/.gitignore +++ b/.gitignore @@ -91,7 +91,6 @@ celerybeat-schedule # Environments .env .venv -env/ venv/ ENV/ @@ -177,3 +176,5 @@ tests/postman/bkman # Thumbnails ._* + +.helm diff --git a/config/default.py b/config/default.py index 888fae8ef..ed8dc74e4 100644 --- a/config/default.py +++ b/config/default.py @@ -15,9 +15,9 @@ from blueapps.conf.default_settings import * # noqa from blueapps.conf.log import get_logging_config_dict +import env from apps.utils.enum import EnhanceEnum from apps.utils.env import get_type_env -from config import env # pipeline 配置 from pipeline.celery.settings import CELERY_QUEUES as PIPELINE_CELERY_QUEUES diff --git a/env/__init__.py b/env/__init__.py new file mode 100644 index 000000000..6c302cee7 --- /dev/null +++ b/env/__init__.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +""" +TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-节点管理(BlueKing-BK-NODEMAN) available. +Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at https://opensource.org/licenses/MIT +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. +""" + +from .paas_version_diff import * # noqa diff --git a/config/env/__init__.py b/env/constants.py similarity index 69% rename from config/env/__init__.py rename to env/constants.py index 3cdea35ea..8b0d76ed1 100644 --- a/config/env/__init__.py +++ b/env/constants.py @@ -9,11 +9,11 @@ specific language governing permissions and limitations under the License. """ + from enum import Enum from typing import Dict from apps.utils.enum import EnhanceEnum -from apps.utils.env import get_type_env class BkPaaSVersion(EnhanceEnum): @@ -23,16 +23,3 @@ class BkPaaSVersion(EnhanceEnum): @classmethod def _get_member__alias_map(cls) -> Dict[Enum, str]: return {cls.V2: "V2", cls.V3: "V3具备容器及二进制配置差异"} - - -BKPAAS_MAJOR_VERSION = get_type_env(key="BKPAAS_MAJOR_VERSION", default=BkPaaSVersion.V2.value, _type=int) -BKAPP_IS_V3_CONTAINER = get_type_env(key="BKAPP_IS_V3_CONTAINER", default=False, _type=bool) - - -if BKPAAS_MAJOR_VERSION == BkPaaSVersion.V3.value: - if BKAPP_IS_V3_CONTAINER: - from .env_v3_container import * # noqa - else: - from .env_v3 import * # noqa -else: - from .env_v2 import * # noqa diff --git a/env/paas_version_diff/__init__.py b/env/paas_version_diff/__init__.py new file mode 100644 index 000000000..3cc844d77 --- /dev/null +++ b/env/paas_version_diff/__init__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +""" +TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-节点管理(BlueKing-BK-NODEMAN) available. +Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at https://opensource.org/licenses/MIT +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. +""" +from apps.utils.env import get_type_env + +from .. import constants + +__all__ = [ + "ENVIRONMENT", + "BK_BACKEND_CONFIG", + "BKAPP_IS_PAAS_DEPLOY", + "BK_COMPONENT_API_URL", + "BK_NODEMAN_HOST", + "BK_NODEMAN_BACKEND_HOST", + "BK_IAM_APP_CODE", + "BK_IAM_SAAS_HOST", + "BK_IAM_RESOURCE_API_HOST", +] + + +BKPAAS_MAJOR_VERSION = get_type_env(key="BKPAAS_MAJOR_VERSION", default=constants.BkPaaSVersion.V2.value, _type=int) +BKAPP_IS_V3_CONTAINER = get_type_env(key="BKAPP_IS_V3_CONTAINER", default=False, _type=bool) + + +if BKPAAS_MAJOR_VERSION == constants.BkPaaSVersion.V3.value: + if BKAPP_IS_V3_CONTAINER: + from env.paas_version_diff.paas_v3_container import * # noqa + else: + from env.paas_version_diff.paas_v3 import * # noqa +else: + from env.paas_version_diff.paas_v2 import * # noqa diff --git a/config/env/env_v2.py b/env/paas_version_diff/paas_v2.py similarity index 100% rename from config/env/env_v2.py rename to env/paas_version_diff/paas_v2.py diff --git a/config/env/env_v3.py b/env/paas_version_diff/paas_v3.py similarity index 96% rename from config/env/env_v3.py rename to env/paas_version_diff/paas_v3.py index 5ec2038fd..85b5cf63c 100644 --- a/config/env/env_v3.py +++ b/env/paas_version_diff/paas_v3.py @@ -9,7 +9,7 @@ specific language governing permissions and limitations under the License. """ -from .env_v2 import * # noqa +from .paas_v2 import * # noqa # PaaS 二进制版本 v2 v3 主要的差异配置 ENVIRONMENT = get_type_env(key="BKPAAS_ENVIRONMENT", default="dev", _type=str) diff --git a/config/env/env_v3_container.py b/env/paas_version_diff/paas_v3_container.py similarity index 100% rename from config/env/env_v3_container.py rename to env/paas_version_diff/paas_v3_container.py diff --git a/pack.sh b/pack.sh index 1f363f98f..563a1b25d 100755 --- a/pack.sh +++ b/pack.sh @@ -49,6 +49,7 @@ cp -R bk_nodeman/script_tools ${NODEMAN_DIST_DIR} cp -R bk_nodeman/config ${NODEMAN_DIST_DIR} cp -R bk_nodeman/iam ${NODEMAN_DIST_DIR} cp -R bk_nodeman/upgrade ${NODEMAN_DIST_DIR} +cp -R bk_nodeman/env ${NODEMAN_DIST_DIR} cp bk_nodeman/manage.py ${NODEMAN_DIST_DIR} cp bk_nodeman/settings.py ${NODEMAN_DIST_DIR}