diff options
author | Sridhar Seshasayee <sseshasa@redhat.com> | 2021-06-30 11:22:50 +0200 |
---|---|---|
committer | Sridhar Seshasayee <sseshasa@redhat.com> | 2021-07-30 14:46:00 +0200 |
commit | 9438e5a4b6b16e7ca3276c94c05ec73541690c10 (patch) | |
tree | 83064aa0daecfae4a8c815cc8e92c6ca812290bc /src/common/config.cc | |
parent | osd: Add method to store config option key/value on the MON store (diff) | |
download | ceph-9438e5a4b6b16e7ca3276c94c05ec73541690c10.tar.xz ceph-9438e5a4b6b16e7ca3276c94c05ec73541690c10.zip |
common/config: Add methods to return the default value of a config option
Add wrapper method "get_val_default()" to the ConfigProxy class that takes
the config option key to search. This method in-turn calls another method
with the same name added to md_config_t class that does the actual work of
searching for the config option. If the option is valid, _get_val_default()
is used to get the default value. Otherwise, the wrapper method returns
std::nullopt.
Fixes: https://tracker.ceph.com/issues/51464
Signed-off-by: Sridhar Seshasayee <sseshasa@redhat.com>
Diffstat (limited to 'src/common/config.cc')
-rw-r--r-- | src/common/config.cc | 10 |
1 files changed, 10 insertions, 0 deletions
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<std::string> 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 { |