diff options
author | Sage Weil <sage@newdream.net> | 2021-02-16 23:06:16 +0100 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2021-02-17 18:27:58 +0100 |
commit | ceace016cd02824709bd0da1c13c6c1e56f690f5 (patch) | |
tree | 80cd082369c348fc41fc710a974457525bbc4a30 /src/mon/ConfigMap.cc | |
parent | mon/ConfigMap: fix stray option leak (diff) | |
download | ceph-ceace016cd02824709bd0da1c13c6c1e56f690f5.tar.xz ceph-ceace016cd02824709bd0da1c13c6c1e56f690f5.zip |
mon/ConfigMap: factor out parse_key helper
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'src/mon/ConfigMap.cc')
-rw-r--r-- | src/mon/ConfigMap.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mon/ConfigMap.cc b/src/mon/ConfigMap.cc index 7fb13841df4..763b8ce9b17 100644 --- a/src/mon/ConfigMap.cc +++ b/src/mon/ConfigMap.cc @@ -233,6 +233,23 @@ bool ConfigMap::parse_mask( return true; } +void ConfigMap::parse_key( + const std::string& key, + std::string *name, + std::string *who) +{ + auto last_slash = key.rfind('/'); + if (last_slash == std::string::npos) { + *name = key; + } else if (auto mgrpos = key.find("/mgr/"); mgrpos != std::string::npos) { + *name = key.substr(mgrpos + 1); + *who = key.substr(0, mgrpos); + } else { + *name = key.substr(last_slash + 1); + *who = key.substr(0, last_slash); + } +} + // -------------- |