From 35a534b3ed52cd06663c2043b4ee866ff94133c6 Mon Sep 17 00:00:00 2001 From: Nav Date: Tue, 22 Aug 2023 17:12:16 +0100 Subject: [PATCH] Allow for the omission of the `insight` node in bloom.yaml (as we no longer have any mandatory Insight config params) --- src/Application.cpp | 10 +--------- src/ProjectConfig.hpp | 6 +++++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 5636a1bc..b27e59df 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -311,15 +311,7 @@ void Application::loadProjectConfiguration() { this->environmentConfig = selectedEnvironmentIt->second; #ifndef EXCLUDE_INSIGHT - if (this->environmentConfig->insightConfig.has_value()) { - this->insightConfig = this->environmentConfig->insightConfig.value(); - - } else if (this->projectConfig->insightConfig.has_value()) { - this->insightConfig = this->projectConfig->insightConfig.value(); - - } else { - throw InvalidConfig("Insight configuration missing."); - } + this->insightConfig = this->environmentConfig->insightConfig.value_or(this->projectConfig->insightConfig); #endif if (this->environmentConfig->debugServerConfig.has_value()) { diff --git a/src/ProjectConfig.hpp b/src/ProjectConfig.hpp index 4a7158c3..32f5f4b0 100644 --- a/src/ProjectConfig.hpp +++ b/src/ProjectConfig.hpp @@ -217,8 +217,12 @@ struct ProjectConfig /** * Application level Insight configuration. We use this as a fallback if no Insight config is provided at * the environment level. + * + * We don't use std::optional here because the InsightConfig has no mandatory parameters, so users may wish to + * omit the 'insight' node from their bloom.yaml file, entirely. In this case, Bloom should fall back to a default + * constructed, project-level, InsightConfig instance. */ - std::optional insightConfig; + InsightConfig insightConfig = InsightConfig(); bool debugLoggingEnabled = false;