mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-27 05:32:27 -08:00
web/ui: fix asset generation for Go modules installs
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
bf9a1d3d15
commit
d89c01b065
14
web/ui/ui.go
14
web/ui/ui.go
|
@ -16,8 +16,6 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go/build"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -26,16 +24,8 @@ import (
|
||||||
"github.com/shurcooL/httpfs/union"
|
"github.com/shurcooL/httpfs/union"
|
||||||
)
|
)
|
||||||
|
|
||||||
func importPathToDir(importPath string) string {
|
|
||||||
p, err := build.Import(importPath, "", build.FindOnly)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
return p.Dir
|
|
||||||
}
|
|
||||||
|
|
||||||
var static http.FileSystem = filter.Keep(
|
var static http.FileSystem = filter.Keep(
|
||||||
http.Dir(importPathToDir("github.com/prometheus/prometheus/web/ui/static")),
|
http.Dir("./static"),
|
||||||
func(path string, fi os.FileInfo) bool {
|
func(path string, fi os.FileInfo) bool {
|
||||||
return fi.IsDir() ||
|
return fi.IsDir() ||
|
||||||
(!strings.HasSuffix(path, "map.js") &&
|
(!strings.HasSuffix(path, "map.js") &&
|
||||||
|
@ -46,7 +36,7 @@ var static http.FileSystem = filter.Keep(
|
||||||
)
|
)
|
||||||
|
|
||||||
var templates http.FileSystem = filter.Keep(
|
var templates http.FileSystem = filter.Keep(
|
||||||
http.Dir(importPathToDir("github.com/prometheus/prometheus/web/ui/templates")),
|
http.Dir("./templates"),
|
||||||
func(path string, fi os.FileInfo) bool {
|
func(path string, fi os.FileInfo) bool {
|
||||||
return fi.IsDir() || strings.HasSuffix(path, ".html")
|
return fi.IsDir() || strings.HasSuffix(path, ".html")
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue