Add node comment functionality to Config_tree
Closed, ResolvedPublic


Now in VyOS there are node comments, though for some reason few people use it. It's a nice feature and I don't see why it shouldn't be in 2.0.

There was already a field in node data record type in Config_tree for it, but I think it should be string option rather than just string so that we can reliably distinguish between "comment set" and "comment not set" states Nodes with empty comments are marginal, and we hardly want to support them (as in, 'comment interfaces ethernet eth0 ""' should remove the comment), but internally it's handy to be able to see if there is any comment at all, and pattern matching is cheaper than string comparison. The default value for the field should be None.

type config_node_data = {
    values: string list;
    comment: string option;

The Config_tree module should therefore have the following functions:

val set_comment : t -> string list -> string option -> t

val get_comment : t -> string list -> string option

We also need to add a unit test for it (if we add a comment with set_comment, get_comment should return the comment we set).


Difficulty level
Easy (less than an hour)