getInstance :: ConfigData -> String -> ErrorResult Instance
getInstance cfg name =
  let instances = fromContainer (configInstances cfg)
  in case getItem' "Instance" name instances of
       -- if not found by uuid, we need to look it up by name
       Ok inst -> Ok inst
       Bad _ -> let by_name =
                      M.delete ""
                      . M.mapKeys (fromMaybe "" . instName . (M.!) instances)
                      $ instances
                in getItem "Instance" name by_name

-- | Looks up an instance by exact name match
getInstance :: ConfigData -> String -> ErrorResult Instance
getInstance cfg name =
  let instances = fromContainer (configInstances cfg)
  in case getItem' "Instance" name instances of
       -- if not found by uuid, we need to look it up by name
       Ok inst -> Ok inst
       Bad _ -> let by_name =
                      M.delete ""
                      . M.mapKeys (fromMaybe "" . instName . (M.!) instances)
                      $ instances
                in getItem "Instance" name by_name

-- | Looks up an instance by exact name match
getInstance cfg name =
  let instances = fromContainer (configInstances cfg)
  in case getItem' "Instance" name instances of
       -- if not found by uuid, we need to look it up by name
       Ok inst -> Ok inst
       Bad _ -> let by_name =
                      M.delete ""
                      . M.mapKeys (fromMaybe "" . instName . (M.!) instances)
                      $ instances
                in getItem "Instance" name by_name

-- | Looks up an instance by exact name match