Skip to content

Commit

Permalink
refactor: last bits of env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jun 8, 2024
1 parent d3fe8b6 commit 0c5248b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"SCRAPPY_BASE_URL": "**********", // Not required for dev env if u use "DEVENV_MOCK_API": "true"
// "DARK_TEST_REGENERATE": "false",
"DEV_ENV": "true",
"DEV_ENV_MOCK_API": "true",
"DARKBOT_LOG_LEVEL": "INFO",
"CONFIGURATOR_DBNAME": "dev",
"DEVENV_MOCK_API": "true",
"DISCORDER_BOT_TOKEN": "**********", // Get your own app token at https://discord.com/developers/applications
},
"go.testTimeout": "30000s",
Expand All @@ -19,9 +19,9 @@
"SCRAPPY_BASE_URL": "**********", // Not required for dev env if u use "DEVENV_MOCK_API": "true"
// "DARK_TEST_REGENERATE": "false",
"DEV_ENV": "true",
"DEV_ENV_MOCK_API": "true",
"DARKBOT_LOG_LEVEL": "INFO",
"CONFIGURATOR_DBNAME": "dev",
"DEVENV_MOCK_API": "true",
"DISCORDER_BOT_TOKEN": "**********", // Get your own app token at https://discord.com/developers/applications
}
}
19 changes: 14 additions & 5 deletions app/settings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,32 @@ func init() {
envs := utils_env.NewEnvConfig()
Env = DarkbotEnv{
UtilsEnvs: utils_settings.Envs,
ScrappyBaseUrl: envs.GetEnvWithDefault("SCRAPPY_BASE_URL", "undefined"),
ScrappyPlayerUrl: envs.GetEnvWithDefault("SCRAPPY_PLAYER_URL", "undefined"),
DevEnvMockApi: envs.GetEnvBoolWithDefault("DEV_ENV_MOCK_API", true),
ScrappyBaseUrl: envs.GetEnvWithDefault("SCRAPPY_BASE_URL", ""),
ScrappyPlayerUrl: envs.GetEnvWithDefault("SCRAPPY_PLAYER_URL", ""),
ScrappyBaseAttackUrl: envs.GetEnvWithDefault("SCRAPPY_BASE_ATTACK_URL", "https://discoverygc.com/forums/showthread.php?tid=110046&action=lastpost"),

DiscorderBotToken: envs.GetEnvWithDefault("DISCORDER_BOT_TOKEN", "undefined"),
DiscorderBotToken: envs.GetEnvWithDefault("DISCORDER_BOT_TOKEN", ""),

ConfiguratorDbname: envs.GetEnvWithDefault("CONFIGURATOR_DBNAME", "dev"),

ConsolerPrefix: envs.GetEnvWithDefault("CONSOLER_PREFIX", ";"),
ProfilingEnabled: envs.GetEnvBool("PROFILING"),
ProfilingEnabled: envs.GetEnvBoolWithDefault("PROFILING", false),

ScrappyLoopDelay: envs.GetIntWithDefault("SCRAPPY_LOOP_DELAY", 10),
ViewerLoopDelay: envs.GetIntWithDefault("VIEWER_LOOP_DELAY", 10),
DevEnvMockApi: envs.GetEnvBoolWithDefault("DEVENV_MOCK_API", true),
}
Workdir = filepath.Dir(filepath.Dir(utils.GetCurrentFolder().ToString()))
Dbpath = NewDBPath(Env.ConfiguratorDbname)

if !Env.DevEnvMockApi {
if Env.ScrappyBaseUrl == "" {
logus.Log.Panic("DEVENV_MOCK_API=false, Expected SCRAPPY_BASE_URL env var to be defined")
}
if Env.ScrappyPlayerUrl == "" {
logus.Log.Panic("DEVENV_MOCK_API=false, Expected SCRAPPY_PLAYER_URL env var to be defined")
}
}
}

var Dbpath types.Dbpath
Expand Down
13 changes: 0 additions & 13 deletions app/viewer/viewer_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
package viewer

import (
"testing"

"github.com/darklab8/fl-darkbot/app/settings"
)

func TestDebugPerformance(t *testing.T) {
if !settings.Env.IsDevEnv {
return
}

}

0 comments on commit 0c5248b

Please sign in to comment.