Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feat_doc_url_hb
Browse files Browse the repository at this point in the history
# Conflicts:
#	app.yml
#	app_desc.yaml
#	config/default.py
#	env_v3.py
#	requirements.txt
  • Loading branch information
normal-wls committed Oct 8, 2024
2 parents af5de72 + 8bf1b75 commit 1838bb9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
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
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
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

0 comments on commit 1838bb9

Please sign in to comment.