Task #5091
openSwitch NFD configuration file format
0%
Description
The INFO format currently in use for NFD config files is specific to the Boost Property Tree library, instead of being in a standard format. As such, we have had to develop a specific tool (infoedit) to programmatically edit config files in integration tests. Therefore, it would be good to switch to a more popular and standardized format, such as TOML, YAML, or JSON.
Updated by Eric Newberry over 4 years ago
Davide Pesavento wrote:
I'd go with TOML.
One concern with TOML is that there doesn't appear to be any command-line tool to edit TOML files as of yet.
Updated by Davide Pesavento over 4 years ago
Eric Newberry wrote:
One concern with TOML is that there doesn't appear to be any command-line tool to edit TOML files as of yet.
Updated by Eric Newberry over 4 years ago
Davide Pesavento wrote:
Eric Newberry wrote:
One concern with TOML is that there doesn't appear to be any command-line tool to edit TOML files as of yet.
I see. This one must be newer than the article I read saying there was none. This one looks like it's written in Rust, which would add another dependency for the integration tests, although I imagine it would be not terribly difficult to write our own tool in C++ or Python (but that doesn't resolve the existing issue with INFO that I mentioned in the issue description). I also found one written in Node: https://github.com/chrisdickinson/toml-cli
However, since such a tool is available, my preference is also for TOML - I think it has the most readable syntax of the three and can handle nested sections.
Updated by Junxiao Shi over 4 years ago
Given all three languages are JSON compatible, you should always provide a JSON schema, and NFD should validate the document against the JSON schema before proceeding.
Using schema validation can eliminate a lot of complexities in parsing, such as "negative port number", "string as port number", "prefix propagation and /localhop/nfd/rib cannot be enabled at the same time".
JSON¶
There's no way to insert comments in standard JSON.
JSON with comments can be an option.
TOML¶
Editing TOML on command line doesn't require compiling tools during deployment:
- Use
tomljson
from go-toml to convert TOML to JSON. - Use jq to edit JSON.
- Use
jsontoml
from go-toml to convert JSON to TOML.
jq has Ubuntu packages.
go-toml can be pre-compiled once and anyone can wget
them. Go binaries are statically linked and will work on all versions of Linux or macOS.
A drawback of TOML is that, JSON document is not valid TOML document, so that tools that produce JSON must be filtered through jsontoml
.
YAML¶
YAML is a classical configuration format.
Its benefit is that, machine generated configuration files can use JSON, and all YAML parsers will accept them.
However, YAML is too complicated and human can make mistakes.
Updated by Eric Newberry over 4 years ago
- Related to Bug #4489: ConfigFile::parseNumber<unsigned>() doesn't reject negative arguments added
Updated by Eric Newberry over 4 years ago
- Assignee deleted (
Eric Newberry) - Priority changed from Normal to Low
In the dev call on March 19, 2020, it was decided that this config format change is low priority compared to other current issues.