buildjson: Support multiple configuration paths

This will allow us to parse configurations from multiple paths in the
filesystem when they are added.

Right now this does not enable new behavior, but a future change will
enable a non-persistent configuration location.

Change-Id: Ifa9bc5eff9cfca84c923be381ec9927c62c2a2e5
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/bmc/buildjson.cpp b/bmc/buildjson.cpp
index a32fbcb..25703f7 100644
--- a/bmc/buildjson.cpp
+++ b/bmc/buildjson.cpp
@@ -68,4 +68,8 @@
                                               unit, systemdMode);
 }
 
+const std::vector<const char*> defaultConfigPaths = {
+    "/usr/share/phosphor-ipmi-flash",
+};
+
 } // namespace ipmi_flash
diff --git a/bmc/buildjson.hpp b/bmc/buildjson.hpp
index f2b0ba1..58266b5 100644
--- a/bmc/buildjson.hpp
+++ b/bmc/buildjson.hpp
@@ -24,6 +24,8 @@
 std::unique_ptr<TriggerableActionInterface>
     buildSystemd(const nlohmann::json& data);
 
+extern const std::vector<const char*> defaultConfigPaths;
+
 /* HandlersBuilderIfc is a helper class that builds Handlers from the json files
  * found within a specified directory.
  * The child class that inherits from HandlersBuilderIfc should implement
@@ -36,13 +38,27 @@
     virtual ~HandlersBuilderIfc() = default;
 
     /**
+     * Builds configurations from the default set of paths used by the blob
+     * handler.
+     */
+    std::vector<HandlerConfig<T>> buildHandlerConfigsFromDefaultPaths()
+    {
+        std::vector<HandlerConfig<T>> ret;
+        for (auto path : defaultConfigPaths)
+        {
+            auto tmp = buildHandlerConfigs(path);
+            std::move(tmp.begin(), tmp.end(), std::back_inserter(ret));
+        }
+        return ret;
+    }
+
+    /**
      * Given a folder of json configs, build the configurations.
      *
      * @param[in] directory - the directory to search (recurisvely).
      * @return list of HandlerConfig objects.
      */
-    std::vector<HandlerConfig<T>>
-        buildHandlerConfigs(const std::string& directory)
+    std::vector<HandlerConfig<T>> buildHandlerConfigs(const char* directory)
     {
 
         std::vector<HandlerConfig<T>> output;
diff --git a/bmc/firmware-handler/main.cpp b/bmc/firmware-handler/main.cpp
index 32d83f0..a383d02 100644
--- a/bmc/firmware-handler/main.cpp
+++ b/bmc/firmware-handler/main.cpp
@@ -44,9 +44,6 @@
 namespace
 {
 
-static constexpr const char* jsonConfigurationPath =
-    "/usr/share/phosphor-ipmi-flash/";
-
 /**
  * Given a name and path, create a HandlerPack.
  *
@@ -115,8 +112,7 @@
     ActionMap actionPacks = {};
     FirmwareHandlersBuilder builder;
 
-    std::vector<HandlerConfig<ActionPack>> configsFromJson =
-        builder.buildHandlerConfigs(jsonConfigurationPath);
+    auto configsFromJson = builder.buildHandlerConfigsFromDefaultPaths();
 
     std::vector<HandlerPack> supportedFirmware;
 
diff --git a/bmc/version-handler/main.cpp b/bmc/version-handler/main.cpp
index 51df8e1..a08507c 100644
--- a/bmc/version-handler/main.cpp
+++ b/bmc/version-handler/main.cpp
@@ -22,6 +22,6 @@
 extern "C" std::unique_ptr<blobs::GenericBlobInterface> createHandler()
 {
     return std::make_unique<ipmi_flash::VersionBlobHandler>(
-        ipmi_flash::VersionHandlersBuilder().buildHandlerConfigs(
-            "/usr/share/phosphor-ipmi-flash/"));
+        ipmi_flash::VersionHandlersBuilder()
+            .buildHandlerConfigsFromDefaultPaths());
 }