File: 0002-Do-not-embed-blobs.patch

package info (click to toggle)
prometheus-pushgateway 1.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,352 kB
  • sloc: javascript: 119; sh: 54; makefile: 40
file content (104 lines) | stat: -rw-r--r-- 4,777 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
From: Martina Ferrari <tina@debian.org>
Date: Tue, 7 Jul 2015 21:22:25 +0000
Subject: Do not embed blobs

Forwarded: not-needed

Instead of embedding blobs, serve directly from the filesystem.
---
 handler/status_test.go  | 6 ++++--
 main.go                 | 8 +++++---
 resources/template.html | 8 ++++----
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/handler/status_test.go b/handler/status_test.go
index 8d3a450..e1a2dda 100644
--- a/handler/status_test.go
+++ b/handler/status_test.go
@@ -17,11 +17,12 @@ import (
 	"io"
 	"net/http"
 	"net/http/httptest"
+	"os"
+	"path/filepath"
 	"strings"
 	"testing"
 	"time"
 
-	"github.com/prometheus/pushgateway/asset"
 	"github.com/prometheus/pushgateway/storage"
 )
 
@@ -34,7 +35,8 @@ func TestPathPrefixPresenceInPage(t *testing.T) {
 	pathPrefix := "/foobar"
 
 	ms := storage.NewDiskMetricStore("", time.Minute, nil, logger)
-	status := Status(ms, asset.Assets, flags, pathPrefix, logger)
+	assets := http.Dir(filepath.Join(os.Getenv("GOPATH"), "..", "resources"))
+	status := Status(ms, assets, flags, pathPrefix, logger)
 	defer ms.Shutdown()
 
 	w := httptest.NewRecorder()
diff --git a/main.go b/main.go
index 7c6bfdb..593c2c3 100644
--- a/main.go
+++ b/main.go
@@ -44,7 +44,6 @@ import (
 	promslogflag "github.com/prometheus/common/promslog/flag"
 	webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag"
 
-	"github.com/prometheus/pushgateway/asset"
 	"github.com/prometheus/pushgateway/handler"
 	"github.com/prometheus/pushgateway/storage"
 
@@ -59,6 +58,7 @@ func main() {
 	var (
 		app                 = kingpin.New(filepath.Base(os.Args[0]), "The Pushgateway").UsageWriter(os.Stdout)
 		webConfig           = webflag.AddFlags(app, ":9091")
+		localAssets         = app.Flag("web.local-assets", "Path to static assets/templates directory.").Default("/usr/share/prometheus/pushgateway").String()
 		metricsPath         = app.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String()
 		externalURL         = app.Flag("web.external-url", "The URL under which the Pushgateway is externally reachable.").Default("").URL()
 		routePrefix         = app.Flag("web.route-prefix", "Prefix for the internal routes of web endpoints. Defaults to the path of --web.external-url.").Default("").String()
@@ -95,6 +95,8 @@ func main() {
 		}
 	}
 
+	var Assets http.FileSystem = http.Dir(*localAssets)
+
 	ms := storage.NewDiskMetricStore(*persistenceFile, *persistenceInterval, prometheus.DefaultGatherer, logger)
 
 	if *pushUTF8Names {
@@ -132,9 +134,9 @@ func main() {
 		r.Post(pushAPIPath+"/job"+suffix+"/:job", handler.Push(ms, false, !*pushUnchecked, jobBase64Encoded, logger))
 		r.Del(pushAPIPath+"/job"+suffix+"/:job", handler.Delete(ms, jobBase64Encoded, logger))
 	}
-	r.Get(*routePrefix+"/static/*filepath", handler.Static(asset.Assets, *routePrefix).ServeHTTP)
+	r.Get(*routePrefix+"/static/*filepath", handler.Static(Assets, *routePrefix).ServeHTTP)
 
-	statusHandler := handler.Status(ms, asset.Assets, flags, externalPathPrefix, logger)
+	statusHandler := handler.Status(ms, Assets, flags, externalPathPrefix, logger)
 	r.Get(*routePrefix+"/status", statusHandler.ServeHTTP)
 	r.Get(*routePrefix+"/", statusHandler.ServeHTTP)
 
diff --git a/resources/template.html b/resources/template.html
index 4dae2e9..0e8f520 100644
--- a/resources/template.html
+++ b/resources/template.html
@@ -21,13 +21,13 @@ limitations under the License.
 	
 	<link rel="shortcut icon" href="{{.PathPrefix}}/static/favicon.ico?v={{.BuildInfo.revision}}">
 	
-	<script src="{{.PathPrefix}}/static/jquery-3.7.1.min.js?v={{.BuildInfo.revision}}"></script>
-	<script src="{{.PathPrefix}}/static/bootstrap-4.3.1-dist/js/bootstrap.min.js?v={{.BuildInfo.revision}}"></script>
+	<script src="{{.PathPrefix}}/static/jquery/jquery.min.js?v={{.BuildInfo.revision}}"></script>
+	<script src="{{.PathPrefix}}/static/bootstrap4/js/bootstrap.min.js?v={{.BuildInfo.revision}}"></script>
 	<script src="{{.PathPrefix}}/static/functions.js?v={{.BuildInfo.revision}}"></script>
 	
-	<link type="text/css" rel="stylesheet" href="{{.PathPrefix}}/static/bootstrap-4.3.1-dist/css/bootstrap.min.css?v={{.BuildInfo.revision}}">
+	<link type="text/css" rel="stylesheet" href="{{.PathPrefix}}/static/bootstrap4/css/bootstrap.min.css?v={{.BuildInfo.revision}}">
 	<link type="text/css" rel="stylesheet" href="{{.PathPrefix}}/static/prometheus.css?v={{.BuildInfo.revision}}">
-	<link type="text/css" rel="stylesheet" href="{{.PathPrefix}}/static/bootstrap4-glyphicons/css/bootstrap-glyphicons.min.css?v={{.BuildInfo.revision}}">
+	<link type="text/css" rel="stylesheet" href="{{.PathPrefix}}/static/bootstrap4-glyphicons/css/bootstrap-glyphicons.css?v={{.BuildInfo.revision}}">
 </head>
 
 <body>