farsandra
farsandra copied to clipboard
Handle YAML replacement using SnakeYAML parsing/serialization instead of string manipulation.
Handle YAML replacement using SnakeYAML parsing/serialization instead of string manipulation.
So I was thinking about the discussion on #22. I wondered if the issues around supporting multiple versions could be reduced by parsing the YAML and manipulating the parsed tree, rather than doing text replacement. This is the result.
I used SnakeYAML to parse cassandra.yaml
and built a little object model (see here). It's backed by the generic SnakeYAML parse tree, with custom getters and setters for the values we want to change.
The only existing API I couldn't support was withYamlReplacement. I could do something like withYamlReplacement(String name, Object Value)
but it wouldn't be compatible with the existing API.
Hum this gets a little bit tricky. One of the things about FAR sandra is we do not want "intimate" knowledge of the structure of the configs because they are subject to change. I think in the end we have to be version specific, because one model probably would not work for 1.2 -> 3.0. Let me look this over some more.
In the end I do not think there is a way for a tool to understand config files (think like puppet/cfengine) most of the work is approximations based on a known base state. But let me look this over and chew this over a bit.