-
Notifications
You must be signed in to change notification settings - Fork 4
/
env.py
136 lines (104 loc) · 5.81 KB
/
env.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making
蓝鲸流程引擎服务 (BlueKing Flow Engine Service) available.
Copyright (C) 2024 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 http://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.
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.
"""
import json
import os
# 部署模块相关变量
# 模块类型,合法值详见 BKFLOWModuleType
BKFLOW_MODULE_TYPE = os.getenv("BKFLOW_MODULE_TYPE")
BKFLOW_MODULE_CODE = os.getenv("BKFLOW_MODULE_CODE")
# 资源隔离级别,合法值详见 BKFLOWResourceIsolationLevel
BKFLOW_RESOURCE_ISOLATION_LEVEL = os.getenv("BKFLOW_RESOURCE_ISOLATION_LEVEL")
BKFLOW_CELERY_BROKER_URL = os.getenv("BKFLOW_CELERY_BROKER_URL", "")
BKFLOW_DATABASE_ENGINE = os.getenv("BKFLOW_DATABASE_ENGINE", "django.db.backends.mysql")
BKFLOW_DATABASE_NAME = os.getenv("BKFLOW_DATABASE_NAME")
BKFLOW_DATABASE_USER = os.getenv("BKFLOW_DATABASE_USER")
BKFLOW_DATABASE_PASSWORD = os.getenv("BKFLOW_DATABASE_PASSWORD", "")
BKFLOW_DATABASE_HOST = os.getenv("BKFLOW_DATABASE_HOST")
BKFLOW_DATABASE_PORT = os.getenv("BKFLOW_DATABASE_PORT")
# CELERY 相关配置
BK_CELERYD_CONCURRENCY = int(os.getenv("BK_CELERYD_CONCURRENCY", 2))
# 是否允许 celery worker 发送监控事件
CELERY_SEND_EVENTS = bool(os.getenv("CELERY_SEND_EVENTS", False))
CELERY_BROKER_POOL_LIMIT = int(os.getenv("CELERY_BROKER_POOL_LIMIT", 10))
# REDIS 相关配置
BKAPP_REDIS_HOST = os.getenv("REDIS_HOST")
BKAPP_REDIS_PORT = os.getenv("REDIS_PORT")
BKAPP_REDIS_PASSWORD = os.getenv("REDIS_PASSWORD")
BKAPP_REDIS_SERVICE_NAME = os.getenv("REDIS_SERVICE_NAME")
BKAPP_REDIS_MODE = os.getenv("REDIS_MODE")
BKAPP_REDIS_DB = os.getenv("REDIS_DB")
BKAPP_REDIS_SENTINEL_PASSWORD = os.getenv("REDIS_SENTINEL_PASSWORD")
# 模块间调用相关配置
APP_INTERNAL_VALIDATION_SKIP = bool(os.getenv("APP_INTERNAL_VALIDATION_SKIP", False))
# 本模块被调用允许通过的 token
APP_INTERNAL_TOKEN = os.getenv("APP_INTERNAL_TOKEN", "")
# 任务模块调用 Interface 模块的 token
INTERFACE_APP_INTERNAL_TOKEN = os.getenv("INTERFACE_APP_INTERNAL_TOKEN", "")
# 任务模块调用 Interface 模块的 url
INTERFACE_APP_URL = os.getenv("INTERFACE_APP_URL", "")
# 变量名关键字黑名单
VARIABLE_KEY_BLACKLIST = os.getenv("BKAPP_VARIABLE_KEY_BLACKLIST", "context,")
# APIGW 访问地址
BK_APIGW_URL_TMPL = os.getenv("BK_API_URL_TMPL") or os.getenv("BK_COMPONENT_API_URL")
BK_APIGW_NAME = os.getenv("BK_APIGW_NAME", "").replace("_", "-")
# 用于校验网关地址是否合法,形如^(?P<api_name>[\w-]+)\.xxx.com
BK_APIGW_NETLOC_PATTERN = os.getenv("BK_APIGW_NETLOC_PATTERN")
BK_ITSM_API_ENTRY = os.getenv("BK_ITSM_API_ENTRY")
# CALLBACK 回调入口,处理走网关回调的场景
BKAPP_INNER_CALLBACK_ENTRY = os.getenv("BKAPP_INNER_CALLBACK_ENTRY", "")
# 默认引擎模块入口
BKAPP_DEFAULT_ENGINE_MODULE_ENTRY = os.getenv("BKAPP_DEFAULT_ENGINE_MODULE_ENTRY", "")
CALLBACK_KEY = os.getenv("BKFLOW_DEFAULT_CALLBACK_KEY", "").encode("utf-8")
BK_PAAS_ESB_HOST = os.getenv("BK_COMPONENT_API_URL", "")
PAASV3_APIGW_API_TOKEN = os.getenv("BKAPP_PAASV3_APIGW_API_TOKEN")
# 启动节点日志数据源拉取
NODE_LOG_DATA_SOURCE = os.getenv("NODE_LOG_DATA_SOURCE", "DATABASE")
NODE_LOG_DATA_SOURCE_CONFIG = json.loads(os.getenv("NODE_LOG_DATA_SOURCE_CONFIG", "{}"))
LOG_PERSISTENT_DAYS = int(os.getenv("LOG_PERSISTENT_DAYS", 7))
ENABLE_OTEL_TRACE = os.getenv("BKAPP_ENABLE_OTEL_TRACE", True if os.getenv("OTEL_BK_DATA_TOKEN") else False)
BKAPP_LOG_SHIELDING_KEYWORDS = os.getenv("BKAPP_LOG_SHIELDING_KEYWORDS", "")
MEMBER_SELECTOR_DATA_HOST = os.getenv("MEMBER_SELECTOR_DATA_HOST", os.getenv("BK_COMPONENT_API_URL", ""))
# 蓝鲸插件授权过滤 APP
PLUGIN_DISTRIBUTOR_NAME = os.getenv("PLUGIN_DISTRIBUTOR_NAME", os.getenv("BKAPP_PLUGIN_DISTRIBUTOR_NAME"))
# 跳过 APIGW 校验
SKIP_APIGW_CHECK = bool(os.getenv("SKIP_APIGW_CHECK", False))
BK_APIGW_REQUIRE_EXEMPT = bool(os.getenv("BK_APIGW_REQUIRE_EXEMPT", False))
# 网关管理员
BK_APIGW_MANAGER_MAINTAINERS = os.getenv("BK_APIGW_MANAGER_MAINTAINERS", "admin").split(",")
BK_APIGW_GRANT_APPS = os.getenv("BK_APIGW_GRANT_APPS").split(",") if os.getenv("BK_APIGW_GRANT_APPS") else []
# APIGW API SERVER服务地址
BKAPP_APIGW_API_HOST = os.getenv("BKAPP_APIGW_API_HOST", "")
# bk notice settings
DISABLE_REGISTER_BKFLOW_TO_BKNOTICE = bool(os.getenv("DISABLE_REGISTER_BKFLOW_TO_BKNOTICE", False))
# ban 掉 admin 权限
BLOCK_ADMIN_PERMISSION = bool(os.getenv("BLOCK_ADMIN_PERMISSION", False))
# BKPAAS 相关环境变量
BKPAAS_ENGINE_REGION = os.getenv("BKPAAS_ENGINE_REGION", "default") # default = open
BKPAAS_DOMAIN = os.getenv("BKPAAS_BK_DOMAIN", "")
# 空间配置
MAX_SPACE_NUM_PER_APP = int(os.getenv("BKAPP_MAX_SPACE_NUM_PER_APP", 100))
BKPAAS_SHARED_RES_URL = os.getenv("BKPAAS_SHARED_RES_URL", "")
BKFLOW_LOGIN_URL = os.getenv("BKAPP_LOGIN_URL", "") or os.getenv("BKPAAS_LOGIN_URL", "")
# 报错联系助手链接
MESSAGE_HELPER_URL = os.getenv("BKAPP_MESSAGE_HELPER_URL", "")
# 获取 PaaS 注入的蓝鲸域名
BKPAAS_BK_DOMAIN = os.getenv("BKPAAS_BK_DOMAIN", "") or os.getenv("BK_DOMAIN", "")
# 文档中心链接
BK_DOC_CENTER_HOST = os.getenv("BK_DOC_CENTER_HOST", os.getenv("BK_DOCS_URL_PREFIX", "")).rstrip("/")
# APP 白名单
APP_WHITE_LIST_STR = os.getenv("BKAPP_APP_WHITE_LIST", "") # 逗号分隔的字符串