-
Notifications
You must be signed in to change notification settings - Fork 197
Issue 329 #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 329 #385
Conversation
sqle/model/instance.go
Outdated
@@ -23,13 +24,20 @@ type Instance struct { | |||
SecretPassword string `json:"secret_password" gorm:"column:db_password; not null"` | |||
Desc string `json:"desc" example:"this is a instance"` | |||
WorkflowTemplateId uint `json:"workflow_template_id"` | |||
AdditionalParams string `json:"additional_params" gorm:"type:text"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用通用的model层params 结构
sqle/driver/driver.go
Outdated
@@ -141,7 +146,7 @@ type handler func(log *logrus.Entry, c *Config) (Driver, error) | |||
// | |||
// Register makes a database driver available by the provided driver name. | |||
// Driver's initialize handler and audit rules register by Register. | |||
func Register(name string, h handler, rs []*Rule) { | |||
func Register(name string, h handler, rs []*Rule, ap []*params.Param) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
考虑兼容性
sqle/api/controller/v1/instance.go
Outdated
additionalParams := driver.AllAdditionalParams()[req.DBType] | ||
for _, param := range additionalParams { | ||
for _, additionalParam := range req.AdditionalParams { | ||
if param.Key == additionalParam.Name { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用SetParamValue 赋值,里面封装了类型验证
sqle/api/controller/v1/instance.go
Outdated
additionalParams := driver.AllAdditionalParams()[req.DBType] | ||
for _, param := range additionalParams { | ||
for _, additionalParam := range req.AdditionalParams { | ||
if param.Key == additionalParam.Name { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用SetParamValue 赋值,里面封装了类型验证
sqle/api/controller/v1/instance.go
Outdated
return c.JSON(http.StatusOK, res) | ||
} | ||
|
||
func ParamsSliceToInstanceAdditionalParamResV1Slice(params []*params.Param) []*InstanceAdditionalParamResV1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convertParamsToInstanceAdditionalParamRes
?
sqle/driver/driver.go
Outdated
Port string | ||
User string | ||
Password string | ||
AdditionalParams []*params.Param |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用 params.Params 保持统一
sqle/pkg/driver/adaptor.go
Outdated
@@ -27,6 +29,8 @@ type Adaptor struct { | |||
ruleToRawHandler map[string] /*rule name*/ rawSQLRuleHandler | |||
ruleToASTHandler map[string] /*rule name*/ astSQLRuleHandler | |||
|
|||
additionalParams []*params.Param |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用 params.Params 保持统一
sqle/pkg/driver/adaptor.go
Outdated
@@ -163,6 +174,10 @@ func (r *registererImpl) Rules() []*driver.Rule { | |||
return r.rules | |||
} | |||
|
|||
func (r *registererImpl) AdditionalParams() []*params.Param { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用 params.Params 保持统一
sqle/driver/proto/util.go
Outdated
"github.com/actiontech/sqle/sqle/pkg/params" | ||
) | ||
|
||
func ParamToProtoParam(p []*params.Param) []*Param { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParamToProtoParam
语法上是什么意思
sqle/api/controller/v1/instance.go
Outdated
@@ -198,14 +237,15 @@ type GetInstanceResV1 struct { | |||
Data InstanceResV1 `json:"data"` | |||
} | |||
|
|||
func convertInstanceToRes(instance *model.Instance) InstanceResV1 { | |||
func convertInstanceToRes(instance *model.Instance, p []*params.Param) InstanceResV1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用 params.Params 保持统一
#329