bmc: move transports vector into handler object

Move the transport vector to the firmware handler object.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ic64b56b95ec52d4bbeb7e12ac26d0cc238363e42
diff --git a/bmc/firmware_handler.cpp b/bmc/firmware_handler.cpp
index 7d896d1..bc9ff84 100644
--- a/bmc/firmware_handler.cpp
+++ b/bmc/firmware_handler.cpp
@@ -38,7 +38,7 @@
 std::unique_ptr<blobs::GenericBlobInterface>
     FirmwareBlobHandler::CreateFirmwareBlobHandler(
         std::vector<HandlerPack>&& firmwares,
-        const std::vector<DataHandlerPack>& transports, ActionMap&& actionPacks)
+        std::vector<DataHandlerPack>&& transports, ActionMap&& actionPacks)
 {
     /* There must be at least one in addition to the hash blob handler. */
     if (firmwares.size() < 2)
@@ -66,8 +66,9 @@
         return nullptr;
     }
 
-    return std::make_unique<FirmwareBlobHandler>(
-        std::move(firmwares), blobs, transports, std::move(actionPacks));
+    return std::make_unique<FirmwareBlobHandler>(std::move(firmwares), blobs,
+                                                 std::move(transports),
+                                                 std::move(actionPacks));
 }
 
 /* Check if the path is in our supported list (or active list). */
diff --git a/bmc/firmware_handler.hpp b/bmc/firmware_handler.hpp
index 5cef9e9..91699e6 100644
--- a/bmc/firmware_handler.hpp
+++ b/bmc/firmware_handler.hpp
@@ -106,10 +106,9 @@
      * @param[in] update - point to object for triggering the update
      */
     static std::unique_ptr<blobs::GenericBlobInterface>
-        CreateFirmwareBlobHandler(
-            std::vector<HandlerPack>&& firmwares,
-            const std::vector<DataHandlerPack>& transports,
-            ActionMap&& actionPacks);
+        CreateFirmwareBlobHandler(std::vector<HandlerPack>&& firmwares,
+                                  std::vector<DataHandlerPack>&& transports,
+                                  ActionMap&& actionPacks);
 
     /**
      * Create a FirmwareBlobHandler.
@@ -122,13 +121,13 @@
      */
     FirmwareBlobHandler(std::vector<HandlerPack>&& firmwares,
                         const std::vector<std::string>& blobs,
-                        const std::vector<DataHandlerPack>& transports,
+                        std::vector<DataHandlerPack>&& transports,
                         ActionMap&& actionPacks) :
         handlers(std::move(firmwares)),
-        blobIDs(blobs), transports(transports), activeImage(activeImageBlobId),
-        activeHash(activeHashBlobId), verifyImage(verifyBlobId),
-        updateImage(updateBlobId), lookup(), state(UpdateState::notYetStarted),
-        actionPacks(std::move(actionPacks))
+        blobIDs(blobs), transports(std::move(transports)),
+        activeImage(activeImageBlobId), activeHash(activeHashBlobId),
+        verifyImage(verifyBlobId), updateImage(updateBlobId), lookup(),
+        state(UpdateState::notYetStarted), actionPacks(std::move(actionPacks))
     {}
     ~FirmwareBlobHandler() = default;
     FirmwareBlobHandler(const FirmwareBlobHandler&) = delete;
diff --git a/bmc/main.cpp b/bmc/main.cpp
index f284d1c..ee15bba 100644
--- a/bmc/main.cpp
+++ b/bmc/main.cpp
@@ -132,8 +132,8 @@
     }
 
     auto handler = ipmi_flash::FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(supportedFirmware), ipmi_flash::supportedTransports,
-        std::move(actionPacks));
+        std::move(supportedFirmware),
+        std::move(ipmi_flash::supportedTransports), std::move(actionPacks));
 
     if (!handler)
     {
diff --git a/bmc/test/firmware_canhandle_unittest.cpp b/bmc/test/firmware_canhandle_unittest.cpp
index c542139..b18b525 100644
--- a/bmc/test/firmware_canhandle_unittest.cpp
+++ b/bmc/test/firmware_canhandle_unittest.cpp
@@ -37,7 +37,7 @@
     };
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
 
     for (const auto& item : items)
     {
diff --git a/bmc/test/firmware_commit_unittest.cpp b/bmc/test/firmware_commit_unittest.cpp
index 51592a9..eb11211 100644
--- a/bmc/test/firmware_commit_unittest.cpp
+++ b/bmc/test/firmware_commit_unittest.cpp
@@ -56,7 +56,7 @@
         std::make_unique<StrictMock<TriggerMock>>();
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
 
     EXPECT_CALL(*imageMock2, open("asdf")).WillOnce(Return(true));
 
@@ -77,7 +77,7 @@
         std::make_unique<StrictMock<TriggerMock>>();
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
 
     EXPECT_CALL(*imageMock1, open(StrEq(hashBlobId))).WillOnce(Return(true));
 
diff --git a/bmc/test/firmware_handler_unittest.cpp b/bmc/test/firmware_handler_unittest.cpp
index 50801c9..bbbd15a 100644
--- a/bmc/test/firmware_handler_unittest.cpp
+++ b/bmc/test/firmware_handler_unittest.cpp
@@ -24,7 +24,7 @@
     };
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        {}, data, std::move(CreateActionMap("abcd")));
+        {}, std::move(data), std::move(CreateActionMap("abcd")));
     EXPECT_EQ(handler, nullptr);
 }
 TEST(FirmwareHandlerTest, CreateEmptyDataHandlerListFails)
