Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 文档中心链接规范调整 #7577 #7578

Merged
11 changes: 9 additions & 2 deletions api/utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
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 django.utils.translation import ugettext_lazy as _
import logging

from django.utils.translation import ugettext_lazy as _

from gcloud.conf import settings
from gcloud.exceptions import ApiRequestError
from gcloud.iam_auth.utils import check_and_raise_raw_auth_fail_exception
from gcloud.utils.handlers import handle_api_error

from .thread import ThreadPool

logger = logging.getLogger("root")
Expand Down Expand Up @@ -126,6 +128,11 @@ def batch_request(
check_and_raise_raw_auth_fail_exception(result, message)
raise ApiRequestError(message)

data.extend(get_data(result))
try:
data.extend(get_data(result))
except Exception as e:
message = handle_api_error("[batch_request get_data]", func.path, params_and_future["params"], result)
logger.exception(f"{e}: {message}")
raise ApiRequestError(message)

return data
2 changes: 1 addition & 1 deletion app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ is_use_celery: True
author: 蓝鲸智云
introduction: 标准运维是通过一套成熟稳定的任务调度引擎,把在多系统间的工作整合到一个流程,助力运维实现跨系统调度自动化的SaaS应用。
introduction_en: SOPS is a SaaS application that utilizes a set of mature and stable task scheduling engines to help realize cross-system scheduling automation, and integrates the work among multiple systems into a single process.
version: 3.33.7
version: 3.33.8
category: 运维工具
language_support: 中文
desktop:
Expand Down
2 changes: 1 addition & 1 deletion app_desc.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spec_version: 2
app_version: "3.33.7"
app_version: "3.33.8"
app:
region: default
bk_app_code: bk_sops
Expand Down
2 changes: 1 addition & 1 deletion config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
# mako模板中:<script src="/a.js?v=${ STATIC_VERSION }"></script>
# 如果静态资源修改了以后,上线前改这个版本号即可

STATIC_VERSION = "3.33.7"
STATIC_VERSION = "3.33.8"
DEPLOY_DATETIME = datetime.datetime.now().strftime("%Y%m%d%H%M%S")

STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
Expand Down
28 changes: 21 additions & 7 deletions env_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,34 @@
os.getenv("BKPAAS_ENVIRONMENT", "prod")
]


def get_app_host(app_code):
app_host_key = "%s_HOST" % app_code.upper()
app_host = os.getenv(app_host_key)
if app_host:
return app_host
if app_code in BK_SAAS_HOSTS:
return BK_SAAS_HOSTS[app_code][BKSAAS_DEFAULT_MODULE_NAME]
return None


BK_CC_HOST = os.getenv("BK_CC_HOST")

BK_JOB_HOST = os.getenv("BK_JOB_HOST")

BK_NODEMAN_HOST = os.getenv("BK_NODEMAN_HOST", BK_SAAS_HOSTS["bk_nodeman"][BKSAAS_DEFAULT_MODULE_NAME])
BK_NODEMAN_HOST = get_app_host("bk_nodeman")

BK_SOPS_HOST = os.getenv("BK_SOPS_HOST", BK_SAAS_HOSTS["bk_sops"][BKSAAS_DEFAULT_MODULE_NAME])
BK_SOPS_HOST = get_app_host("bk_sops")

# 兼容没有部署 GSEKIT 的情况
BK_GSE_KIT_PAGE_URL_TEMPLATE = os.getenv(
"BK_GSEKIT_PAGE_URL_TEMPLATE",
str(BK_SAAS_HOSTS["bk_gsekit"][BKSAAS_DEFAULT_MODULE_NAME]).rstrip("/")
BK_SAAS_HOSTS.get("bk_gsekit", {}).get(BKSAAS_DEFAULT_MODULE_NAME, "").rstrip("/")
+ "/task-history/detail/{job_id}?biz={bk_biz_id}",
)

# 用户管理配置
BK_USER_MANAGE_HOST = os.getenv("BK_USER_MANAGE_HOST", BK_SAAS_HOSTS["bk_user_manage"][BKSAAS_DEFAULT_MODULE_NAME])
BK_USER_MANAGE_HOST = get_app_host("bk_user_manage")

# 文档中心
BK_DOC_CENTER_HOST = os.getenv("BK_DOC_CENTER_HOST", os.getenv("BK_DOCS_URL_PREFIX"))
Expand Down Expand Up @@ -147,15 +158,18 @@

# CALLBACK 回调地址
BKAPP_INNER_CALLBACK_HOST = os.getenv(
"BKAPP_INNER_CALLBACK_HOST", BK_SAAS_HOSTS[APP_CODE][SOPS_CALLBACK_MODULE_NAME] or BK_PAAS_INNER_HOST + SITE_URL
"BKAPP_INNER_CALLBACK_HOST",
BK_SAAS_HOSTS[APP_CODE][SOPS_CALLBACK_MODULE_NAME] if BK_SAAS_HOSTS else BK_PAAS_INNER_HOST + SITE_URL,
)
# APIGW CALLBACK SERVER服务地址
BKAPP_APIGW_CALLBACK_HOST = os.getenv(
"BKAPP_APIGW_CALLBACK_HOST", BK_SAAS_HOSTS[APP_CODE][SOPS_CALLBACK_MODULE_NAME] or BK_PAAS_INNER_HOST + SITE_URL
"BKAPP_APIGW_CALLBACK_HOST",
BK_SAAS_HOSTS[APP_CODE][SOPS_CALLBACK_MODULE_NAME] if BK_SAAS_HOSTS else BK_PAAS_INNER_HOST + SITE_URL,
)
# API SERVER服务地址
BKAPP_APIGW_API_HOST = os.getenv(
"BKAPP_APIGW_API_HOST", BK_SAAS_HOSTS[APP_CODE][SOPS_API_SERVER_MODULE_NAME] or BK_PAAS_INNER_HOST + SITE_URL
"BKAPP_APIGW_API_HOST",
BK_SAAS_HOSTS[APP_CODE][SOPS_API_SERVER_MODULE_NAME] if BK_SAAS_HOSTS else BK_PAAS_INNER_HOST + SITE_URL,
)

BKAPP_FILE_UPLOAD_ENTRY = os.getenv("BKAPP_FILE_UPLOAD_ENTRY", "")
Expand Down
2 changes: 1 addition & 1 deletion gcloud/conf/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

APP_HOST = env.BK_SOPS_HOST
ESB_GET_ALL_USER = "{}/api/c/compapi/v2/usermanage/fe_list_users/".format(settings.BK_PAAS_ESB_HOST)
BK_DOC_URL = "{}/markdown/SOPS/UserGuide/Overview/README.md".format(env.BK_DOC_CENTER_HOST)
BK_DOC_URL = f"{env.BK_DOC_CENTER_HOST}/markdown/{{}}/SOPS/3.33/UserGuide/Overview/README.md"
FEEDBACK_URL = "https://bk.tencent.com/s-mart/community"
APP_MAKER_UPLOAD_LOGO_USER_UIN = "bk_token"
APP_MAKER_UPLOAD_LOGO_USER_KEY = "bk_token_null"
Expand Down
3 changes: 2 additions & 1 deletion gcloud/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def get_cur_pos_from_url(request):
def mysetting(request):
# 嵌入CICD,隐藏头部
language = request.COOKIES.get("blueking_language", "zh-cn")
doc_lang_mappings = {"zh-cn": "ZH", "en": "EN"}
run_ver_key = "BKAPP_RUN_VER_NAME" if language == "zh-cn" else "BKAPP_RUN_VER_NAME_{}".format(language.upper())
file_manager_type = "BKAPP_FILE_MANAGER_TYPE"
hide_header = int(request.GET.get("hide_header", "0") == "1")
Expand Down Expand Up @@ -117,7 +118,7 @@ def mysetting(request):
"FILE_UPLOAD_ENTRY": env.BKAPP_FILE_UPLOAD_ENTRY,
"MEMBER_SELECTOR_DATA_HOST": settings.BK_MEMBER_SELECTOR_DATA_HOST,
"BK_STATIC_URL": frontend_entry_url,
"BK_DOC_URL": settings.BK_DOC_URL,
"BK_DOC_URL": settings.BK_DOC_URL.format(doc_lang_mappings.get(language, "ZH")),
"FEEDBACK_URL": settings.FEEDBACK_URL,
"FILE_MANAGER_TYPE": EnvironmentVariables.objects.get_var(file_manager_type, env.BKAPP_FILE_MANAGER_TYPE),
"MAX_NODE_EXECUTE_TIMEOUT": settings.MAX_NODE_EXECUTE_TIMEOUT,
Expand Down
10 changes: 5 additions & 5 deletions gcloud/template_base/apis/drf/viewsets/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
import logging

from drf_yasg.utils import swagger_auto_schema
from rest_framework import viewsets, permissions
from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.exceptions import APIException
from rest_framework.response import Response

from gcloud.common_template.models import CommonTemplate
from gcloud.core.apis.drf.viewsets import ApiMixin
from gcloud.tasktmpl3.models import TaskTemplate
from gcloud.template_base.apis.drf.permission import ProjectTemplatePermission, CommonTemplatePermission
from gcloud.template_base.apis.drf.serilaziers.template import TemplateIdsSerializer, BatchDeleteSerialzer
from gcloud.template_base.apis.drf.permission import CommonTemplatePermission, ProjectTemplatePermission
from gcloud.template_base.apis.drf.serilaziers.template import BatchDeleteSerialzer, TemplateIdsSerializer
from gcloud.template_base.domains.template_manager import TemplateManager

logger = logging.getLogger("root")
Expand All @@ -49,13 +49,13 @@ def batch_delete(self, request, *args, **kwargs):

class ProjectTemplateViewSet(TemplateViewSet):
queryset = TaskTemplate.objects.all()
permission_classes = [permissions.IsAuthenticated | ProjectTemplatePermission]
permission_classes = [ProjectTemplatePermission]
template_type = "project"
tmpl_model = TaskTemplate


class CommonTemplateViewSet(TemplateViewSet):
queryset = CommonTemplate.objects.all()
permission_classes = [permissions.IsAuthenticated | CommonTemplatePermission]
permission_classes = [CommonTemplatePermission]
template_type = "common"
tmpl_model = CommonTemplate
Loading