Skip to content

Commit

Permalink
SQL上线自动审批支持按照实例标签过滤
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Nov 2, 2019
1 parent 4a09cb1 commit c31ef13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions common/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ <h5 style="color: darkgrey"><b>SQL上线</b></h5>
</div>
</div>
<div id="div-auto-review-config" style="display: none">
<div class="form-group">
<label for="auto_review_tag"
class="col-sm-4 control-label">AUTO_REVIEW_TAG</label>
<div class="col-sm-5">
<input type="text" class="form-control"
id="auto_review_tag"
key="auto_review_tag"
value="{{ config.auto_review_tag }}"
placeholder="自动审批的实例标签CODE,多个使用逗号分隔">
</div>
</div>
<div class="form-group">
<label for="auto_review_regex"
class="col-sm-4 control-label">AUTO_REVIEW_REGEX</label>
Expand Down
5 changes: 4 additions & 1 deletion sql/utils/sql_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ def is_auto_review(workflow_id):
:param workflow_id:
:return:
"""

workflow = SqlWorkflow.objects.get(id=workflow_id)
auto_review_tags = SysConfig().get('auto_review_tag', '').split(',')
# TODO 这里也可以放到engine中实现,但是配置项可能会相对复杂
if workflow.instance.db_type == 'mysql':
if workflow.instance.db_type == 'mysql' and workflow.instance.instancetag_set.filter(
tag_code__in=auto_review_tags).exists():
# 获取正则表达式
auto_review_regex = SysConfig().get('auto_review_regex',
'^alter|^create|^drop|^truncate|^rename|^delete')
Expand Down

0 comments on commit c31ef13

Please sign in to comment.