@@ -38,7 +38,8 @@
         std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>())));
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), {}, std::move(CreateActionMap("asdf")));
+        std::move(blobs), std::move(std::vector<DataHandlerPack>()),
+        std::move(CreateActionMap("asdf")));
     EXPECT_EQ(handler, nullptr);
 }
 TEST(FirmwareHandlerTest, CreateEmptyActionPackVerifyFails)
@@ -59,7 +60,7 @@
     ActionMap emptyMap;
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), data, std::move(emptyMap));
+        std::move(blobs), std::move(data), std::move(emptyMap));
     EXPECT_EQ(handler, nullptr);
 }
 TEST(FirmwareHandlerTest, FirmwareHandlerListRequiresAtLeastTwoEntries)
@@ -79,7 +80,7 @@
         HandlerPack(hashBlobId, std::make_unique<ImageHandlerMock>())));
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
     EXPECT_EQ(handler, nullptr);
 
     /* Add second firmware and it'll now work. */
@@ -89,8 +90,11 @@
     blobs2.push_back(
         std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>())));
 
+    data = {
+        {FirmwareFlags::UpdateFlags::ipmi, nullptr},
+    };
     handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs2), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs2), std::move(data), std::move(CreateActionMap("asdf")));
 
     auto result = handler->getBlobIds();
     std::vector<std::string> expectedBlobs = {"asdf", hashBlobId};
@@ -108,7 +112,7 @@
         std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>())));
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
     EXPECT_EQ(handler, nullptr);
 
     std::vector<HandlerPack> blobs2;
@@ -117,8 +121,11 @@
     blobs2.push_back(std::move(
         HandlerPack(hashBlobId, std::make_unique<ImageHandlerMock>())));
 
+    data = {
+        {FirmwareFlags::UpdateFlags::ipmi, nullptr},
+    };
     handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs2), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs2), std::move(data), std::move(CreateActionMap("asdf")));
 
     auto result = handler->getBlobIds();
     std::vector<std::string> expectedBlobs = {"asdf", hashBlobId};
diff --git a/bmc/test/firmware_multiplebundle_unittest.cpp b/bmc/test/firmware_multiplebundle_unittest.cpp
index 1cbda1a..a2984b7 100644
--- a/bmc/test/firmware_multiplebundle_unittest.cpp
+++ b/bmc/test/firmware_multiplebundle_unittest.cpp
@@ -88,7 +88,7 @@
         packs[biosBlobId] = std::move(biosPack);
 
         handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-            std::move(blobs), data, std::move(packs));
+            std::move(blobs), std::move(data), std::move(packs));
     }
 
     void expectedState(FirmwareBlobHandler::UpdateState state)
diff --git a/bmc/test/firmware_open_unittest.cpp b/bmc/test/firmware_open_unittest.cpp
index 77e5ff3..a2e3d95 100644
--- a/bmc/test/firmware_open_unittest.cpp
+++ b/bmc/test/firmware_open_unittest.cpp
@@ -33,7 +33,7 @@
         std::move(HandlerPack("asdf", std::make_unique<ImageHandlerMock>())));
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
 
     EXPECT_FALSE(handler->open(0, GetParam(), "asdf"));
 }
diff --git a/bmc/test/firmware_stat_unittest.cpp b/bmc/test/firmware_stat_unittest.cpp
index 4eb2e99..1313c5a 100644
--- a/bmc/test/firmware_stat_unittest.cpp
+++ b/bmc/test/firmware_stat_unittest.cpp
@@ -36,7 +36,7 @@
     };
 
     auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        std::move(blobs), data, std::move(CreateActionMap("asdf")));
+        std::move(blobs), std::move(data), std::move(CreateActionMap("asdf")));
 
     blobs::BlobMeta meta;
     EXPECT_TRUE(handler->stat("asdf", &meta));
diff --git a/bmc/test/firmware_state_notyetstarted_tarball_unittest.cpp b/bmc/test/firmware_state_notyetstarted_tarball_unittest.cpp
index e171646..6ce6102 100644
--- a/bmc/test/firmware_state_notyetstarted_tarball_unittest.cpp
+++ b/bmc/test/firmware_state_notyetstarted_tarball_unittest.cpp
@@ -50,7 +50,7 @@
         packs[ubiTarballBlobId] = std::move(actionPack);
 
         handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-            std::move(blobs), data, std::move(packs));
+            std::move(blobs), std::move(data), std::move(packs));
     }
 
     void expectedState(FirmwareBlobHandler::UpdateState state)
diff --git a/bmc/test/firmware_unittest.hpp b/bmc/test/firmware_unittest.hpp
index 3d7fa4e..0b4dc53 100644
--- a/bmc/test/firmware_unittest.hpp
+++ b/bmc/test/firmware_unittest.hpp
@@ -60,7 +60,7 @@
         packs[staticLayoutBlobId] = std::move(actionPack);
 
         handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-            std::move(blobs), data, std::move(packs));
+            std::move(blobs), std::move(data), std::move(packs));
     }
 
     void expectedState(FirmwareBlobHandler::UpdateState state)
@@ -213,7 +213,8 @@
         blobs.push_back(std::move(HandlerPack("asdf", std::move(image))));
 
         handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-            std::move(blobs), data, std::move(CreateActionMap("asdf")));
+            std::move(blobs), std::move(data),
+            std::move(CreateActionMap("asdf")));
     }
 };
 
@@ -242,7 +243,8 @@
             {FirmwareFlags::UpdateFlags::lpc, &dataMock},
         };
         handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-            std::move(blobs), data, std::move(CreateActionMap("asdf")));
+            std::move(blobs), std::move(data),
+            std::move(CreateActionMap("asdf")));
     }
 };