MP Config: Ability to specify root config source directory
Overview
The MicroProfile Config with SmallRye subsystem currently supports configuration of several types of Config Sources. One of these allows you to specify a directory, wherein each file is used as a config property. The file name is the name of the property, and the contents of the file is the value of the property.
This is useful on OpenShift where ConfigMaps, the ServiceBinding opertator (and probably other things) expose config via this mechanism for use in applications.
This RFE is about enhancing the subsystem to allow specifying a root directory, of which the top-level directories under it will appear as Config Sources. The motivation is that each 'thing' on OpenShift installs their config under a root directory. e.g. in the ServiceBinding operator case this is under the /bindings
directory and ConfigMaps are installed under /etc/config
.
So if you have two ConfigMaps called cfg-a
and cfg-b
, their respective directories containing the config files will be /etc/config/cfg-a
and /etc/config/cfg-b
. At present this means we need to add two Config Source entries to the subsystem, and we need to know the exact names of both, in order to pick these up.
While we will keep the existing mechanism, the proposal is to be able to specify a directory as a root for configuration, and that each top level directory becomes a Config Source as with the previous mechanism.
This has the advantage of only needing to specify one Config Source root in order to pick up all ConfigMaps, one to pick up all ServiceBinding configs, and so on. An added bonus is not needing to know the exact names of the configuration directories, which are in some cases autogenerated.
From the previous example, specifying /etc/config
as a root ConfigSource will pick up the configs from both the /etc/config/cfg-a
and /etc/config/cfg-b
directories.
Issue Metadata
Dev Contacts
QE Contacts
Testing By
-
Engineering
-
QE
Affected Projects or Components
All code changes are in the MicroProfile Config with SmallRye subsystem in WildFly.
Other Interested Projects
N/A
Relevant Installation Types
-
Traditional standalone server (unzipped or provisioned by Galleon)
-
Managed domain
-
OpenShift s2i
-
Bootable jar
Requirements
Hard Requirements
-
The
dir
complex attribute of the/subsystem=microprofile-config-smallrye/config-source=*
resource will be extended to have an additionalroot
nested attribute.-
The default value of the
root
nested attribute isfalse
, giving the legacy behaviour -
If
root=true
, the directory is treated as a root directory for ConfigSources
-
-
Within a root directory for ConfigSource:
-
Files contained directly within the root directory are ignored and are not used for config
-
Each top-level directory is treated as a ConfigSource
-
Files within each top-level directory under the root directory are treated as a config entry
-
Only top-level directories are considered, directories nested within those are ignored
-
By default the ConfigSources for each top level directory get the
ordinal
of the/subsystem=microprofile-config-smallrye/config-source=*
resource used to add the root directory-
If the top-level directory contains a
config_ordinal
file, the value specified in there will override the defaultordinal
-
-
If two top-level directories with the same
ordinal
contain the same entry, their names are sorted according to standard Java sorting rules and the first one is used
-
Nice-to-Have Requirements
N/A
Non-Requirements
-
As mentioned previously, in Hard Requirements, only top level directories under a ConfigSource root directory will be considered as ConfigSources. We don’t check nested folders.
-
No attempts will be made to avoid having multiple ConfigSources defined in the subsystem referencing the same directories
Backwards Compatibility
The feature is backward compatible.
Security Considerations
None. The feature doesn’t expose anything which would not be possible with what is there today.
Test Plan
The WildFly testsuite will be enhanced to test the new functionality. Package org.wildfly.test.integration.microprofile.config.smallrye.management.config_source.from_root_dir
in testsuite/integration/microprofile
.
Community Documentation
Community documentation will be done as part of the pull request to WildFly that contains the implementation.
Release Note Content
The MicroProfile Config with SmallRye subsystem now supports using a directory as a root for several MicroProfile ConfigSource directories, removing the need to define several ConfigSource directories if they share the same parent directory.