Merge pull request #1836 from simonpasquier/assets-without-gopath

asset: fix when outside of $GOPATH
This commit is contained in:
stuart nelson 2019-04-15 12:40:59 +02:00 committed by GitHub
commit eb09caeea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 12 deletions

View File

@ -16,8 +16,6 @@
package asset
import (
"go/build"
"log"
"net/http"
"os"
"strings"
@ -26,16 +24,8 @@ import (
"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(
http.Dir(importPathToDir("github.com/prometheus/alertmanager/ui/app")),
http.Dir("../ui/app"),
func(path string, fi os.FileInfo) bool {
return path == "/" ||
path == "/script.js" ||
@ -46,7 +36,7 @@ var static http.FileSystem = filter.Keep(
)
var templates http.FileSystem = filter.Keep(
http.Dir(importPathToDir("github.com/prometheus/alertmanager/template")),
http.Dir("../template"),
func(path string, fi os.FileInfo) bool {
return path == "/" || path == "/default.tmpl"
},