Skip to content

Commit

Permalink
cleanup of old bindata (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
cviecco authored Jun 12, 2024
1 parent 05a3c17 commit d1e1b06
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 336 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ all: install-client
build: prebuild
go build ${EXTRA_BUILD_FLAGS} -ldflags "${CLIENT_LDFLAGS}" -o $(OUTPUT_DIR) ./...

cmd/keymasterd/binData.go:
-go-bindata -fs -o cmd/keymasterd/binData.go -prefix cmd/keymasterd/data cmd/keymasterd/data/...

keymaster.spec:
ifeq ($(OS), Windows_NT)
Expand All @@ -58,7 +56,7 @@ keymaster.spec:
sed 's/{{VERSION}}/$(VERSION)/g' keymaster.spec.tpl > keymaster.spec;
endif

prebuild: keymaster.spec cmd/keymasterd/binData.go
prebuild: keymaster.spec

install-client: prebuild
cd cmd/keymaster; go install ${EXTRA_BUILD_FLAGS} -ldflags "${CLIENT_LDFLAGS}"
Expand Down
17 changes: 16 additions & 1 deletion cmd/keymasterd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
"crypto/tls"
"crypto/x509"
"database/sql"
"embed"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"flag"
"fmt"
htmltemplate "html/template"
"io/fs"
"io/ioutil"
stdlog "log"
"net"
Expand Down Expand Up @@ -281,6 +283,18 @@ var (
eventNotifier *eventnotifier.EventNotifier
)

//go:embed data/*
var compiledData embed.FS

// This function is just to "remove" the /data path of the embeddedFS
func getCompiledDataFS() http.FileSystem {
fsys, err := fs.Sub(compiledData, "data")
if err != nil {
logger.Fatal(err)
}
return http.FS(fsys)
}

func cacheControlHandler(h http.Handler) http.Handler {
maxAgeSeconds := maxCacheLifetime / time.Second
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -1823,7 +1837,8 @@ func main() {
http.StripPrefix("/static/",
http.FileServer(http.Dir(staticFilesPath)))))
serviceMux.Handle("/static/compiled/", cacheControlHandler(
http.StripPrefix("/static/compiled/", http.FileServer(AssetFile()))))
http.StripPrefix("/static/compiled/",
http.FileServer(getCompiledDataFS()))))
customWebResourcesPath :=
filepath.Join(runtimeState.Config.Base.SharedDataDirectory,
"customization_data", "web_resources")
Expand Down
332 changes: 0 additions & 332 deletions cmd/keymasterd/binData.go

This file was deleted.

0 comments on commit d1e1b06

Please sign in to comment.