tools: type field now matches the /flash/{type}

Instead of mapping one word to a pre-defined mapping of types, let the
host user specify any value.

A user shouldn't specify hash, or update, or something meaningful.
Perhaps this should be validated.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Icec103e0ade999d527923dcacb440086c93e175c
diff --git a/tools/main.cpp b/tools/main.cpp
index a933e67..ae85c1b 100644
--- a/tools/main.cpp
+++ b/tools/main.cpp
@@ -42,14 +42,10 @@
 #define IPMILPC "ipmilpc"
 #define IPMIPCI "ipmipci"
 #define IPMIBT "ipmibt"
-#define STATIC "static"
-#define UBITAR "ubitar"
-#define BIOS "bios"
 
 namespace
 {
 const std::vector<std::string> interfaceList = {IPMIBT, IPMILPC, IPMIPCI};
-const std::vector<std::string> typeList = {STATIC, UBITAR, BIOS};
 } // namespace
 
 void usage(const char* program)
@@ -65,16 +61,9 @@
               std::ostream_iterator<std::string>(std::cerr, ", "));
     std::fprintf(stderr, "\n");
 
-    std::fprintf(stderr, "layouts: ");
-    std::copy(typeList.begin(), typeList.end(),
-              std::ostream_iterator<std::string>(std::cerr, ", "));
-    std::fprintf(stderr, "\n");
-}
-
-bool checkType(const std::string& type)
-{
-    auto tFound = std::find(typeList.begin(), typeList.end(), type);
-    return (tFound != typeList.end());
+    std::fprintf(stderr, "layouts examples: image, bios\n");
+    std::fprintf(stderr,
+                 "the type field specifies '/flash/{layout}' for a handler\n");
 }
 
 bool checkCommand(const std::string& command)
@@ -178,11 +167,6 @@
                 break;
             case 't':
                 type = std::string{optarg};
-                if (!checkType(type))
-                {
-                    usage(argv[0]);
-                    exit(EXIT_FAILURE);
-                }
                 break;
             default:
                 usage(argv[0]);
@@ -199,7 +183,8 @@
     /* They want to update the firmware. */
     if (command == "update")
     {
-        if (interface.empty() || imagePath.empty() || signaturePath.empty())
+        if (interface.empty() || imagePath.empty() || signaturePath.empty() ||
+            type.empty())
         {
             usage(argv[0]);
             exit(EXIT_FAILURE);
diff --git a/tools/updater.cpp b/tools/updater.cpp
index 96f38b1..0fcfe6f 100644
--- a/tools/updater.cpp
+++ b/tools/updater.cpp
@@ -38,12 +38,10 @@
                  const std::string& signaturePath,
                  const std::string& layoutType)
 {
-    static std::unordered_map<std::string, std::string> typesToBlob = {
-        {"static", ipmi_flash::staticLayoutBlobId},
-        {"ubitar", ipmi_flash::ubiTarballBlobId},
-        {"bios", ipmi_flash::biosBlobId}};
-    /* We know it's one of the above types already. */
-    auto& layout = typesToBlob[layoutType];
+    /* TODO: validate the layoutType isn't a special value such as: 'update',
+     * 'verify', or 'hash'
+     */
+    std::string layout = "/flash/" + layoutType;
 
     bool goalSupported = updater->checkAvailable(layout);
     if (!goalSupported)