spec is a special namespace that describes via metadata the semantics of individual keys.
Most importantly it:
- describes which keys are of interest to the application
- describes the metadata to be copied to every key
- describes how the cascading lookup works
- describes the mount points including the plugins needed for them
It is, however, not limited to this but can express any other key database semantics (new plugins might be necessary, though).
The most simple use is to enlist all keys that will be used by an application and maybe give a description for them (we use ini syntax in this document):
[mykey]
[folder/anotherkey]
description = set this key if you want another behaviorSo Keys in spec allow us to specify which keys are read by the application.
The description key will be copied (referred to) to folder/anotherkey of
any namespace, so that it can easily be accessed.
Other features are directly implemented in ksLookup.
When cascading keys (those starting with /) are used following features
are now available (in the metadata of respective spec-keys):
override/#: use these keys in favor of the key itself (note that#is the syntax for arrays, e.g.#0for the first element,#_10for the 11th and so on)namespace/#: instead of using all namespaces in the predefined order, one can specify which namespaces should be searched in which orderfallback/#: when no key was found in any of the (specified) namespaces thefallback-keys will be searcheddefault: this value will be used if nothing else was found
E.g.
[promise]
default=20
fallback/#0=/somewhere/else
namespace/#0=user- When this file is mounted to
spec:/sw/app/#0we specify, that for the key/sw/app/#0/promiseonly the namespaceusershould be used. - If this key was not found, but
/somewhere/elseis present, we will use this key instead. Thefallbacktechnique is very powerful: it allows us to have (recursive) links between applications. In the example above, the application is tricked in receiving e.g. the keyuser:/somewhere/elsewhenpromisewas not available. - The value
20will be used as default, even if no configuration file is found.
Note that the fallback, override and cascading works on key level, and not like most other systems have implemented, on configuration file level.
You can tag any key using the check metadata so that it will be validated.
For example:
[folder/anotherkey]
check/validation = abc.*
check/validation/message = def does not start with abcIn the spec namespace you can also specify mount points.
First you need the metakey mountpoint and a configuration file name.
Otherwise, it basically works in the same way as the contracts
in plugins using infos and config:
[]
mountpoint=file.abc
config/plugin/code/escape = 40
config/plugin/lua#abc/script = abc_storage.lua
infos/author = Markus Raab
infos/needs = resolver_abc rename code lua#abc
infos/recommends = hexcode