mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-05 09:30:24 +08:00
简化API节点的数据库配置(db.yaml)
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/configs"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
@@ -14,9 +15,7 @@ import (
|
||||
"github.com/iwind/TeaGo/rands"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -34,12 +33,7 @@ func NewSQLExecutor(dbConfig *dbs.DBConfig) *SQLExecutor {
|
||||
|
||||
func NewSQLExecutorFromCmd() (*SQLExecutor, error) {
|
||||
// 执行SQL
|
||||
var config = &dbs.Config{}
|
||||
configData, err := os.ReadFile(Tea.ConfigFile("db.yaml"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = yaml.Unmarshal(configData, config)
|
||||
config, err := configs.LoadDBConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -321,6 +315,9 @@ func (this *SQLExecutor) checkCluster(db *dbs.DB) error {
|
||||
models.SharedNodeClusterDAO = models.NewNodeClusterDAO()
|
||||
models.SharedNodeClusterDAO.Instance = db
|
||||
|
||||
models.SharedIPListDAO = models.NewIPListDAO()
|
||||
models.SharedIPListDAO.Instance = db
|
||||
|
||||
policyId, err = models.SharedHTTPFirewallPolicyDAO.CreateDefaultFirewallPolicy(nil, "默认集群")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user