代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017 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.
"""
import logging
from copy import deepcopy
from pipeline_web.preview_base import PipelineTemplateWebPreviewer
from gcloud.common_template.models import CommonTemplate
from gcloud.tasktmpl3.models import TaskTemplate
from gcloud.constants import PROJECT
logger = logging.getLogger("root")
def preview_template_tree(project_id, template_source, template_id, version, exclude_task_nodes_id):
if template_source == PROJECT:
template = TaskTemplate.objects.get(pk=template_id, is_deleted=False, project_id=project_id)
else:
template = CommonTemplate.objects.get(pk=template_id, is_deleted=False)
pipeline_tree = template.get_pipeline_tree_by_version(version)
template_constants = deepcopy(pipeline_tree["constants"])
PipelineTemplateWebPreviewer.preview_pipeline_tree_exclude_task_nodes(pipeline_tree, exclude_task_nodes_id)
constants_not_referred = {
key: value for key, value in list(template_constants.items()) if key not in pipeline_tree["constants"]
}
return {"pipeline_tree": pipeline_tree, "constants_not_referred": constants_not_referred}
def preview_template_tree_with_schemes(template, version, scheme_id_list):
version = version or template.version
pipeline_tree = template.get_pipeline_tree_by_version(version)
template_constants = deepcopy(pipeline_tree["constants"])
exclude_task_nodes_id = PipelineTemplateWebPreviewer.get_template_exclude_task_nodes_with_schemes(
pipeline_tree, scheme_id_list
)
PipelineTemplateWebPreviewer.preview_pipeline_tree_exclude_task_nodes(pipeline_tree, exclude_task_nodes_id)
constants_not_referred = {}
custom_constants = {}
for key, value in template_constants.items():
if value["show_type"] == "show" and key not in pipeline_tree["constants"]:
if value["source_type"] == "custom":
custom_constants[key] = value
constants_not_referred[key] = value
# 添加outputs返回
template_outputs = template.get_outputs(version)
outputs = {}
for key, value in template_outputs.items():
# 如果输出变量来源于节点勾选,且来源的节点是执行方案删除节点的子集,则不展示该输出变量
if value["source_type"] in ["component_outputs", "component_inputs"] and set(
value["source_info"].keys()
).issubset(set(exclude_task_nodes_id)):
continue
outputs[key] = value
return {
"pipeline_tree": pipeline_tree,
"custom_constants": custom_constants,
"constants_not_referred": constants_not_referred,
"outputs": outputs,
"version": version,
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。