浏览代码

tech(renderer): improve renderOpts names

bergquist 9 年之前
父节点
当前提交
1a32ab64b6
共有 3 个文件被更改,包括 6 次插入6 次删除
  1. 1 1
      pkg/api/render.go
  2. 4 4
      pkg/components/renderer/renderer.go
  3. 1 1
      pkg/services/alerting/notifier.go

+ 1 - 1
pkg/api/render.go

@@ -14,7 +14,7 @@ func RenderToPng(c *middleware.Context) {
 	queryParams := fmt.Sprintf("?%s", c.Req.URL.RawQuery)
 
 	renderOpts := &renderer.RenderOpts{
-		Url:     c.Params("*") + queryParams,
+		Path:    c.Params("*") + queryParams,
 		Width:   queryReader.Get("width", "800"),
 		Height:  queryReader.Get("height", "400"),
 		OrgId:   c.OrgId,

+ 4 - 4
pkg/components/renderer/renderer.go

@@ -18,7 +18,7 @@ import (
 )
 
 type RenderOpts struct {
-	Url     string
+	Path    string
 	Width   string
 	Height  string
 	Timeout string
@@ -28,14 +28,14 @@ type RenderOpts struct {
 var rendererLog log.Logger = log.New("png-renderer")
 
 func RenderToPng(params *RenderOpts) (string, error) {
-	rendererLog.Info("Rendering", "url", params.Url)
+	rendererLog.Info("Rendering", "path", params.Path)
 
 	var executable = "phantomjs"
 	if runtime.GOOS == "windows" {
 		executable = executable + ".exe"
 	}
 
-	params.Url = fmt.Sprintf("%s://localhost:%s/%s", setting.Protocol, setting.HttpPort, params.Url)
+	url := fmt.Sprintf("%s://localhost:%s/%s", setting.Protocol, setting.HttpPort, params.Path)
 
 	binPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, executable))
 	scriptPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, "render.js"))
@@ -48,7 +48,7 @@ func RenderToPng(params *RenderOpts) (string, error) {
 	cmdArgs := []string{
 		"--ignore-ssl-errors=true",
 		scriptPath,
-		"url=" + params.Url,
+		"url=" + url,
 		"width=" + params.Width,
 		"height=" + params.Height,
 		"png=" + pngPath,

+ 1 - 1
pkg/services/alerting/notifier.go

@@ -74,7 +74,7 @@ func (n *RootNotifier) uploadImage(context *EvalContext) (err error) {
 	if slug, err := context.GetDashboardSlug(); err != nil {
 		return err
 	} else {
-		renderOpts.Url = fmt.Sprintf("dashboard-solo/db/%s?&panelId=%d", slug, context.Rule.PanelId)
+		renderOpts.Path = fmt.Sprintf("dashboard-solo/db/%s?&panelId=%d", slug, context.Rule.PanelId)
 	}
 
 	if imagePath, err := renderer.RenderToPng(renderOpts); err != nil {