File tree 3 files changed +269
-114
lines changed
3 files changed +269
-114
lines changed Original file line number Diff line number Diff line change 1
- MODULE_NAME := $(shell go list -m)
1
+ MODULE_NAME := scrape
2
+ ifneq ($(shell command -v go >/dev/null 2>&1 && echo yes) ,)
3
+ MODULE_NAME := $(shell go list -m)
4
+ endif
2
5
DOCKER_IMAGE_NAME := ${shell basename ${MODULE_NAME}}-bookworm-slim
3
6
CWD := $(shell pwd)
4
7
BUILD_DIR := build
Original file line number Diff line number Diff line change @@ -107,9 +107,10 @@ var home embed.FS
107
107
108
108
func (h scrapeServer ) mustHomeTemplate () * template.Template {
109
109
tmpl := template .New ("home" )
110
- var keyF = func () string { return "" }
111
- if len (h .SigningKey ) > 0 {
112
- keyF = func () string {
110
+ var authTokenF = func () string { return "" }
111
+ var authEnabledF = func () bool { return len (h .SigningKey ) > 0 }
112
+ if authEnabledF () {
113
+ authTokenF = func () string {
113
114
c , err := auth .NewClaims (
114
115
auth .WithSubject ("home" ),
115
116
auth .ExpiresIn (60 * time .Minute ),
@@ -126,7 +127,11 @@ func (h scrapeServer) mustHomeTemplate() *template.Template {
126
127
return s
127
128
}
128
129
}
129
- tmpl = tmpl .Funcs (template.FuncMap {"AuthToken" : keyF })
130
+ funcMap := template.FuncMap {
131
+ "AuthToken" : authTokenF ,
132
+ "AuthEnabled" : authEnabledF ,
133
+ }
134
+ tmpl = tmpl .Funcs (funcMap )
130
135
homeSource , _ := home .ReadFile ("templates/index.html" )
131
136
tmpl = template .Must (tmpl .Parse (string (homeSource )))
132
137
return tmpl
You can’t perform that action at this time.
0 commit comments