Convert tag objects to a safer type
Currently, we keep information about the "target" of a tag operation in a data type similar to (TagKind, Maybe String). This is unsafe, as nothing (at the type level) prevents us from accidentally having (TagCluster, Just "instance1.example.com"), or (TagInstance, Nothing). To fix this problem, we rename the current TagObject type to TagType (an internal utility type), and create TagObject as a better/safer data type (see the definition), which doesn't allow such possibilities in the future. The downside is that, since at encoding level (both opcode and luxi) this is done in an ugly way (type elements spread at the same level as level as other value), we have to add custom encoders/decoders. The encoder is shared between the OpCode and Luxi usage, the decoder is different however as Luxi uses custom decoding. This also fixes the recent breakage in confd w.r.t. QueryTags. Signed-off-by:Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
Showing
- htest/Test/Ganeti/Luxi.hs 1 addition, 1 deletionhtest/Test/Ganeti/Luxi.hs
- htest/Test/Ganeti/OpCodes.hs 8 additions, 3 deletionshtest/Test/Ganeti/OpCodes.hs
- htools/Ganeti/Luxi.hs 4 additions, 3 deletionshtools/Ganeti/Luxi.hs
- htools/Ganeti/OpCodes.hs 63 additions, 11 deletionshtools/Ganeti/OpCodes.hs
- htools/Ganeti/Query/Server.hs 5 additions, 5 deletionshtools/Ganeti/Query/Server.hs
Loading
Please register or sign in to comment