version-handler: Refactor handler construction
Instead of requiring callers to build maps and info blobs, take the
minimal required amount of information about the blob configuration and
build required datastructures internally.
This reduces the amount of code, and nearly eliminates all of the
untested code in main.cpp.
Change-Id: Iaa398eb404814e9263e6707b71b38a9831d96697
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/bmc/version-handler/version_handlers_builder.cpp b/bmc/version-handler/version_handlers_builder.cpp
index d6ed016..f27fa54 100644
--- a/bmc/version-handler/version_handlers_builder.cpp
+++ b/bmc/version-handler/version_handlers_builder.cpp
@@ -32,16 +32,17 @@
namespace ipmi_flash
{
-std::vector<HandlerConfig<VersionActionPack>>
+
+std::vector<HandlerConfig<VersionBlobHandler::ActionPack>>
VersionHandlersBuilder::buildHandlerFromJson(const nlohmann::json& data)
{
- std::vector<HandlerConfig<VersionActionPack>> handlers;
+ std::vector<HandlerConfig<VersionBlobHandler::ActionPack>> handlers;
for (const auto& item : data)
{
try
{
- HandlerConfig<VersionActionPack> output;
+ HandlerConfig<VersionBlobHandler::ActionPack> output;
/* at() throws an exception when the key is not present. */
item.at("blob").get_to(output.blobId);
@@ -75,8 +76,7 @@
/* actions are required (presently). */
const auto& a = v.at("actions");
- std::unique_ptr<VersionActionPack> pack =
- std::make_unique<VersionActionPack>();
+ auto pack = std::make_unique<VersionBlobHandler::ActionPack>();
/* to make an action optional, assign type "skip" */
const auto& onOpen = a.at("open");
@@ -111,4 +111,5 @@
return handlers;
}
+
} // namespace ipmi_flash