Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup of old bindata #238

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"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 @@
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)

Check warning on line 293 in cmd/keymasterd/app.go

View check run for this annotation

Codecov / codecov/patch

cmd/keymasterd/app.go#L290-L293

Added lines #L290 - L293 were not covered by tests
}
return http.FS(fsys)

Check warning on line 295 in cmd/keymasterd/app.go

View check run for this annotation

Codecov / codecov/patch

cmd/keymasterd/app.go#L295

Added line #L295 was not covered by tests
}

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 @@
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()))))

Check warning on line 1841 in cmd/keymasterd/app.go

View check run for this annotation

Codecov / codecov/patch

cmd/keymasterd/app.go#L1840-L1841

Added lines #L1840 - L1841 were not covered by tests
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.

Loading