11package main
22
33import (
4- "sql-dog/src/domain/model "
5- "sql-dog/src/infrastructure/datastore/mysql"
6- "sql-dog/src/usecase/presenter"
7- "sql-dog/src/usecase/services"
4+ "github.com/tkc/ sql-dog/config "
5+ "github.com/tkc/ sql-dog/src/infrastructure/datastore/mysql"
6+ "github.com/tkc/ sql-dog/src/usecase/presenter"
7+ "github.com/tkc/ sql-dog/src/usecase/services"
88)
99
10- func createValidation () model.Validator {
11- return model.Validator {
12- Ignores : []string {
13- "DELETE FROM Ignores table_name" ,
14- },
15- Nodes : []model.ValidatorNode {
16- {
17- TableName : "table_name" ,
18- Operations : []model.ValidateOperation {
19- {
20- Type : model .OpTypeEq ,
21- Column : "require_column_a" ,
22- },
23- {
24- Type : model .OpTypeEq ,
25- Column : "require_column_b" ,
26- },
27- },
28- StmtTypePattern : []model.StmtType {
29- model .StmtTypeSelect ,
30- model .StmtTypeDelete ,
31- },
32- },
33- },
10+ func main () {
11+ validation , err := config .ReadLintConfig ("./linter.yaml" )
12+ if err != nil {
13+ panic (err )
3414 }
35- }
3615
37- func main () {
38- v := createValidation ()
16+ conf , err := config .ReadConfig ()
17+ if err != nil {
18+ panic (err )
19+ }
3920
4021 handler , _ , _ := mysql .NewMySQLHandler (
41- "root" ,
42- "password" ,
43- "localhost" ,
44- 3306 )
22+ conf .Username ,
23+ conf .Password ,
24+ conf .Host ,
25+ conf .Port ,
26+ conf .RootDatabase )
4527
4628 reportService := services .NewReportService (
4729 mysql .NewGeneralLogRepository (handler ),
@@ -50,5 +32,5 @@ func main() {
5032 presenter .NewReportPresenter (),
5133 )
5234
53- reportService .Show (v )
35+ reportService .Show (* validation )
5436}
0 commit comments