[ 
https://issues.apache.org/jira/browse/KARAF-3262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944757#comment-14944757
 ] 

ASF GitHub Bot commented on KARAF-3262:
---------------------------------------

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 <maggu2...@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 <maggu2...@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 <maggu2...@gmail.com>

----


> Being able to use ${karaf.etc} in feature <configfile/> element
> ---------------------------------------------------------------
>
>                 Key: KARAF-3262
>                 URL: https://issues.apache.org/jira/browse/KARAF-3262
>             Project: Karaf
>          Issue Type: Improvement
>          Components: karaf-feature
>            Reporter: Jean-Baptiste Onofré
>            Assignee: Jean-Baptiste Onofré
>
> The <configfile/> element in a feature accepts a finalname attribute to 
> define where the configfile has to be copied.
> However, finalname is relative to ${karaf.base}, whereas it should be able to 
> use ${karaf.etc} (and so relative to ${karaf.etc}).
> In order to be backward compatible, if finalname starts with /etc/ it will be 
> relative to ${karaf.base}, else it will be related to ${karaf.etc}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to