You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by maggu2810 <gi...@git.apache.org> on 2015/10/06 11:05:36 UTC

[GitHub] karaf pull request: [KARAF-3262] feature configfile: substitution

GitHub user maggu2810 opened a pull request:

    https://github.com/apache/karaf/pull/83

    [KARAF-3262] feature configfile: substitution

    Add variable substitution to the configfile finalname of a feature.
    
    Old situation:
    * All ${...} are removed from the config file name and not used.
    * The given path is prefixed with / relative to ${karaf.base} on
      installation
    
    New behaviour:
    * If the final name starts not with "${", the path is prefixed with /
      relative to karaf.base.
    * All ${...} are substituted.
    * If the substituted string starts with an variable (the first one
    * has
      been unknown), it is prefixed with / relative to karaf.base.
    * All unknown variables are removed from the resulting final name.
    
    Signed-off-by: Markus Rathgeb <ma...@gmail.com>
    
    Here some testing:
    ```java
    public static void main(String[] args) {
        System.setProperty("karaf.base", "/tmp/karaf.base");
        System.setProperty("foo1", "/foo1");
        
        final String[] finalNames = {
                "etc/test.cfg",
                "/etc/test.cfg",
                "${karaf.base}/etc/test.cfg",
                "etc/${foo1}/test.cfg",
                "${foo1}/test.cfg",
                "etc${foo2}/${foo2}test.cfg",
                "${foo2}/etc/test.cfg${foo2}",
                "${karaf.base}${foo2}/etc/test.cfg",
                "etc${}/${foo1}/test.cfg",
                "${foo1}/test.cfg",
        };
        
        for (final String finalName : finalNames) {
            System.out.println(finalName + " => " + substFinalName(finalName));
        }
    }
    ```
    
    Result (the exception is catched, kept logging):
    ```java
    etc/test.cfg => /tmp/karaf.base/etc/test.cfg
    /etc/test.cfg => /tmp/karaf.base//etc/test.cfg
    ${karaf.base}/etc/test.cfg => /tmp/karaf.base/etc/test.cfg
    etc/${foo1}/test.cfg => /tmp/karaf.base/etc//foo1/test.cfg
    ${foo1}/test.cfg => /foo1/test.cfg
    etc${foo2}/${foo2}test.cfg => /tmp/karaf.base/etc/test.cfg
    ${foo2}/etc/test.cfg${foo2} => /tmp/karaf.base//etc/test.cfg
    ${karaf.base}${foo2}/etc/test.cfg => /tmp/karaf.base/etc/test.cfg
    etc${}/${foo1}/test.cfg => /tmp/karaf.base/etc//test.cfg
    Oct 06, 2015 10:57:43 AM org.apache.karaf.features.internal.service.FeatureConfigInstaller substFinalName
    WARNING: Skip substitution of variables of configuration final name (etc${}/${foo1}/test.cfg).
    java.lang.IllegalArgumentException: recursive variable reference: 
    	at org.apache.felix.utils.properties.InterpolationHelper.doSubstVars(InterpolationHelper.java:319)
    	at org.apache.felix.utils.properties.InterpolationHelper.substVars(InterpolationHelper.java:235)
    	at org.apache.karaf.features.internal.service.FeatureConfigInstaller.substFinalName(FeatureConfigInstaller.java:180)
    	at org.apache.karaf.features.internal.service.FeatureConfigInstaller.main(FeatureConfigInstaller.java:157)
    
    ${foo1}/test.cfg => /foo1/test.cfg
    ```

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/maggu2810/karaf feature-config-path

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/karaf/pull/83.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #83
    
----
commit 032f3e75e99b4d1523b8aba20e08072b4d291cff
Author: Markus Rathgeb <ma...@gmail.com>
Date:   2015-10-05T14:56:19Z

    [KARAF-3262] feature configfile: substitution
    
    Add variable substitution to the configfile finalname of a feature.
    
    Old situation:
    * All ${...} are removed from the config file name and not used.
    * The given path is prefixed with / relative to ${karaf.base} on
      installation
    
    New behaviour:
    * If the final name starts not with "${", the path is prefixed with /
      relative to karaf.base.
    * All ${...} are substituted.
    * If the substituted string starts with an variable (the first one
    * has
      been unknown), it is prefixed with / relative to karaf.base.
    * All unknown variables are removed from the resulting final name.
    
    Signed-off-by: Markus Rathgeb <ma...@gmail.com>

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] karaf pull request: [KARAF-3262] feature configfile: substitution

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/karaf/pull/83


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---