diff --git a/conf/config.go b/conf/config.go index 3bfcafec57cc3deebd2905c1163ff41278cc5c52..58c1b28abeb3993093402256c749710f9dde1f83 100644 --- a/conf/config.go +++ b/conf/config.go @@ -9,11 +9,12 @@ import ( ) type HttpConfig struct { - Addr string `json:"addr"` + Addr string `yaml:"addr"` } type GrafanaConfig struct { - Addr string `yaml:"addr"` + Addr string `yaml:"addr"` + PluginType string `yaml:"plugin_type"` } type ServerConfig struct { diff --git a/config.yaml.templete b/config.yaml.templete index d2d1a238c9fec58eb47cbd03ca61389acc06bc75..d3819623f24c73fc414b8aaa1dbc7bb205d94e9d 100644 --- a/config.yaml.templete +++ b/config.yaml.templete @@ -2,6 +2,7 @@ http_server: addr: "localhost:9999" grafana_server: addr: "localhost:3000" + plugin_type: "iframe" log: level: debug driver: file # 可选stdout和file。stdout:输出到终端控制台;file:输出到path下的指定文件。 diff --git a/go.sum b/go.sum index 7e93618b4aa29ac26e1cd2d2230654fff1ba36d4..f4767d9ea9c2e56eacd02e4f0c139cdad6096b7e 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,3 @@ -gitee.com/openeuler/PilotGo/sdk v0.0.0-20231208073829-a1e2ae2fa48f h1:SSV11E2fBoKPdJH2SmCMtFLKjnW126lGtEknljmfBpo= -gitee.com/openeuler/PilotGo/sdk v0.0.0-20231208073829-a1e2ae2fa48f/go.mod h1:zEVmY3l48/CvR2kIM3DJpD/jWTG1qkOxRoHJii/D0us= -gitee.com/openeuler/PilotGo/sdk v0.0.0-20231229071059-61698c219eb3 h1:J3frP8uNIwxjTzbaP00tNmJVtQGtcwL0K6HRjZaxvQM= -gitee.com/openeuler/PilotGo/sdk v0.0.0-20231229071059-61698c219eb3/go.mod h1:zEVmY3l48/CvR2kIM3DJpD/jWTG1qkOxRoHJii/D0us= gitee.com/openeuler/PilotGo/sdk v0.0.0-20240328030306-4b66a7291c6e h1:lSwHbmV75XrNcxQw5EzXNTE/EFthLVfXlC0GDYV/tdM= gitee.com/openeuler/PilotGo/sdk v0.0.0-20240328030306-4b66a7291c6e/go.mod h1:zEVmY3l48/CvR2kIM3DJpD/jWTG1qkOxRoHJii/D0us= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= diff --git a/main.go b/main.go index e149a204a2110e97409a4b9b52e49b40ed242e8a..3429dec66cd1e8322aff601f3fb7b78f1857aaea 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "os" "strings" + "gitee.com/openeuler/PilotGo/sdk/common" "gitee.com/openeuler/PilotGo/sdk/logger" "gitee.com/openeuler/PilotGo/sdk/plugin/client" "github.com/gin-gonic/gin" @@ -22,7 +23,7 @@ var PluginInfo = &client.PluginInfo{ Author: "guozhengxin", Email: "guozhengxin@kylinos.cn", Url: "", - PluginType: "iframe", + PluginType: "", ReverseDest: "", } @@ -31,8 +32,9 @@ func main() { InitLogger() - PluginInfo.Url = "http://" + conf.Config().Http.Addr + "/plugin/grafana" + PluginInfo.Url = "http://" + conf.Config().Http.Addr PluginInfo.ReverseDest = "http://" + conf.Config().Grafana.Addr + PluginInfo.PluginType = conf.Config().Grafana.PluginType server := gin.Default() @@ -40,6 +42,17 @@ func main() { client.RegisterHandlers(server) InitRouter(server) + // 添加扩展点 + var ex []common.Extention + me1 := &common.MachineExtention{ + Type: common.ExtentionPage, + Name: "plugin-grafana", + URL: "/plugin/grafana", + Permission: "plugin.grafana.page/menu", + } + ex = append(ex, me1) + client.RegisterExtention(ex) + if err := server.Run(conf.Config().Http.Addr); err != nil { logger.Fatal("failed to run server") }