upgradeManifests :: JSValue -> JSValue
upgradeManifests tree =
    jsModify manifest "/backend/appliance_manifest" $
    tree
    where
      app_type True  _             = "dynamic"
      app_type False n | n > 1     = "hybrid"
                       | otherwise = "static"

      shared (Just (JSBool x)) = x
      shared _                 = error "expected appliance shared boolean"

      num_disks (Just (JSArray dms)) = length dms
      num_disks _                    = error "expected array of disk manifests"

      manifest tree =
          jsSet "/appliance/imgType" (jsBoxString $ app_type s n) $
          tree
          where
            s = shared $ jsGet "/appliance/shared" tree
            n = num_disks $ jsGet "/disk_manifests" tree
upgradeManifests :: JSValue -> JSValue
upgradeManifests tree =
    jsModify manifest "/backend/appliance_manifest" $
    tree
    where
      app_type True  _             = "dynamic"
      app_type False n | n > 1     = "hybrid"
                       | otherwise = "static"

      shared (Just (JSBool x)) = x
      shared _                 = error "expected appliance shared boolean"

      num_disks (Just (JSArray dms)) = length dms
      num_disks _                    = error "expected array of disk manifests"

      manifest tree =
          jsSet "/appliance/imgType" (jsBoxString $ app_type s n) $
          tree
          where
            s = shared $ jsGet "/appliance/shared" tree
            n = num_disks $ jsGet "/disk_manifests" tree
upgradeManifests tree =
    jsModify manifest "/backend/appliance_manifest" $
    tree
    where
      app_type True  _             = "dynamic"
      app_type False n | n > 1     = "hybrid"
                       | otherwise = "static"

      shared (Just (JSBool x)) = x
      shared _                 = error "expected appliance shared boolean"

      num_disks (Just (JSArray dms)) = length dms
      num_disks _                    = error "expected array of disk manifests"

      manifest tree =
          jsSet "/appliance/imgType" (jsBoxString $ app_type s n) $
          tree
          where
            s = shared $ jsGet "/appliance/shared" tree
            n = num_disks $ jsGet "/disk_manifests" tree