From 0d3f7c590bec82598149f543ed1c7d858e5b2437 Mon Sep 17 00:00:00 2001 From: Nikhil Saraf <1028334+nikhilsaraf@users.noreply.github.com> Date: Fri, 5 Nov 2021 13:52:01 -0400 Subject: [PATCH] fix bug in gui config option which prevented GUI startup --- .gitignore | 3 +-- cmd/server_amd64.go | 13 ++++++------- .../{sample_GUI_config.cfg => sample_gui.cfg} | 0 support/guiconfig/config.go | 7 +++++++ 4 files changed, 14 insertions(+), 9 deletions(-) rename examples/configs/trader/{sample_GUI_config.cfg => sample_gui.cfg} (100%) diff --git a/.gitignore b/.gitignore index b7a6a3b6c..815631d14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ configs/ -trader/configs/ trader/scripts/ terminator/configs/ vendor/ @@ -12,4 +11,4 @@ logs/ gui/filesystem_vfsdata.go kelp.prefs bind_*.go -bundler.json \ No newline at end of file +bundler.json diff --git a/cmd/server_amd64.go b/cmd/server_amd64.go index 439217d5f..b2f87ce62 100644 --- a/cmd/server_amd64.go +++ b/cmd/server_amd64.go @@ -94,6 +94,10 @@ func (o serverInputOptions) String() string { // function for reading custom config file and returning config struct with intilized value func readGUIConfig(options serverInputOptions) guiconfig.GUIConfig { + if *options.guiConfigPath == "" { + return guiconfig.EmptyGuiConfig() + } + var guiConfigInFunc guiconfig.GUIConfig e := config.Read(*options.guiConfigPath, &guiConfigInFunc) utils.CheckConfigError(guiConfigInFunc, e, *options.guiConfigPath) @@ -103,9 +107,6 @@ func readGUIConfig(options serverInputOptions) guiconfig.GUIConfig { return guiConfigInFunc } -// customConfigVar Variable with its equivalent struct #used to inject config values to jwt config var and to configure route -var auth0ConfigVar guiconfig.GUIConfig - func init() { options := serverInputOptions{} options.port = serverCmd.Flags().Uint16P("port", "p", 8000, "port on which to serve HTTP") @@ -121,9 +122,7 @@ func init() { options.enableKaas = serverCmd.Flags().Bool("enable-kaas", false, "enable kelp-as-a-service (KaaS) mode, which does not bring up browser or electron") options.tlsCertFile = serverCmd.Flags().String("tls-cert-file", "", "path to TLS certificate file") options.tlsKeyFile = serverCmd.Flags().String("tls-key-file", "", "path to TLS key file") - options.guiConfigPath = serverCmd.Flags().StringP("guiconfig", "c", "", "(required) gui-config for auth0 and other basic config file path") - - requiredFlags("guiconfig") + options.guiConfigPath = serverCmd.Flags().StringP("guiconfig", "c", "", "gui-config for auth0 and other basic config file path") serverCmd.Run = func(ccmd *cobra.Command, args []string) { isLocalMode := env == envDev @@ -173,7 +172,7 @@ func init() { log.Printf("initialized server with cli flag inputs: %s", options) //calliing readGUIConfig func and then inject values into JWT_middleware customconfigvar - auth0ConfigVar = readGUIConfig(options) + auth0ConfigVar := readGUIConfig(options) backend.Auth0ConfigVarJWT = auth0ConfigVar if runtime.GOOS == "windows" { diff --git a/examples/configs/trader/sample_GUI_config.cfg b/examples/configs/trader/sample_gui.cfg similarity index 100% rename from examples/configs/trader/sample_GUI_config.cfg rename to examples/configs/trader/sample_gui.cfg diff --git a/support/guiconfig/config.go b/support/guiconfig/config.go index 8f9ef6627..7b4fcc8ec 100644 --- a/support/guiconfig/config.go +++ b/support/guiconfig/config.go @@ -21,4 +21,11 @@ func (g GUIConfig) String() string { "CLIENT_ID": utils.Hide, "DOMAIN": utils.Hide, }) +} + +// EmptyGuiConfig returns an empty GUIConfig for when it is not specified on the command-line +func EmptyGuiConfig() GUIConfig { + return GUIConfig{ + Auth0Config: &Auth0Config{}, + } } \ No newline at end of file