LGTM, thanks.
On Tue, Jan 21, 2014 at 4:00 PM, Klaus Aehlig <[email protected]> wrote: > ...to avoid duplicating that code all over Ganeti.Query. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/Query/Export.hs | 4 +--- > src/Ganeti/Query/Group.hs | 5 +---- > src/Ganeti/Query/Instance.hs | 2 +- > src/Ganeti/Query/Job.hs | 4 +--- > src/Ganeti/Query/Locks.hs | 5 +---- > src/Ganeti/Query/Network.hs | 3 +-- > src/Ganeti/Query/Node.hs | 3 +-- > 7 files changed, 7 insertions(+), 19 deletions(-) > > diff --git a/src/Ganeti/Query/Export.hs b/src/Ganeti/Query/Export.hs > index d45b930..f7c35aa 100644 > --- a/src/Ganeti/Query/Export.hs > +++ b/src/Ganeti/Query/Export.hs > @@ -30,7 +30,6 @@ module Ganeti.Query.Export > ) where > > import Control.Monad (liftM) > -import qualified Data.Map as Map > > import Ganeti.Objects > import Ganeti.Rpc > @@ -65,8 +64,7 @@ exportFields = > > -- | The node fields map. > fieldsMap :: FieldMap Node Runtime > -fieldsMap = > - Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) exportFields > +fieldsMap = fieldListToFieldMap exportFields > > -- | Collect live data from RPC query if enabled. > -- > diff --git a/src/Ganeti/Query/Group.hs b/src/Ganeti/Query/Group.hs > index b4f4a7b..ca3154c 100644 > --- a/src/Ganeti/Query/Group.hs > +++ b/src/Ganeti/Query/Group.hs > @@ -26,8 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, > Boston, MA > module Ganeti.Query.Group > (fieldsMap) where > > -import qualified Data.Map as Map > - > import Ganeti.Config > import Ganeti.Objects > import Ganeti.Query.Language > @@ -83,5 +81,4 @@ groupFields = > > -- | The group fields map. > fieldsMap :: FieldMap NodeGroup NoDataRuntime > -fieldsMap = > - Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) groupFields > +fieldsMap = fieldListToFieldMap groupFields > diff --git a/src/Ganeti/Query/Instance.hs b/src/Ganeti/Query/Instance.hs > index a398e49..3b81a2f 100644 > --- a/src/Ganeti/Query/Instance.hs > +++ b/src/Ganeti/Query/Instance.hs > @@ -72,7 +72,7 @@ type Runtime = Either RpcError LiveInfo > > -- | The instance fields map. > fieldsMap :: FieldMap Instance Runtime > -fieldsMap = Map.fromList [(fdefName f, v) | v@(f, _, _) <- aliasedFields] > +fieldsMap = fieldListToFieldMap aliasedFields > > -- | The instance aliases. > instanceAliases :: [(FieldName, FieldName)] > diff --git a/src/Ganeti/Query/Job.hs b/src/Ganeti/Query/Job.hs > index 21d3425..445d4a2 100644 > --- a/src/Ganeti/Query/Job.hs > +++ b/src/Ganeti/Query/Job.hs > @@ -29,7 +29,6 @@ module Ganeti.Query.Job > , wantArchived > ) where > > -import qualified Data.Map as Map > import qualified Text.JSON as J > > import Ganeti.BasicTypes > @@ -139,5 +138,4 @@ jobFields = > > -- | The node fields map. > fieldsMap :: FieldMap JobId RuntimeData > -fieldsMap = > - Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) jobFields > +fieldsMap = fieldListToFieldMap jobFields > diff --git a/src/Ganeti/Query/Locks.hs b/src/Ganeti/Query/Locks.hs > index 363f539..3d4b577 100644 > --- a/src/Ganeti/Query/Locks.hs > +++ b/src/Ganeti/Query/Locks.hs > @@ -30,8 +30,6 @@ module Ganeti.Query.Locks > ( fieldsMap > ) where > > -import qualified Data.Map as Map > - > import Ganeti.Query.Common > import Ganeti.Query.Language > import Ganeti.Query.Types > @@ -53,5 +51,4 @@ lockFields = > > -- | The lock fields map. > fieldsMap :: FieldMap String () > -fieldsMap = > - Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) lockFields > +fieldsMap = fieldListToFieldMap lockFields > diff --git a/src/Ganeti/Query/Network.hs b/src/Ganeti/Query/Network.hs > index 012170d..168c595 100644 > --- a/src/Ganeti/Query/Network.hs > +++ b/src/Ganeti/Query/Network.hs > @@ -94,8 +94,7 @@ networkFields = > > -- | The group fields map. > fieldsMap :: FieldMap Network NoDataRuntime > -fieldsMap = > - Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) networkFields > +fieldsMap = fieldListToFieldMap networkFields > > -- TODO: the following fields are not implemented yet: > external_reservations > > diff --git a/src/Ganeti/Query/Node.hs b/src/Ganeti/Query/Node.hs > index 4cf4bd7..5e422f2 100644 > --- a/src/Ganeti/Query/Node.hs > +++ b/src/Ganeti/Query/Node.hs > @@ -257,8 +257,7 @@ getNumInstances get_fn cfg = length . get_fn . > getNodeInstances cfg . nodeUuid > > -- | The node fields map. > fieldsMap :: FieldMap Node Runtime > -fieldsMap = > - Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) nodeFields > +fieldsMap = fieldListToFieldMap nodeFields > > -- | Create an RPC result for a broken node > rpcResultNodeBroken :: Node -> (Node, Runtime) > -- > 1.8.5.3 > >
