Skip to content
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

Fix/env json #49

Merged
merged 4 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ endif
test: ## run tests with race detactor
go test -race ./...

clean: ## remove the output binary from go build, as well as go install and entire module download cache for safety
go clean -modcache
go clean -i
clean: ## remove the output binary from go build, as well as go install and build cache
go clean -i -r -cache

.PHONY: build build-race build-slim lint test clean

8 changes: 4 additions & 4 deletions framework/bean/bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type Config struct {
On bool
Secret string
}
SQL dbdrivers.SQLConfig
MySQL dbdrivers.SQLConfig
Mongo dbdrivers.MongoConfig
Redis dbdrivers.RedisConfig
Badger dbdrivers.BadgerConfig
Expand Down Expand Up @@ -332,12 +332,12 @@ func (b *Bean) InitDB() {
var tenantRedisDBNames map[uint64]int

if b.Config.Database.Tenant.On {
masterMySQLDB, masterMySQLDBName = dbdrivers.InitMysqlMasterConn(b.Config.Database.SQL)
tenantMySQLDBs, tenantMySQLDBNames = dbdrivers.InitMysqlTenantConns(b.Config.Database.SQL, masterMySQLDB, b.Config.Database.Tenant.Secret)
masterMySQLDB, masterMySQLDBName = dbdrivers.InitMysqlMasterConn(b.Config.Database.MySQL)
tenantMySQLDBs, tenantMySQLDBNames = dbdrivers.InitMysqlTenantConns(b.Config.Database.MySQL, masterMySQLDB, b.Config.Database.Tenant.Secret)
tenantMongoDBs, tenantMongoDBNames = dbdrivers.InitMongoTenantConns(b.Config.Database.Mongo, masterMySQLDB, b.Config.Database.Tenant.Secret)
tenantRedisDBs, tenantRedisDBNames = dbdrivers.InitRedisTenantConns(b.Config.Database.Redis, masterMySQLDB, b.Config.Database.Tenant.Secret)
} else {
masterMySQLDB, masterMySQLDBName = dbdrivers.InitMysqlMasterConn(b.Config.Database.SQL)
masterMySQLDB, masterMySQLDBName = dbdrivers.InitMysqlMasterConn(b.Config.Database.MySQL)
masterMongoDB, masterMongoDBName = dbdrivers.InitMongoMasterConn(b.Config.Database.Mongo)
masterRedisDB, masterRedisDBName = dbdrivers.InitRedisMasterConn(b.Config.Database.Redis)
}
Expand Down
2 changes: 1 addition & 1 deletion framework/dbdrivers/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func InitMysqlMasterConn(config SQLConfig) (*gorm.DB, string) {

masterCfg := config.Master

if masterCfg != nil {
if masterCfg != nil && masterCfg.Database != "" {
return connectMysqlDB(masterCfg.Username, masterCfg.Password, masterCfg.Host, masterCfg.Port, masterCfg.Database,
config.MaxIdleConnections, config.MaxOpenConnections, config.MaxConnectionLifeTime, config.Debug)
}
Expand Down
5 changes: 2 additions & 3 deletions internal/project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ endif
test: ## run tests with race detactor
go test -race ./...

clean: ## remove the output binary from go build, as well as go install and entire module download cache for safety
go clean -modcache
go clean -i
clean: ## remove the output binary from go build, as well as go install and build cache
go clean -i -r -cache

.PHONY: build build-race build-slim lint test clean
6 changes: 3 additions & 3 deletions internal/project/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
},
"mysql": {
"master":{
"database": "naviee_master",
"username": "master",
"password": "secret",
"database": "",
"username": "",
"password": "",
"host": "127.0.0.1",
"port": "3306"
},
Expand Down
2 changes: 1 addition & 1 deletion internal/project/go.mod.tmp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/go-playground/validator/v10 v10.9.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/labstack/echo/v4 v4.6.3
github.com/retail-ai-inc/bean v1.1.0
github.com/retail-ai-inc/bean v1.1.1
github.com/spf13/cobra v1.3.0
github.com/spf13/viper v1.10.0
)
Expand Down