Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
fix bug in gui config option which prevented GUI startup
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsaraf committed Nov 5, 2021
1 parent 2750806 commit 0d3f7c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
configs/
trader/configs/
trader/scripts/
terminator/configs/
vendor/
Expand All @@ -12,4 +11,4 @@ logs/
gui/filesystem_vfsdata.go
kelp.prefs
bind_*.go
bundler.json
bundler.json
13 changes: 6 additions & 7 deletions cmd/server_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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" {
Expand Down
7 changes: 7 additions & 0 deletions support/guiconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
}
}

0 comments on commit 0d3f7c5

Please sign in to comment.