This is an automated email from the ASF dual-hosted git repository. jbonofre pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/main by this push: new b347362f34 [KARAF-7608] Support factory configuration override with environment variable new 47bd65b36c Merge pull request #1698 from jbonofre/KARAF-7608 b347362f34 is described below commit b347362f3452b1cf7f4f30b6847669daf3f9e74c Author: Jean-Baptiste Onofré <jbono...@apache.org> AuthorDate: Mon Dec 19 07:54:59 2022 +0100 [KARAF-7608] Support factory configuration override with environment variable --- .../org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java | 4 ++-- manual/src/main/asciidoc/user-guide/configuration.adoc | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config/src/main/java/org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java b/config/src/main/java/org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java index 816e5af944..4adb316d15 100644 --- a/config/src/main/java/org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java +++ b/config/src/main/java/org/apache/karaf/config/core/impl/KarafConfigurationPlugin.java @@ -33,8 +33,8 @@ public class KarafConfigurationPlugin implements ConfigurationPlugin { final Object pid = properties.get(Constants.SERVICE_PID); for (Enumeration<String> keys = properties.keys(); keys.hasMoreElements(); ) { String key = keys.nextElement(); - // looking for env variable and system property matching key (pid.key).toUpperCase().replace('.', '_') - String env = (pid + "." + key).toUpperCase().replaceAll("\\.", "_"); + // looking for env variable and system property matching key (pid.key).toUpperCase().replace('.', '_').replace('-', '_').replace('~', '_') + String env = (pid + "." + key).toUpperCase().replaceAll("\\.", "_").replace("-", "_").replace("~", "_"); String sys = pid + "." + key; if (System.getenv(env) != null) { String value = InterpolationHelper.substVars(System.getenv(env), null,null, convertDictionaryToMap(properties)); diff --git a/manual/src/main/asciidoc/user-guide/configuration.adoc b/manual/src/main/asciidoc/user-guide/configuration.adoc index 7143c8168e..df7dae084c 100644 --- a/manual/src/main/asciidoc/user-guide/configuration.adoc +++ b/manual/src/main/asciidoc/user-guide/configuration.adoc @@ -44,6 +44,11 @@ Please note that making this functionality requires OSGi configuration object to It is not possible to override non-existing properties or create new entries in configuration based on environment variable. ==== +[NOTE] +==== +Environment variable matches configuration pid with all `.`, `-`, `~` replaced by `_`. +It means that you can override `org.apache.felix.fileinstall~deploy` configuration with `ORG_APACHE_FELIX_FILEINSTAL_DEPLOY` environment variable. +==== It's possible to "append" a new value based on the content of a configuration property. For instance, you want to add a new features repository to the default value (define the `etc/org.apache.karaf.features.cfg` config file `featuresRepositories` property.