From 2f325ee9f470a029ab5e8d352d98e3843be7e0bf Mon Sep 17 00:00:00 2001 From: luowei Date: Tue, 14 Nov 2023 15:35:41 +0800 Subject: [PATCH 1/3] change method to get default rule knowledge --- sqle/driver/mysql/rule/rule.go | 8 ++++++-- sqle/driver/mysql/rule/rule_ce.go | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sqle/driver/mysql/rule/rule.go b/sqle/driver/mysql/rule/rule.go index e67b687204..8a4f733fb4 100644 --- a/sqle/driver/mysql/rule/rule.go +++ b/sqle/driver/mysql/rule/rule.go @@ -231,9 +231,13 @@ type RuleHandler struct { } func init() { + defaultRulesKnowledge, err := getDefaultRulesKnowledge() + if err != nil { + panic(fmt.Errorf("get default rules knowledge failed: %v", err)) + } for i, rh := range RuleHandlers { - if knowledge, ok := defaultRuleKnowledgeMap[rh.Rule.Name]; ok { - rh.Rule.Knowledge = knowledge + if knowledge, ok := defaultRulesKnowledge[rh.Rule.Name]; ok { + rh.Rule.Knowledge = driverV2.RuleKnowledge{Content: knowledge} RuleHandlers[i] = rh } RuleHandlerMap[rh.Rule.Name] = rh diff --git a/sqle/driver/mysql/rule/rule_ce.go b/sqle/driver/mysql/rule/rule_ce.go index d5bf99b40e..f2f98e8249 100644 --- a/sqle/driver/mysql/rule/rule_ce.go +++ b/sqle/driver/mysql/rule/rule_ce.go @@ -3,6 +3,6 @@ package rule -import driverV2 "github.com/actiontech/sqle/sqle/driver/v2" - -var defaultRuleKnowledgeMap = map[string]driverV2.RuleKnowledge{} +func getDefaultRulesKnowledge() (map[string]string, error) { + return nil, nil +} From 9836b5ba45c334dc5d09e2ec5e9d272a93131ffd Mon Sep 17 00:00:00 2001 From: luowei Date: Tue, 14 Nov 2023 17:35:07 +0800 Subject: [PATCH 2/3] get rule knowledge from plugin --- sqle/driver/v2/util.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sqle/driver/v2/util.go b/sqle/driver/v2/util.go index 0bfef80200..77aa881ba5 100644 --- a/sqle/driver/v2/util.go +++ b/sqle/driver/v2/util.go @@ -118,6 +118,9 @@ func ConvertRuleFromDriverToProto(rule *Rule) *protoV2.Rule { Level: string(rule.Level), Category: rule.Category, Params: params, + Knowledge: &protoV2.Knowledge{ + Content: rule.Knowledge.Content, + }, } } From 98bc9940a5b53ca2e6ad243550d32d7ae7411201 Mon Sep 17 00:00:00 2001 From: luowei Date: Thu, 16 Nov 2023 14:58:45 +0800 Subject: [PATCH 3/3] do not prevent files in dir which has _ee suffix --- .github/workflows/check-pr-files.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-pr-files.yml b/.github/workflows/check-pr-files.yml index f8c8b584e7..6eeca7c410 100644 --- a/.github/workflows/check-pr-files.yml +++ b/.github/workflows/check-pr-files.yml @@ -12,5 +12,5 @@ jobs: name: Prevent file change with: githubToken: ${{ secrets.GITHUB_TOKEN }} - pattern: ^(?!.*_ee\.go$)(?!.*_ee_test\.go$)(?!.*_rel\.go$)(?!.*_rel_test\.go$)(?!go\.mod$)(?!go\.sum$)(?!\.github\/workflows\/check-pr-files\.yml$)(?!vendor\/.*)(?!.*_qa\.go$).* + pattern: ^(?!.*_ee\/.*$)(?!.*_ee\.go$)(?!.*_ee_test\.go$)(?!.*_rel\.go$)(?!.*_rel_test\.go$)(?!go\.mod$)(?!go\.sum$)(?!\.github\/workflows\/check-pr-files\.yml$)(?!vendor\/.*)(?!.*_qa\.go$).* trustedAuthors: xalvarez \ No newline at end of file