!8 Solve the problem of missing grafana extension
From: @jxy_git Reviewed-by: @yangzhao_kl Signed-off-by: @yangzhao_kl
This commit is contained in:
commit
6420124e8a
108
Add-extention-of-grafana.patch
Normal file
108
Add-extention-of-grafana.patch
Normal file
@ -0,0 +1,108 @@
|
||||
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
|
||||
|
||||
@ -2,11 +2,12 @@
|
||||
|
||||
Name: PilotGo-plugin-grafana
|
||||
Version: 1.1.0
|
||||
Release: 1
|
||||
Release: 2
|
||||
Summary: PilotGo grafana plugin maintains grafana to provide beautiful visual monitoring interface.
|
||||
License: MulanPSL-2.0
|
||||
URL: https://gitee.com/openeuler/PilotGo-plugin-grafana
|
||||
Source0: https://gitee.com/openeuler/PilotGo-plugin-grafana/repository/archive/v%{version}.tar.gz
|
||||
Patch0: Add-extention-of-grafana.patch
|
||||
|
||||
BuildRequires: systemd
|
||||
BuildRequires: golang
|
||||
@ -18,6 +19,7 @@ PilotGo grafana plugin maintains grafana to provide beautiful visual monitoring
|
||||
|
||||
%prep
|
||||
%setup -n %{name}-v%{version}
|
||||
%patch 0 -p1
|
||||
|
||||
%build
|
||||
GO111MODULE=on go build -mod=vendor -o PilotGo-plugin-grafana main.go
|
||||
@ -36,8 +38,10 @@ install -D -m 0644 scripts/PilotGo-plugin-grafana.service %{buildroot}%{_unitdir
|
||||
|
||||
%postun
|
||||
%systemd_postun PilotGo-plugin-grafana.service
|
||||
# Clear all installed files when uninstalling
|
||||
rm -rf /opt/PilotGo/plugin/grafana
|
||||
if [ $1 -eq 0 ]; then
|
||||
# Clear all installed files when uninstalling
|
||||
rm -rf /opt/PilotGo/plugin/grafana
|
||||
fi
|
||||
|
||||
%files
|
||||
/opt/PilotGo/plugin/grafana/PilotGo-plugin-grafana
|
||||
@ -46,6 +50,9 @@ rm -rf /opt/PilotGo/plugin/grafana
|
||||
%{_unitdir}/PilotGo-plugin-grafana.service
|
||||
|
||||
%changelog
|
||||
* Wed May 15 2024 jianxinyu <jiangxinyu@kylinos.cn> - 1.1.0-2
|
||||
- Solve the problem of missing grafana extension
|
||||
|
||||
* Tue Apr 02 2024 jianxinyu <jiangxinyu@kylinos.cn> - 1.1.0-1
|
||||
- Update package to version 1.1.0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user