diff --git a/src/common/config.cc b/src/common/config.cc index a58d9d9e1f2..c8101587b71 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -1024,6 +1024,16 @@ void md_config_t::get_config_bl( } } +std::optional md_config_t::get_val_default(std::string_view key) +{ + std::string val; + const Option *opt = find_option(key); + if (opt && (conf_stringify(_get_val_default(*opt), &val) == 0)) { + return std::make_optional(std::move(val)); + } + return std::nullopt; +} + int md_config_t::get_val(const ConfigValues& values, const std::string_view key, char **buf, int len) const { diff --git a/src/common/config.h b/src/common/config.h index ce5f9277796..bafac663127 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -192,6 +192,9 @@ public: /// get encoded map of compiled-in defaults void get_defaults_bl(const ConfigValues& values, ceph::buffer::list *bl); + /// Get the default value of a configuration option + std::optional get_val_default(std::string_view key); + // Get a configuration value. // No metavariables will be returned (they will have already been expanded) int get_val(const ConfigValues& values, const std::string_view key, char **buf, int len) const; diff --git a/src/common/config_proxy.h b/src/common/config_proxy.h index cb30a2d7f1f..e43a7c6dd67 100644 --- a/src/common/config_proxy.h +++ b/src/common/config_proxy.h @@ -344,6 +344,9 @@ public: const std::string& get_conf_path() const { return config.get_conf_path(); } + std::optional get_val_default(std::string_view key) { + return config.get_val_default(key); + } }; }