From a597a79e2df3e51ae628a527a0c33888acc23c4f Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 31 Aug 2020 12:49:47 -0500 Subject: [PATCH 1/3] Add embedded UI to default release process --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 93e5407f3..560c0faa0 100644 --- a/Makefile +++ b/Makefile @@ -101,10 +101,15 @@ ifndef SKIP_CHECK_CLEAN endif # Create release build tarballs for all supported platforms. Linux compilation happens under Docker. -release: check-clean +release: check-clean generate-statik $(MAKE) release-build GOOS=darwin GOARCH=amd64 $(MAKE) release-build GOOS=linux GOARCH=amd64 +# Create release build tarballs for all supported platforms. Same as `release`, but without embedded Lattice UI. +release-sans-ui: check-clean + rm -f statik/statik.go + $(MAKE) release-build GOOS=darwin GOARCH=amd64 + $(MAKE) release-build GOOS=linux GOARCH=amd64 # try (e.g.) internal/clustertests/docker-compose-replication2.yml DOCKER_COMPOSE=internal/clustertests/docker-compose.yml From 4ce3879e2cc5805146b52f0789e0cbee84df5cb9 Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 31 Aug 2020 17:41:57 -0500 Subject: [PATCH 2/3] Revert UI->Lattice name change, correct the ordering of error checks in statikHandler --- ctl/server.go | 2 +- http/handler.go | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ctl/server.go b/ctl/server.go index a64b63749..968b2bd6d 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -39,7 +39,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { SetTLSConfig(flags, "", &srv.Config.TLS.CertificatePath, &srv.Config.TLS.CertificateKeyPath, &srv.Config.TLS.CACertPath, &srv.Config.TLS.SkipVerify, &srv.Config.TLS.EnableClientVerification) // Handler - flags.StringSliceVarP(&srv.Config.Handler.AllowedOrigins, "handler.allowed-origins", "", []string{}, "Comma separated list of allowed origin URIs (for CORS/Lattice UI).") + flags.StringSliceVarP(&srv.Config.Handler.AllowedOrigins, "handler.allowed-origins", "", []string{}, "Comma separated list of allowed origin URIs (for CORS/Web UI).") // Cluster flags.BoolVarP(&srv.Config.Cluster.Disabled, "cluster.disabled", "", srv.Config.Cluster.Disabled, "Disabled multi-node cluster communication (used for testing)") diff --git a/http/handler.go b/http/handler.go index c8953984c..2d481d22f 100644 --- a/http/handler.go +++ b/http/handler.go @@ -468,7 +468,7 @@ type statikHandler struct { func NewStatikHandler(h *Handler) statikHandler { fs, err := h.fileSystem.New() if err == nil { - h.logger.Printf("enabled Lattice UI (%s) at %s", h.api.LatticeVersion(), h.api.Node().URI) + h.logger.Printf("enabled Web UI (%s) at %s", h.api.LatticeVersion(), h.api.Node().URI) } return statikHandler{ @@ -478,8 +478,15 @@ func NewStatikHandler(h *Handler) statikHandler { } func (s statikHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if s.statikFS == nil { + msg := "Web UI is not available. Please run `make generate-statik` before building Pilosa with `make install`." + s.handler.logger.Printf(msg) + http.Error(w, msg, http.StatusInternalServerError) + return + } + if strings.HasPrefix(r.UserAgent(), "curl") { - http.Error(w, "Welcome. Pilosa is running. Visit https://www.pilosa.com/docs/ for more information or try the Lattice UI by visiting this URL in your browser.", http.StatusNotFound) + http.Error(w, "Welcome. Pilosa is running. Visit https://www.pilosa.com/docs/ for more information or try the Web UI by visiting this URL in your browser.", http.StatusNotFound) return } @@ -490,12 +497,6 @@ func (s statikHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { r.URL = url } - if s.statikFS == nil { - msg := "Lattice UI is not available. Please run `make generate-statik` before building Pilosa with `make install`." - s.handler.logger.Printf(msg) - http.Error(w, msg, http.StatusInternalServerError) - return - } http.FileServer(s.statikFS).ServeHTTP(w, r) } From 007b3ffc3c37dc9e742ed26703eee3074dee7ec8 Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Tue, 1 Sep 2020 11:32:58 -0500 Subject: [PATCH 3/3] re-re-arrange error checks --- http/handler.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/http/handler.go b/http/handler.go index 2d481d22f..60624e5e8 100644 --- a/http/handler.go +++ b/http/handler.go @@ -478,6 +478,15 @@ func NewStatikHandler(h *Handler) statikHandler { } func (s statikHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if strings.HasPrefix(r.UserAgent(), "curl") { + msg := "Welcome. Pilosa v" + s.handler.api.Version() + " is running. Visit https://www.pilosa.com/docs/ for more information." + if s.statikFS != nil { + msg += " Try the Web UI by visiting this URL in your browser." + } + http.Error(w, msg, http.StatusNotFound) + return + } + if s.statikFS == nil { msg := "Web UI is not available. Please run `make generate-statik` before building Pilosa with `make install`." s.handler.logger.Printf(msg) @@ -485,11 +494,6 @@ func (s statikHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - if strings.HasPrefix(r.UserAgent(), "curl") { - http.Error(w, "Welcome. Pilosa is running. Visit https://www.pilosa.com/docs/ for more information or try the Web UI by visiting this URL in your browser.", http.StatusNotFound) - return - } - // /vds is a front-end route, not a backend route. Without this check, refreshing at /vds // will request a nonexistent resource and return 404. if r.URL.String() == "/vds" {