File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ FROM gcr.io/distroless/static as test
2525USER 0:0
2626WORKDIR /app
2727COPY --from=build /go/src/github.com/webdevops/azure-resourcegraph-exporter/azure-resourcegraph-exporter .
28- COPY --from=build /go/src/github.com/webdevops/azure-resourcegraph-exporter/templates ./templates
2928RUN ["./azure-resourcegraph-exporter" , "--help" ]
3029
3130# ############################################
Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "embed"
45 "encoding/base64"
56 "errors"
67 "fmt"
3940
4041 metricCache * cache.Cache
4142
43+ //go:embed templates/*.html
44+ templates embed.FS
45+
4246 // Git version information
4347 gitCommit = "<unknown>"
4448 gitTag = "<unknown>"
@@ -152,7 +156,7 @@ func startHttpServer() {
152156 })
153157
154158 // report
155- reportTmpl := template .Must (template .ParseFiles ( "./ templates/query .html" ))
159+ tmpl := template .Must (template .ParseFS ( templates , " templates/* .html" ))
156160 mux .HandleFunc ("/query" , func (w http.ResponseWriter , r * http.Request ) {
157161 cspNonce := base64 .StdEncoding .EncodeToString ([]byte (uuid .New ().String ()))
158162
@@ -174,7 +178,7 @@ func startHttpServer() {
174178 Nonce : cspNonce ,
175179 }
176180
177- if err := reportTmpl . Execute ( w , templatePayload ); err != nil {
181+ if err := tmpl . ExecuteTemplate ( w , "query.html" , templatePayload ); err != nil {
178182 log .Error (err )
179183 }
180184 })
You can’t perform that action at this time.
0 commit comments