diff --git a/htools/Ganeti/Query/Query.hs b/htools/Ganeti/Query/Query.hs index 2d10c3db0e04055485be8870c6f4c9238d1dc768..2dc1fc2c49d45adf52eb3a8a977c7344246ab832 100644 --- a/htools/Ganeti/Query/Query.hs +++ b/htools/Ganeti/Query/Query.hs @@ -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'. diff --git a/htools/Ganeti/Query/Types.hs b/htools/Ganeti/Query/Types.hs index 175dfa537ee48677fe4d46d3868e030ab611e15d..42300b2cd63a83e07a8a7856f0aa20adf9fe3f92 100644 --- a/htools/Ganeti/Query/Types.hs +++ b/htools/Ganeti/Query/Types.hs @@ -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