Moved environment defaulting to class scope
This commit is contained in:
@@ -83,17 +83,16 @@ void Application::startup() {
|
|||||||
this->blockAllSignalsOnCurrentThread();
|
this->blockAllSignalsOnCurrentThread();
|
||||||
this->signalHandlerThread = std::thread(&SignalHandler::run, std::ref(this->signalHandler));
|
this->signalHandlerThread = std::thread(&SignalHandler::run, std::ref(this->signalHandler));
|
||||||
|
|
||||||
auto environmentName = this->selectedEnvironmentName.value_or("default");
|
Logger::info("Selected environment: " + this->selectedEnvironmentName);
|
||||||
Logger::info("Selected environment: " + environmentName);
|
|
||||||
Logger::debug("Number of environments extracted from config: "
|
Logger::debug("Number of environments extracted from config: "
|
||||||
+ std::to_string(this->applicationConfig.environments.size()));
|
+ std::to_string(this->applicationConfig.environments.size()));
|
||||||
|
|
||||||
// Validate the selected environment
|
// Validate the selected environment
|
||||||
if (!applicationConfig.environments.contains(environmentName)) {
|
if (!applicationConfig.environments.contains(this->selectedEnvironmentName)) {
|
||||||
throw InvalidConfig("Environment (\"" + environmentName + "\") not found in configuration.");
|
throw InvalidConfig("Environment (\"" + this->selectedEnvironmentName + "\") not found in configuration.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this->environmentConfig = applicationConfig.environments.at(environmentName);
|
this->environmentConfig = applicationConfig.environments.at(this->selectedEnvironmentName);
|
||||||
this->insightConfig = this->environmentConfig.insightConfig.value_or(this->applicationConfig.insightConfig);
|
this->insightConfig = this->environmentConfig.insightConfig.value_or(this->applicationConfig.insightConfig);
|
||||||
|
|
||||||
if (this->environmentConfig.debugServerConfig.has_value()) {
|
if (this->environmentConfig.debugServerConfig.has_value()) {
|
||||||
|
|||||||
@@ -89,7 +89,14 @@ namespace Bloom
|
|||||||
EnvironmentConfig environmentConfig;
|
EnvironmentConfig environmentConfig;
|
||||||
DebugServerConfig debugServerConfig;
|
DebugServerConfig debugServerConfig;
|
||||||
InsightConfig insightConfig;
|
InsightConfig insightConfig;
|
||||||
std::optional<std::string> selectedEnvironmentName;
|
|
||||||
|
/**
|
||||||
|
* The project environment selected by the user.
|
||||||
|
*
|
||||||
|
* If an environment name is not provided as an argument when running Bloom, Bloom will fallback to the
|
||||||
|
* environment named "default".
|
||||||
|
*/
|
||||||
|
std::string selectedEnvironmentName = "default";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some CLI arguments are interpreted as commands and thus require specific handler methods to be called.
|
* Some CLI arguments are interpreted as commands and thus require specific handler methods to be called.
|
||||||
|
|||||||
Reference in New Issue
Block a user