From: Casey Bodley Date: Wed, 2 Jul 2025 19:26:02 +0000 (-0400) Subject: rgw/main: clean up use of rgw_enable_apis X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4ec80fa1b870c897234e9450b362acc366f761e;p=ceph.git rgw/main: clean up use of rgw_enable_apis replace `get_str_vec()` with `ceph::split()` replace `map` with `set` replace `count(key) > 0` with `contains(key)` Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_appmain.cc b/src/rgw/rgw_appmain.cc index 08ba5dca547..6641e2b304d 100644 --- a/src/rgw/rgw_appmain.cc +++ b/src/rgw/rgw_appmain.cc @@ -13,6 +13,7 @@ * */ +#include #include #include "global/global_init.h" #include "global/signal_handler.h" @@ -21,6 +22,7 @@ #include "common/Timer.h" #include "common/TracepointProvider.h" #include "common/numa.h" +#include "common/split.h" #include "include/compat.h" #include "include/str_list.h" #include "include/stringify.h" @@ -272,13 +274,10 @@ void rgw::AppMain::cond_init_apis() rgw_rest_init(g_ceph_context, env.driver->get_zone()->get_zonegroup()); if (have_http_frontend) { - std::vector apis; - get_str_vec(g_conf()->rgw_enable_apis, apis); + const auto apis = ceph::split(g_conf()->rgw_enable_apis); - std::map apis_map; - for (auto &api : apis) { - apis_map[api] = true; - } + std::set apis_set; + apis_set.insert(apis.begin(), apis.end()); /* warn about insecure keystone secret config options */ if (!g_ceph_context->_conf->rgw_keystone_admin_password.empty()) { @@ -290,14 +289,14 @@ void rgw::AppMain::cond_init_apis() } // S3 website mode is a specialization of S3 - const bool s3website_enabled = apis_map.count("s3website") > 0; - const bool sts_enabled = apis_map.count("sts") > 0; - const bool iam_enabled = apis_map.count("iam") > 0; + const bool s3website_enabled = apis_set.contains("s3website"); + const bool sts_enabled = apis_set.contains("sts"); + const bool iam_enabled = apis_set.contains("iam"); const bool pubsub_enabled = - apis_map.count("pubsub") > 0 || apis_map.count("notifications") > 0; + apis_set.contains("pubsub") || apis_set.contains("notifications"); // Swift API entrypoint could placed in the root instead of S3 const bool swift_at_root = g_conf()->rgw_swift_url_prefix == "/"; - if (apis_map.count("s3") > 0 || s3website_enabled) { + if (apis_set.contains("s3") || s3website_enabled) { if (!swift_at_root) { rest.register_default_mgr(set_logging( rest_filter(env.driver, RGW_REST_S3, @@ -309,7 +308,7 @@ void rgw::AppMain::cond_init_apis() } } - if (apis_map.count("swift") > 0) { + if (apis_set.contains("swift")) { RGWRESTMgr_SWIFT* const swift_resource = new RGWRESTMgr_SWIFT; if (! g_conf()->rgw_cross_domain_policy.empty()) { @@ -338,12 +337,12 @@ void rgw::AppMain::cond_init_apis() } } - if (apis_map.count("swift_auth") > 0) { + if (apis_set.contains("swift_auth")) { rest.register_resource(g_conf()->rgw_swift_auth_entry, set_logging(new RGWRESTMgr_SWIFT_Auth)); } - if (apis_map.count("admin") > 0) { + if (apis_set.contains("admin")) { RGWRESTMgr_Admin *admin_resource = new RGWRESTMgr_Admin; admin_resource->register_resource("info", new RGWRESTMgr_Info); admin_resource->register_resource("usage", new RGWRESTMgr_Usage); @@ -354,7 +353,7 @@ void rgw::AppMain::cond_init_apis() rest.register_resource(g_conf()->rgw_admin_entry, admin_resource); } - if (apis_map.count("zero")) { + if (apis_set.contains("zero")) { rest.register_resource("zero", new rgw::RESTMgr_Zero()); } } /* have_http_frontend */