summaryrefslogtreecommitdiff
path: root/redfish-core/lib/roles.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-05-31 18:59:27 +0300
committerEd Tanous <ed@tanous.net>2022-06-01 19:10:35 +0300
commit002d39b4a7a5ed7166e2acad84e0943c3def9492 (patch)
tree4307dd5161ec9779d59308a9b933e408cc2c6ca7 /redfish-core/lib/roles.hpp
parent62c416fb0d2f62e09d7f60754ff359ac2389e749 (diff)
downloadbmcweb-002d39b4a7a5ed7166e2acad84e0943c3def9492.tar.xz
Try to fix the lambda formatting issue
clang-tidy has a setting, LambdaBodyIndentation, which it says: "For callback-heavy code, it may improve readability to have the signature indented two levels and to use OuterScope." bmcweb is very callback heavy code. Try to enable it and see if that improves things. There are many cases where the length of a lambda call will change, and reindent the entire lambda function. This is really bad for code reviews, as it's difficult to see the lines changed. This commit should resolve it. This does have the downside of reindenting a lot of functions, which is unfortunate, but probably worth it in the long run. All changes except for the .clang-format file were made by the robot. Tested: Code compiles, whitespace changes only. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
Diffstat (limited to 'redfish-core/lib/roles.hpp')
-rw-r--r--redfish-core/lib/roles.hpp120
1 files changed, 58 insertions, 62 deletions
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index 6f27b8e10c..67e54670b0 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -81,31 +81,29 @@ inline void requestRoutesRoles(App& app)
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& roleId) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- nlohmann::json privArray = nlohmann::json::array();
- if (!getAssignedPrivFromRole(roleId, privArray))
- {
- messages::resourceNotFound(asyncResp->res, "Role", roleId);
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ nlohmann::json privArray = nlohmann::json::array();
+ if (!getAssignedPrivFromRole(roleId, privArray))
+ {
+ messages::resourceNotFound(asyncResp->res, "Role", roleId);
- return;
- }
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] = "#Role.v1_2_2.Role";
- asyncResp->res.jsonValue["Name"] = "User Role";
- asyncResp->res.jsonValue["Description"] = roleId + " User Role";
- asyncResp->res.jsonValue["OemPrivileges"] =
- nlohmann::json::array();
- asyncResp->res.jsonValue["IsPredefined"] = true;
- asyncResp->res.jsonValue["Id"] = roleId;
- asyncResp->res.jsonValue["RoleId"] = roleId;
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/AccountService/Roles/" + roleId;
- asyncResp->res.jsonValue["AssignedPrivileges"] =
- std::move(privArray);
- });
+ asyncResp->res.jsonValue["@odata.type"] = "#Role.v1_2_2.Role";
+ asyncResp->res.jsonValue["Name"] = "User Role";
+ asyncResp->res.jsonValue["Description"] = roleId + " User Role";
+ asyncResp->res.jsonValue["OemPrivileges"] = nlohmann::json::array();
+ asyncResp->res.jsonValue["IsPredefined"] = true;
+ asyncResp->res.jsonValue["Id"] = roleId;
+ asyncResp->res.jsonValue["RoleId"] = roleId;
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/AccountService/Roles/" + roleId;
+ asyncResp->res.jsonValue["AssignedPrivileges"] = std::move(privArray);
+ });
}
inline void requestRoutesRoleCollection(App& app)
@@ -115,48 +113,46 @@ inline void requestRoutesRoleCollection(App& app)
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/AccountService/Roles";
- asyncResp->res.jsonValue["@odata.type"] =
- "#RoleCollection.RoleCollection";
- asyncResp->res.jsonValue["Name"] = "Roles Collection";
- asyncResp->res.jsonValue["Description"] = "BMC User Roles";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/AccountService/Roles";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#RoleCollection.RoleCollection";
+ asyncResp->res.jsonValue["Name"] = "Roles Collection";
+ asyncResp->res.jsonValue["Description"] = "BMC User Roles";
- sdbusplus::asio::getProperty<std::vector<std::string>>(
- *crow::connections::systemBus,
- "xyz.openbmc_project.User.Manager",
- "/xyz/openbmc_project/user",
- "xyz.openbmc_project.User.Manager", "AllPrivileges",
- [asyncResp](const boost::system::error_code ec,
- const std::vector<std::string>& privList) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- nlohmann::json& memberArray =
- asyncResp->res.jsonValue["Members"];
- memberArray = nlohmann::json::array();
- for (const std::string& priv : privList)
- {
- std::string role = getRoleFromPrivileges(priv);
- if (!role.empty())
- {
- nlohmann::json::object_t member;
- member["@odata.id"] =
- "/redfish/v1/AccountService/Roles/" + role;
- memberArray.push_back(std::move(member));
- }
- }
- asyncResp->res.jsonValue["Members@odata.count"] =
- memberArray.size();
- });
+ sdbusplus::asio::getProperty<std::vector<std::string>>(
+ *crow::connections::systemBus, "xyz.openbmc_project.User.Manager",
+ "/xyz/openbmc_project/user", "xyz.openbmc_project.User.Manager",
+ "AllPrivileges",
+ [asyncResp](const boost::system::error_code ec,
+ const std::vector<std::string>& privList) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json& memberArray = asyncResp->res.jsonValue["Members"];
+ memberArray = nlohmann::json::array();
+ for (const std::string& priv : privList)
+ {
+ std::string role = getRoleFromPrivileges(priv);
+ if (!role.empty())
+ {
+ nlohmann::json::object_t member;
+ member["@odata.id"] =
+ "/redfish/v1/AccountService/Roles/" + role;
+ memberArray.push_back(std::move(member));
+ }
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ memberArray.size();
});
+ });
}
} // namespace redfish