Elektra
0.9.8
|
In order to optimally use Elektra an application has to provide a specification. This specification has to be mounted in the spec
namespace by the user (or automatically during the install process). However, this specification should in most cases not be modified by the user. If it is modified the user has to be sure it is still compatible to the original specification. Otherwise the application might crash because it e.g. expected a default value to be provided by the specification that the user changed or removed.
This is were this plugin comes in. Unlike other storage plugins specload
doesn't use the file given during mounting for most of the configuration. Instead specload
requests the specification with which an application was compiled from the application itself. On top of this base specifications the user can make some modifications, which are the only keys stored in the mounted file. All modifications made by the user are verified by the plugin. The user can never modify the specification in a way to would break application compatibility.
NOTE: currently the modifications a user can make are very limited/not possible. See Limitations below.
The plugin relies heavily on the quickdump
plugin. It is used for storing the overridden values as well as the data transfer between specload
and an application.
To check whether quickdump
is available you can use:
To mount specload
use (note: only the spec
namespace is supported):
You always have to specify the app
that shall be called. This application will be called with the single argument --elektra-spec
. This can be configured by using app/args/#
during mounting:
To inhibit the default --elektra-spec
argument and call an application without any arguments use ‘'app/args=’`.
The app must only output the expected base specification to stdout
and then exit, when called by specload
. We use the quickdump
plugin for communication, so the application should call elektraQuickdumpSet
. Because this dependency may change in future, it is recommended you use the function elektraSpecloadSendSpec
exported as "system:/elektra/modules/specload/exports/sendspec"
:
The code above will automatically print the KeySet ks
to stdout in exactly the way specload
expects it.
Once the mounting is done you can inspect you specification like you would with any other mounted configuration. If you call kdb set
(or kdb meta-set
or anything else that calls kdbSet()
), however, specload
will verify that the modifications you made are compatible with the original specification. Currently this verification is very restrictive and doesn't allow a lot of changes that would be safe. This is because the necessary verification becomes very complex very quickly. For example adding opt/arg
is only safe, if opt
was also added by the user, because the application might rely on the default opt/arg=none
. See also Limitations.
Instead of loading the specification via stdin
/stdout
from another app, you can also instruct specload
to directly load a quickdump
file. This can be done by setting the file
config key instead of app
. The provided path must be absolute, same as an app
path.
Note: If file
is specified, app
will be ignored.
This assumes you compiled the file testapp.c
and it is available as the executable testapp
in the current folder.
Or in direct file mode:
description
or opt/help
default
type
noresolver
or another resolver that always calls the storage plugin. To work around this limitation, specload
prefixes relative paths with KDB_DB_SPEC
before passing the path on to quickdump
. This means that your overlay files will be stored in the same directory as any other spec
configurations.