109 lines
3.4 KiB
Diff
109 lines
3.4 KiB
Diff
From 2c08b483c84474f81cf7642afd89cbec1181b9da Mon Sep 17 00:00:00 2001
|
||
From: wubijie <wubijie@kylinos.cn>
|
||
Date: Wed, 3 Apr 2024 15:23:18 +0800
|
||
Subject: [PATCH] add extention of grafana
|
||
|
||
---
|
||
conf/config.go | 5 +++--
|
||
config.yaml.templete | 1 +
|
||
go.sum | 4 ----
|
||
main.go | 17 +++++++++++++++--
|
||
4 files changed, 19 insertions(+), 8 deletions(-)
|
||
|
||
diff --git a/conf/config.go b/conf/config.go
|
||
index 3bfcafe..58c1b28 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 d2d1a23..d381962 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 7e93618..f4767d9 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 e149a20..3429dec 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")
|
||
}
|
||
--
|
||
Gitee
|
||
|