forked from TencentBlueKing/bamboo-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: 网关支持自定义表达式和策略 (TencentBlueKing#161)
* feature: 网关支持自定义表达式和策略 * test: 修复单元测试 * test: 单元测试修复 * test: 新增分支命中策略的单元测试 * minor: get_config 方法签名修改 * minor: 并行网关和分支网关配置合并 * minor: 配置项统一添加前缀 * test: fix单元测试 * minor: 补充config的校验逻辑
- Loading branch information
1 parent
48957b4
commit ae818d0
Showing
14 changed files
with
348 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
default_stages: [ commit ] | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.1.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- repo: https://github.com/psf/black | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
language_version: python3 | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.6.4 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black", "--filter-files"] | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 5.0.4 | ||
hooks: | ||
- id: flake8 | ||
language_version: python3 | ||
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook | ||
rev: v2.2.0 | ||
hooks: | ||
- id: commitlint | ||
stages: [ commit-msg ] | ||
additional_dependencies: [ '@commitlint/config-conventional' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
from bamboo_engine.utils.boolrule import BoolRule | ||
|
||
|
||
def default_expr_func(expr: str, context: dict) -> bool: | ||
return BoolRule(expr).test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const Configuration = { | ||
/* | ||
* Resolve and load @commitlint/config-conventional from node_modules. | ||
* Referenced packages must be installed | ||
*/ | ||
extends: [ | ||
'@commitlint/config-conventional' | ||
], | ||
/* | ||
* Resolve and load conventional-changelog-atom from node_modules. | ||
* Referenced packages must be installed | ||
*/ | ||
formatter: '@commitlint/format', | ||
/* | ||
* Any rules defined here will override rules from @commitlint/config-conventional | ||
*/ | ||
rules: { | ||
'type-enum': [ | ||
2, | ||
'always', | ||
[ | ||
'feature', | ||
'bugfix', | ||
'minor', | ||
'optimization', | ||
'sprintfix', | ||
'refactor', | ||
'test', | ||
'docs', | ||
'merge', | ||
], | ||
] | ||
}, | ||
/* | ||
* Functions that return true if commitlint should ignore the given message. | ||
*/ | ||
ignores: [ | ||
(commit) => commit === '', | ||
(message) => message.includes('Merge'), | ||
(message) => message.includes('merge') | ||
], | ||
/* | ||
* Whether commitlint uses the default ignore rules. | ||
*/ | ||
defaultIgnores: true, | ||
/* | ||
* Custom URL to show upon failure | ||
*/ | ||
helpUrl: | ||
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint', | ||
/* | ||
* Custom prompt configs | ||
*/ | ||
prompt: { | ||
messages: {}, | ||
questions: { | ||
type: { | ||
description: 'please input type:', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = Configuration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.conf import settings | ||
|
||
from bamboo_engine.config import Settings | ||
from bamboo_engine.utils.constants import RUNTIME_ALLOWED_CONFIG | ||
|
||
|
||
class ConfigMixin: | ||
def get_config(self, name): | ||
if name not in RUNTIME_ALLOWED_CONFIG: | ||
raise ValueError("unsupported pipeline config, name={}".format(name)) | ||
|
||
custom_config_value = getattr(settings, name, None) | ||
if custom_config_value: | ||
return custom_config_value | ||
return getattr(Settings, name) |
Oops, something went wrong.