Skip to content

Commit

Permalink
fix: comment move rulehandler allowOffline to rule
Browse files Browse the repository at this point in the history
  • Loading branch information
littleniannian committed Dec 25, 2024
1 parent ad33559 commit 1d2c614
Show file tree
Hide file tree
Showing 5 changed files with 922 additions and 923 deletions.
23 changes: 11 additions & 12 deletions sqle/driver/mysql/rule/rule_i18n_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ type SourceParam struct {
}

type SourceRule struct {
Name string
Desc *i18n.Message
Annotation *i18n.Message
Category *i18n.Message
Level driverV2.RuleLevel
Params []*SourceParam
Knowledge driverV2.RuleKnowledge
Name string
Desc *i18n.Message
Annotation *i18n.Message
Category *i18n.Message
Level driverV2.RuleLevel
Params []*SourceParam
Knowledge driverV2.RuleKnowledge
AllowOffline bool
}

type SourceHandler struct {
Rule SourceRule
Message *i18n.Message
Func RuleHandlerFunc
AllowOffline bool
NotAllowOfflineStmts []ast.Node
// 开始事后审核时将会跳过这个值为ture的规则
OnlyAuditNotExecutedSQL bool
Expand All @@ -50,10 +50,9 @@ func generateI18nRuleHandlersFromSource(shs []*SourceHandler) []RuleHandler {
rhs := make([]RuleHandler, len(shs))
for k, v := range shs {
rhs[k] = RuleHandler{
Rule: *ConvertSourceRule(&v.Rule, v.AllowOffline),
Rule: *ConvertSourceRule(&v.Rule),
Message: v.Message,
Func: v.Func,
AllowOffline: v.AllowOffline,
NotAllowOfflineStmts: v.NotAllowOfflineStmts,
OnlyAuditNotExecutedSQL: v.OnlyAuditNotExecutedSQL,
NotSupportExecutedSQLAuditStmts: v.NotSupportExecutedSQLAuditStmts,
Expand All @@ -62,14 +61,14 @@ func generateI18nRuleHandlersFromSource(shs []*SourceHandler) []RuleHandler {
return rhs
}

func ConvertSourceRule(sr *SourceRule, allowOffline bool) *driverV2.Rule {
func ConvertSourceRule(sr *SourceRule) *driverV2.Rule {
r := &driverV2.Rule{
Name: sr.Name,
Level: sr.Level,
Category: sr.Category.ID,
Params: make(params.Params, 0, len(sr.Params)),
I18nRuleInfo: genAllI18nRuleInfo(sr),
AllowOffline: allowOffline,
AllowOffline: sr.AllowOffline,
}
for _, v := range sr.Params {
r.Params = append(r.Params, &params.Param{
Expand Down
Loading

0 comments on commit 1d2c614

Please sign in to comment.