Commit 64c4e2cb authored by qiuqunfeng's avatar qiuqunfeng
Browse files

fix

parent 2e951857
...@@ -10,10 +10,9 @@ import ( ...@@ -10,10 +10,9 @@ import (
"gitlab.com/tensorsecurity-rd/waf-console/internal/utils" "gitlab.com/tensorsecurity-rd/waf-console/internal/utils"
"gitlab.com/tensorsecurity-rd/waf-console/pkg/generated/clientset/versioned" "gitlab.com/tensorsecurity-rd/waf-console/pkg/generated/clientset/versioned"
"gorm.io/gorm" "gorm.io/gorm"
"k8s.io/client-go/rest"
) )
func SetRouters(db *gorm.DB) *gin.Engine { func SetRouters(db *gorm.DB, client *versioned.Clientset) *gin.Engine {
var engine *gin.Engine var engine *gin.Engine
if !config.Conf.Debug { if !config.Conf.Debug {
...@@ -53,16 +52,16 @@ func SetRouters(db *gorm.DB) *gin.Engine { ...@@ -53,16 +52,16 @@ func SetRouters(db *gorm.DB) *gin.Engine {
// SetIPInforRouter(engine) // SetIPInforRouter(engine)
// loadkubeConfig() // loadkubeConfig()
// clientcmd.LoadFromFile("kubeconfig.yaml") // clientcmd.LoadFromFile("kubeconfig.yaml")
client := versioned.NewForConfigOrDie(&rest.Config{ // client := versioned.NewForConfigOrDie(&rest.Config{
Host: "https://127.0.0.1:6443", // Host: "https://127.0.0.1:6443",
TLSClientConfig: rest.TLSClientConfig{ // TLSClientConfig: rest.TLSClientConfig{
Insecure: false, // Insecure: false,
CAData: []byte(""), // CAData: []byte(""),
CertData: []byte(""), // CertData: []byte(""),
KeyData: []byte(""), // KeyData: []byte(""),
}, // },
// BearerToken: "1234567890", // // BearerToken: "1234567890",
}) // })
SetWafRouter(engine, client, db) SetWafRouter(engine, client, db)
// 统一处理 404 // 统一处理 404
......
...@@ -7,10 +7,10 @@ import ( ...@@ -7,10 +7,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitlab.com/security-rd/go-pkg/logging" "gitlab.com/security-rd/go-pkg/logging"
"gitlab.com/tensorsecurity-rd/waf-console/api" "gitlab.com/tensorsecurity-rd/waf-console/api"
"gitlab.com/tensorsecurity-rd/waf-console/pkg/generated/clientset/versioned"
// "gitlab.com/tensorsecurity-rd/waf-console/internal/config"
"gorm.io/driver/mysql" "gorm.io/driver/mysql"
"gorm.io/gorm" "gorm.io/gorm"
"k8s.io/client-go/rest"
) )
func NewRootCommand() *cobra.Command { func NewRootCommand() *cobra.Command {
...@@ -39,7 +39,18 @@ func NewRootCommand() *cobra.Command { ...@@ -39,7 +39,18 @@ func NewRootCommand() *cobra.Command {
panic("dbConfig is nil") panic("dbConfig is nil")
} }
e := api.SetRouters(db) client := versioned.NewForConfigOrDie(&rest.Config{
Host: config.RegionConfigs[0].ApiServer,
TLSClientConfig: rest.TLSClientConfig{
Insecure: false,
CAData: []byte(config.RegionConfigs[0].CAData),
CertData: []byte(config.RegionConfigs[0].ClientCertData),
KeyData: []byte(config.RegionConfigs[0].ClientKeyData),
},
// BearerToken: "1234567890",
})
e := api.SetRouters(db, client)
return e.Run(":8080") return e.Run(":8080")
}, },
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment