diff --git a/Add-extention-of-grafana.patch b/Add-extention-of-grafana.patch new file mode 100644 index 0000000000000000000000000000000000000000..876c42e29888087cf8569c0afcd34e417b9e06f0 --- /dev/null +++ b/Add-extention-of-grafana.patch @@ -0,0 +1,108 @@ +From 2c08b483c84474f81cf7642afd89cbec1181b9da Mon Sep 17 00:00:00 2001 +From: wubijie +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 + diff --git a/PilotGo-plugin-grafana.spec b/PilotGo-plugin-grafana.spec index 9bf792fabc79fe2cff1d1b78036d9e84d3d1ded6..2cc3bb963c0f3cb1ba83132f944311ffef4fae3a 100644 --- a/PilotGo-plugin-grafana.spec +++ b/PilotGo-plugin-grafana.spec @@ -1,22 +1,25 @@ %define debug_package %{nil} Name: PilotGo-plugin-grafana -Version: 1.0.1 +Version: 1.1.0 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/%{name}-%{version}.tar.gz +Source0: https://gitee.com/openeuler/PilotGo-plugin-grafana/repository/archive/v%{version}.tar.gz +Patch0: Add-extention-of-grafana.patch + BuildRequires: systemd BuildRequires: golang +Requires: grafana Provides: pilotgo-plugin-grafana = %{version}-%{release} %description PilotGo grafana plugin maintains grafana to provide beautiful visual monitoring interface. - %prep -%autosetup -p1 -n %{name}-%{version} +%setup -n %{name}-v%{version} +%patch 0 -p1 %build GO111MODULE=on go build -mod=vendor -o PilotGo-plugin-grafana main.go @@ -35,18 +38,24 @@ install -D -m 0644 scripts/PilotGo-plugin-grafana.service %{buildroot}%{_unitdir %postun %systemd_postun PilotGo-plugin-grafana.service +if [ $1 -eq 0 ]; then + # Clear all installed files when uninstalling + rm -rf /opt/PilotGo/plugin/grafana +fi %files -%dir /opt/PilotGo -%dir /opt/PilotGo/plugin -%dir /opt/PilotGo/plugin/grafana -%dir /opt/PilotGo/plugin/grafana/log /opt/PilotGo/plugin/grafana/PilotGo-plugin-grafana /opt/PilotGo/plugin/grafana/config.yaml +/opt/PilotGo/plugin/grafana/log %{_unitdir}/PilotGo-plugin-grafana.service - %changelog +* Wed May 15 2024 jianxinyu - 1.1.0-2 +- Solve the problem of missing grafana extension + +* Tue Apr 02 2024 jianxinyu - 1.1.0-1 +- Update package to version 1.1.0 + * Wed Sep 13 2023 wubijie - 1.0.1-2 - Modify the README.md file diff --git a/PilotGo-plugin-grafana-1.0.1.tar.gz b/v1.1.0.tar.gz similarity index 40% rename from PilotGo-plugin-grafana-1.0.1.tar.gz rename to v1.1.0.tar.gz index 4c02c4f70c9098e64a78401980100273f88e52f4..2409ef5ff73bd7f09824b11821f759d81eef3901 100644 Binary files a/PilotGo-plugin-grafana-1.0.1.tar.gz and b/v1.1.0.tar.gz differ