mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
[FIX] bug: reflect.Value.Set using unaddressable value
This commit is contained in:
parent
a2cb4cce94
commit
6c2fc4eb2b
@ -48,7 +48,7 @@ type TenantDao interface {
|
||||
GetTenantByUUIDIsExist(uuid string) bool
|
||||
}
|
||||
|
||||
//TenantDao tenant dao
|
||||
//AppDao tenant dao
|
||||
type AppDao interface {
|
||||
Dao
|
||||
GetByEventId(eventID string) (*model.AppStatus, error)
|
||||
@ -351,16 +351,16 @@ type RuleExtensionDao interface {
|
||||
DeleteRuleExtensionByRuleID(ruleID string) error
|
||||
}
|
||||
|
||||
// HttpRuleDao -
|
||||
type HttpRuleDao interface {
|
||||
// HTTPRuleDao -
|
||||
type HTTPRuleDao interface {
|
||||
Dao
|
||||
GetHttpRuleByID(id string) (*model.HTTPRule, error)
|
||||
GetHttpRuleByServiceIDAndContainerPort(serviceID string, containerPort int) ([]*model.HTTPRule, error)
|
||||
DeleteHttpRuleByID(id string) error
|
||||
}
|
||||
|
||||
// TcpRuleDao -
|
||||
type TcpRuleDao interface {
|
||||
// TCPRuleDao -
|
||||
type TCPRuleDao interface {
|
||||
Dao
|
||||
GetTcpRuleByServiceIDAndContainerPort(serviceID string, containerPort int) ([]*model.TCPRule, error)
|
||||
GetTcpRuleByID(id string) (*model.TCPRule, error)
|
||||
|
@ -2911,7 +2911,7 @@ func (_mr *_MockRuleExtensionDaoRecorder) DeleteRuleExtensionByRuleID(arg0 inter
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "DeleteRuleExtensionByRuleID", arg0)
|
||||
}
|
||||
|
||||
// Mock of HttpRuleDao interface
|
||||
// Mock of HTTPRuleDao interface
|
||||
type MockHttpRuleDao struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *_MockHttpRuleDaoRecorder
|
||||
@ -2995,7 +2995,7 @@ func (_mr *_MockHttpRuleDaoRecorder) DeleteHttpRuleByID(arg0 interface{}) *gomoc
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "DeleteHttpRuleByID", arg0)
|
||||
}
|
||||
|
||||
// Mock of TcpRuleDao interface
|
||||
// Mock of TCPRuleDao interface
|
||||
type MockTcpRuleDao struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *_MockTcpRuleDaoRecorder
|
||||
|
8
db/db.go
8
db/db.go
@ -98,10 +98,10 @@ type Manager interface {
|
||||
CertificateDaoTransactions(db *gorm.DB) dao.CertificateDao
|
||||
RuleExtensionDao() dao.RuleExtensionDao
|
||||
RuleExtensionDaoTransactions(db *gorm.DB) dao.RuleExtensionDao
|
||||
HttpRuleDao() dao.HttpRuleDao
|
||||
HttpRuleDaoTransactions(db *gorm.DB) dao.HttpRuleDao
|
||||
TcpRuleDao() dao.TcpRuleDao
|
||||
TcpRuleDaoTransactions(db *gorm.DB) dao.TcpRuleDao
|
||||
HttpRuleDao() dao.HTTPRuleDao
|
||||
HttpRuleDaoTransactions(db *gorm.DB) dao.HTTPRuleDao
|
||||
TcpRuleDao() dao.TCPRuleDao
|
||||
TcpRuleDaoTransactions(db *gorm.DB) dao.TCPRuleDao
|
||||
}
|
||||
|
||||
var defaultManager Manager
|
||||
|
@ -610,19 +610,19 @@ func (_mr *_MockManagerRecorder) RuleExtensionDaoTransactions(arg0 interface{})
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "RuleExtensionDaoTransactions", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockManager) HttpRuleDao() dao.HttpRuleDao {
|
||||
ret := _m.ctrl.Call(_m, "HttpRuleDao")
|
||||
ret0, _ := ret[0].(dao.HttpRuleDao)
|
||||
func (_m *MockManager) HttpRuleDao() dao.HTTPRuleDao {
|
||||
ret := _m.ctrl.Call(_m, "HTTPRuleDao")
|
||||
ret0, _ := ret[0].(dao.HTTPRuleDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
func (_mr *_MockManagerRecorder) HttpRuleDao() *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "HttpRuleDao")
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "HTTPRuleDao")
|
||||
}
|
||||
|
||||
func (_m *MockManager) HttpRuleDaoTransactions(db *gorm.DB) dao.HttpRuleDao {
|
||||
func (_m *MockManager) HttpRuleDaoTransactions(db *gorm.DB) dao.HTTPRuleDao {
|
||||
ret := _m.ctrl.Call(_m, "HttpRuleDaoTransactions", db)
|
||||
ret0, _ := ret[0].(dao.HttpRuleDao)
|
||||
ret0, _ := ret[0].(dao.HTTPRuleDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
@ -630,19 +630,19 @@ func (_mr *_MockManagerRecorder) HttpRuleDaoTransactions(arg0 interface{}) *gomo
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "HttpRuleDaoTransactions", arg0)
|
||||
}
|
||||
|
||||
func (_m *MockManager) TcpRuleDao() dao.TcpRuleDao {
|
||||
ret := _m.ctrl.Call(_m, "TcpRuleDao")
|
||||
ret0, _ := ret[0].(dao.TcpRuleDao)
|
||||
func (_m *MockManager) TcpRuleDao() dao.TCPRuleDao {
|
||||
ret := _m.ctrl.Call(_m, "TCPRuleDao")
|
||||
ret0, _ := ret[0].(dao.TCPRuleDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
func (_mr *_MockManagerRecorder) TcpRuleDao() *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TcpRuleDao")
|
||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "TCPRuleDao")
|
||||
}
|
||||
|
||||
func (_m *MockManager) TcpRuleDaoTransactions(db *gorm.DB) dao.TcpRuleDao {
|
||||
func (_m *MockManager) TcpRuleDaoTransactions(db *gorm.DB) dao.TCPRuleDao {
|
||||
ret := _m.ctrl.Call(_m, "TcpRuleDaoTransactions", db)
|
||||
ret0, _ := ret[0].(dao.TcpRuleDao)
|
||||
ret0, _ := ret[0].(dao.TCPRuleDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
|
@ -196,32 +196,62 @@ func TestCockroachDBDeleteService(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCockroachDBSaveDeployInfo(t *testing.T) {
|
||||
//func TestCockroachDBSaveDeployInfo(t *testing.T) {
|
||||
// if err := CreateManager(dbconfig.Config{
|
||||
// MysqlConnectionInfo: "postgresql://root@localhost:5432/region?sslmode=disable",
|
||||
// DBType: "cockroachdb",
|
||||
// }); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// err := GetManager().K8sDeployReplicationDao().AddModel(&model.K8sDeployReplication{
|
||||
// TenantID: "asdasd",
|
||||
// ServiceID: "asdasdasdasd",
|
||||
// ReplicationID: "asdasdadsasdasdasd",
|
||||
// ReplicationType: model.TypeReplicationController,
|
||||
// })
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//}
|
||||
|
||||
//func TestCockroachDBDeleteDeployInfo(t *testing.T) {
|
||||
// if err := CreateManager(dbconfig.Config{
|
||||
// MysqlConnectionInfo: "postgresql://root@localhost:5432/region?sslmode=disable",
|
||||
// DBType: "cockroachdb",
|
||||
// }); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
//err := GetManager().K8sDeployReplicationDao().DeleteK8sDeployReplication("asdasdadsasdasdasd")
|
||||
//if err != nil {
|
||||
// t.Fatal(err)
|
||||
//}
|
||||
//}
|
||||
|
||||
func TestGetHttpRuleByServiceIDAndContainerPort(t *testing.T) {
|
||||
if err := CreateManager(dbconfig.Config{
|
||||
MysqlConnectionInfo: "postgresql://root@localhost:5432/region?sslmode=disable",
|
||||
DBType: "cockroachdb",
|
||||
MysqlConnectionInfo: "admin:admin@tcp(127.0.0.1:3306)/region",
|
||||
DBType: "mysql",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err := GetManager().K8sDeployReplicationDao().AddModel(&model.K8sDeployReplication{
|
||||
TenantID: "asdasd",
|
||||
ServiceID: "asdasdasdasd",
|
||||
ReplicationID: "asdasdadsasdasdasd",
|
||||
ReplicationType: model.TypeReplicationController,
|
||||
})
|
||||
|
||||
_, err := GetManager().HttpRuleDao().GetHttpRuleByServiceIDAndContainerPort(
|
||||
"43eaae441859eda35b02075d37d83581", 10001)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCockroachDBDeleteDeployInfo(t *testing.T) {
|
||||
func TestGetTcpRuleByServiceIDAndContainerPort(t *testing.T) {
|
||||
if err := CreateManager(dbconfig.Config{
|
||||
MysqlConnectionInfo: "postgresql://root@localhost:5432/region?sslmode=disable",
|
||||
DBType: "cockroachdb",
|
||||
MysqlConnectionInfo: "admin:admin@tcp(127.0.0.1:3306)/region",
|
||||
DBType: "mysql",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err := GetManager().K8sDeployReplicationDao().DeleteK8sDeployReplication("asdasdadsasdasdasd")
|
||||
|
||||
_, err := GetManager().TcpRuleDao().GetTcpRuleByServiceIDAndContainerPort(
|
||||
"43eaae441859eda35b02075d37d83581", 10001)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ func (h *HttpRuleDaoImpl) GetHttpRuleByServiceIDAndContainerPort(serviceID strin
|
||||
containerPort int) ([]*model.HTTPRule, error) {
|
||||
var httpRule []*model.HTTPRule
|
||||
if err := h.DB.Where("service_id = ? and container_port = ?", serviceID,
|
||||
containerPort).Find(httpRule).Error; err != nil {
|
||||
containerPort).Find(&httpRule).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return httpRule, nil
|
||||
}
|
||||
@ -221,7 +221,7 @@ func (s *TcpRuleDaoTmpl) GetTcpRuleByServiceIDAndContainerPort(serviceID string,
|
||||
containerPort int) ([]*model.TCPRule, error) {
|
||||
var result []*model.TCPRule
|
||||
if err := s.DB.Where("service_id = ? and container_port = ?", serviceID,
|
||||
containerPort).Find(result).Error; err != nil {
|
||||
containerPort).Find(&result).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return result, nil
|
||||
}
|
||||
|
@ -413,25 +413,25 @@ func (m *Manager) RuleExtensionDaoTransactions(db *gorm.DB) dao.RuleExtensionDao
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) HttpRuleDao() dao.HttpRuleDao {
|
||||
func (m *Manager) HttpRuleDao() dao.HTTPRuleDao {
|
||||
return &mysqldao.HttpRuleDaoImpl{
|
||||
DB: m.db,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) HttpRuleDaoTransactions(db *gorm.DB) dao.HttpRuleDao {
|
||||
func (m *Manager) HttpRuleDaoTransactions(db *gorm.DB) dao.HTTPRuleDao {
|
||||
return &mysqldao.HttpRuleDaoImpl{
|
||||
DB: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) TcpRuleDao() dao.TcpRuleDao {
|
||||
func (m *Manager) TcpRuleDao() dao.TCPRuleDao {
|
||||
return &mysqldao.TcpRuleDaoTmpl{
|
||||
DB: m.db,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) TcpRuleDaoTransactions(db *gorm.DB) dao.TcpRuleDao {
|
||||
func (m *Manager) TcpRuleDaoTransactions(db *gorm.DB) dao.TCPRuleDao {
|
||||
return &mysqldao.TcpRuleDaoTmpl{
|
||||
DB: db,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user