Commit be747966 authored by Iustin Pop's avatar Iustin Pop
Browse files

Change the Luxi tags kind from String to a custom type



This will allow safer code when we implement the tags query.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent 8a9ee1e9
......@@ -1847,6 +1847,9 @@ testSuite "JSON"
-- * Luxi tests
instance Arbitrary Luxi.TagObject where
arbitrary = elements [minBound..maxBound]
instance Arbitrary Luxi.LuxiReq where
arbitrary = elements [minBound..maxBound]
......@@ -1866,7 +1869,7 @@ instance Arbitrary Luxi.LuxiOp where
(listOf getFQDN) <*> arbitrary
Luxi.ReqQueryConfigValues -> Luxi.QueryConfigValues <$> getFields
Luxi.ReqQueryClusterInfo -> pure Luxi.QueryClusterInfo
Luxi.ReqQueryTags -> Luxi.QueryTags <$> getName <*> getFQDN
Luxi.ReqQueryTags -> Luxi.QueryTags <$> arbitrary <*> getFQDN
Luxi.ReqSubmitJob -> Luxi.SubmitJob <$> (resize maxOpCodes arbitrary)
Luxi.ReqSubmitManyJobs -> Luxi.SubmitManyJobs <$>
(resize maxOpCodes arbitrary)
......
......@@ -32,6 +32,7 @@ module Ganeti.Luxi
, Client
, JobId
, RecvResult(..)
, TagObject(..)
, strOfOp
, checkRS
, getClient
......@@ -99,6 +100,15 @@ data RecvResult = RecvConnClosed -- ^ Connection closed
-- | The Ganeti job type.
type JobId = Int
-- | Data type representing what items do the tag operations apply to.
$(declareSADT "TagObject"
[ ("TagInstance", 'tagInstance)
, ("TagNode", 'tagNode)
, ("TagGroup", 'tagNodegroup)
, ("TagCluster", 'tagCluster)
])
$(makeJSONInstance ''TagObject)
-- | Currently supported Luxi operations and JSON serialization.
$(genLuxiOp "LuxiOp"
[(luxiReqQuery,
......@@ -134,7 +144,7 @@ $(genLuxiOp "LuxiOp"
)
, (luxiReqQueryClusterInfo, [])
, (luxiReqQueryTags,
[ ("kind", [t| String |])
[ ("kind", [t| TagObject |])
, ("name", [t| String |])
])
, (luxiReqSubmitJob,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment