Skip to content

Commit

Permalink
feat: 容器执行支持灰度 TencentBlueKing#2903
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Apr 19, 2024
1 parent 82ef130 commit 039e5c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,18 @@ private boolean isValidScopeId(String scopeId) {

return true;
}

/**
* 判断是否命中配置的管理空间列表
*
* @param scope 管理空间
*/
protected boolean hitResourceScopeRange(ResourceScope scope) {
ResourceScope checkScope = scope;
if (!scope.getClass().equals(ResourceScope.class)) {
// 需要转换为 ResourceScope 类型,避免后面 contains() 判断因为 class 不同出现预期之外的结果
checkScope = new ResourceScope(scope.getType(), scope.getId());
}
return this.resourceScopes.contains(checkScope);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ResourceScopeBlackListToggleStrategy(Map<String, String> initParams) {
@Override
public boolean evaluate(String featureId, FeatureExecutionContext ctx) {
ResourceScope scope = (ResourceScope) ctx.getParam(ToggleStrategyContextParams.CTX_PARAM_RESOURCE_SCOPE);
return !this.resourceScopes.contains(scope);
return !hitResourceScopeRange(scope);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ResourceScopeWhiteListToggleStrategy(Map<String, String> initParams) {
@Override
public boolean evaluate(String featureId, FeatureExecutionContext ctx) {
ResourceScope scope = (ResourceScope) ctx.getParam(ToggleStrategyContextParams.CTX_PARAM_RESOURCE_SCOPE);
return this.resourceScopes.contains(scope);
return hitResourceScopeRange(scope);
}

@Override
Expand Down

0 comments on commit 039e5c1

Please sign in to comment.