Skip to content
Snippets Groups Projects
Commit a2ae14e9 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a helper for query field checks


… and also use it to simplify 'needsLiveData'. Additionally, add an
explicit export list to Ganeti.Query.Types, since otherwise we'd
(re)export all imported symbols.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent 9fbf0098
No related branches found
No related tags found
No related merge requests found
......@@ -114,9 +114,7 @@ maybeCollectLiveData True cfg nodes = do
-- | Check whether list of queried fields contains live fields.
needsLiveData :: [FieldGetter a b] -> Bool
needsLiveData = any (\getter -> case getter of
FieldRuntime _ -> True
_ -> False)
needsLiveData = any isRuntimeField
-- | Checks whether we have requested exactly some names. This is a
-- simple wrapper over 'requestedNames' and 'nameField'.
......
......@@ -26,7 +26,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-}
module Ganeti.Query.Types where
module Ganeti.Query.Types
( FieldGetter(..)
, FieldData
, FieldList
, FieldMap
, isRuntimeField
) where
import qualified Data.Map as Map
......@@ -52,3 +58,8 @@ type FieldList a b = [FieldData a b]
-- | Alias for field maps.
type FieldMap a b = Map.Map String (FieldData a b)
-- | Helper function to check if a getter is a runtime one.
isRuntimeField :: FieldGetter a b -> Bool
isRuntimeField (FieldRuntime _) = True
isRuntimeField _ = False
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment