-
Notifications
You must be signed in to change notification settings - Fork 123
write storage plugins with existing parsers #1231
Description
Hello newcomer,
Elektra's goal is to integrate current forms of configuration files. The best way to integrate them is to use ready-made parsers, then Elektra uses exactly the same code to access configuration files as the application. Some ideas for such libraries (random order):
- https://github.com/vstakhov/libucl
- https://github.com/toml-lang/toml
- http://www.hyperrealm.com/libconfig/
- https://github.com/martinh/libconfuse
- http://home.gna.org/cfl/
- https://rfc.zeromq.org/spec:4/ZPL/
- http://rudeserver.com/config/
- http://sbooth.org/ccl/
- http://ndevilla.free.fr/iniparser/
- https://kdl.dev/
- many, many others..
You should prefer to pick the ones you are familar with, which are popular, are well maintained, and provide a easy-to-use API.
To get support for a new file format with a new parser, you have to create a new plugin (see https://github.com/ElektraInitiative/libelektra/blob/master/doc/tutorials/plugins.md and https://github.com/ElektraInitiative/libelektra/blob/master/doc/tutorials/storage-plugins.md). You only have to implement kdbGet and kdbSet:
- in kdbGet you first you look into the string of the parentKey and open the configuration file of this name. Then you iterate over all keys you get from the library and transform them into a keyset.
- in kdbSet you do the opposite: you iterate over the keyset and feed it to the library. Again you use the string of the parentKey to know where to write the content to.
A Plugin that already does exactly this are https://tree.libelektra.org/src/plugins/ni (you can ignore metakey and metavalue for a first step)
To complete the task, please:
- implement as described above for one configuration parsing library
- fully fill out README.md. For tricky parts (provides, placements) you can peek into the READMEs of other storage plugins.
- handle all errors (also peek in other storage plugins what to do on I/O errors)
- add unit tests demonstrating that a file read and written again stays the same (you guessed it, other storage plugins do the same)
- remove not needed parts of template (open, close, error)
Please write something below before starting the task. You can always ask here for help.