From c5df50c774bef169ade99874bdf422fa3ef58ddd Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sat, 12 Oct 2019 17:41:21 +0300 Subject: [PATCH] Make UI logo URL configurable --- Makefile | 4 +++- cmd/podinfo/main.go | 4 +++- pkg/api/index.go | 2 ++ pkg/api/info.go | 2 ++ pkg/api/server.go | 1 + ui/vue.html | 5 +++-- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 77f0482..21d1e22 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,9 @@ GIT_COMMIT:=$(shell git describe --dirty --always) VERSION:=$(shell grep 'VERSION' pkg/version/version.go | awk '{ print $$4 }' | tr -d '"') run: - GO111MODULE=on go run -ldflags "-s -w -X github.com/stefanprodan/podinfo/pkg/version.REVISION=$(GIT_COMMIT)" cmd/podinfo/* --level=debug --grpc-port=9999 --backend-url=https://httpbin.org/status/401 --backend-url=https://httpbin.org/status/500 + GO111MODULE=on go run -ldflags "-s -w -X github.com/stefanprodan/podinfo/pkg/version.REVISION=$(GIT_COMMIT)" cmd/podinfo/* \ + --level=debug --grpc-port=9999 --backend-url=https://httpbin.org/status/401 --backend-url=https://httpbin.org/status/500 \ + --ui-logo=https://media.giphy.com/media/l0ExbNdlJFGRphMR2/giphy.gif test: GO111MODULE=on go test -v -race ./... diff --git a/cmd/podinfo/main.go b/cmd/podinfo/main.go index 5418558..2f1aeff 100644 --- a/cmd/podinfo/main.go +++ b/cmd/podinfo/main.go @@ -36,7 +36,8 @@ func main() { fs.String("config-path", "", "config dir path") fs.String("config", "config.yaml", "config file name") fs.String("ui-path", "./ui", "UI local path") - fs.String("ui-color", "blue", "UI color") + fs.String("ui-logo", "", "UI logo") + fs.String("ui-color", "cyan", "UI color") fs.String("ui-message", fmt.Sprintf("greetings from podinfo v%v", version.VERSION), "UI message") fs.Bool("random-delay", false, "between 0 and 5 seconds random delay") fs.Bool("random-error", false, "1/3 chances of a random response error") @@ -64,6 +65,7 @@ func main() { viper.RegisterAlias("backendUrl", "backend-url") hostname, _ := os.Hostname() viper.SetDefault("jwt-secret", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9") + viper.SetDefault("ui-logo", "https://d33wubrfki0l68.cloudfront.net/33a12d8be0bc50be4738443101616e968c7afb8f/cba76/images/scalable.png") viper.Set("hostname", hostname) viper.Set("version", version.VERSION) viper.Set("revision", version.REVISION) diff --git a/pkg/api/index.go b/pkg/api/index.go index f7837ce..feb5243 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -23,8 +23,10 @@ func (s *Server) indexHandler(w http.ResponseWriter, r *http.Request) { data := struct { Title string + Logo string }{ Title: s.config.Hostname, + Logo: s.config.UILogo, } if err := tmpl.Execute(w, data); err != nil { diff --git a/pkg/api/info.go b/pkg/api/info.go index 90512cf..d3841f1 100644 --- a/pkg/api/info.go +++ b/pkg/api/info.go @@ -22,6 +22,7 @@ func (s *Server) infoHandler(w http.ResponseWriter, r *http.Request) { Hostname: s.config.Hostname, Version: version.VERSION, Revision: version.REVISION, + Logo: s.config.UILogo, Color: s.config.UIColor, Message: s.config.UIMessage, GOOS: runtime.GOOS, @@ -39,6 +40,7 @@ type RuntimeResponse struct { Version string `json:"version"` Revision string `json:"revision"` Color string `json:"color"` + Logo string `json:"logo"` Message string `json:"message"` GOOS string `json:"goos"` GOARCH string `json:"goarch"` diff --git a/pkg/api/server.go b/pkg/api/server.go index 9f76402..df71f6a 100644 --- a/pkg/api/server.go +++ b/pkg/api/server.go @@ -50,6 +50,7 @@ type Config struct { HttpServerTimeout time.Duration `mapstructure:"http-server-timeout"` HttpServerShutdownTimeout time.Duration `mapstructure:"http-server-shutdown-timeout"` BackendURL []string `mapstructure:"backend-url"` + UILogo string `mapstructure:"ui-logo"` UIMessage string `mapstructure:"ui-message"` UIColor string `mapstructure:"ui-color"` UIPath string `mapstructure:"ui-path"` diff --git a/ui/vue.html b/ui/vue.html index 0a42379..d012e99 100644 --- a/ui/vue.html +++ b/ui/vue.html @@ -26,7 +26,7 @@ justify-center class="white--text" > - kubernetes + kubernetes

${ info.message }

Served by ${ info.hostname }