You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Robert Munteanu <ro...@apache.org> on 2020/08/20 21:03:34 UTC

[feature] Support for variables within variables?

Hi,

I noticed that variables are declared to be supported as part of
configurations and framework properties. In addition to that, I think
it would be very useful to replace them in variable values as well. It
would go well with providing reasonable defaults which can then be
overriden from the command line.

As an example, the following feature file:

{
  "variables": {
    "persistence.dir": "${sling.home}/persistence"
  },
  "configurations": {
    "com.foo.Persister": {
      "data": "${persistence.dir}"
    }
  }
}

will by default store data under launcher/persistence. However, I will
be able to redirect it anywhere with 

  -V persistence.dir=/data

Right now this isn't possible. Is this something that could be done
with the feature model?

Thanks,
Robert


Re: [feature] Support for variables within variables?

Posted by Robert Munteanu <ro...@apache.org>.
Thanks Carsten and David.

I created https://issues.apache.org/jira/browse/SLING-9684 for this.

Robert

On Mon, 2020-08-24 at 12:05 +0100, David Bosschaert wrote:
> HI all,
> 
> I also thought that recursively replacing variables was supported,
> but I
> tried it this morning quickly and apparently it's not.
> 
> Maybe create a JIRA for it?
> 
> Best regards,
> 
> David
> 
> On Mon, 24 Aug 2020 at 12:00, Carsten Ziegeler <cz...@apache.org>
> wrote:
> 
> > Hi Robert,
> > 
> > ok, thanks for clarifying. Yes, I agree it makes sense to support
> > a) as
> > well - and actually I'm a little bit surprised that it is not :)
> > I guess the only change needed is to recursively process
> > replacements of
> > variables which should be an easy fix
> > 
> > Regards
> > Carsten
> > 
> > Am 24.08.2020 um 12:55 schrieb Robert Munteanu:
> > > Hi Carsten,
> > > 
> > > On Sat, 2020-08-22 at 14:27 +0200, Carsten Ziegeler wrote:
> > > > Hi,
> > > > 
> > > > I guess it depends on how this support should look like. I
> > > > would
> > > > assume,
> > > > that "-V persistence.dir=/data" with your example works and
> > > > uses
> > > > "/data"
> > > > for the persistence. It will not use "${sling.home}/data" - not
> > > > sure
> > > > if
> > > > that was your intention?
> > > 
> > > I wanted to achieve both scenarios:
> > > 
> > > a) if no variable is passed from the CLI, persistence.dir should
> > > point
> > > to the resovled value of "sling.home" and "/persistence"
> > > b) if the variable value is overridden, the override should be
> > > used
> > > 
> > > b) works today, but a) does not. I tried to give my problem a bit
> > > more
> > > context with an exampe, but I guess I ended up creating confusion
> > > :-)
> > > 
> > > So basically I would like "${sling.home}/repository" to be
> > > properly
> > > resolved for variables like it is done for configurations for
> > > instance.
> > > 
> > > Thanks,
> > > Robert
> > > 
> > 
> > --
> > --
> > Carsten Ziegeler
> > Adobe Research Switzerland
> > cziegeler@apache.org
> > 


Re: [feature] Support for variables within variables?

Posted by David Bosschaert <da...@gmail.com>.
HI all,

I also thought that recursively replacing variables was supported, but I
tried it this morning quickly and apparently it's not.

Maybe create a JIRA for it?

Best regards,

David

On Mon, 24 Aug 2020 at 12:00, Carsten Ziegeler <cz...@apache.org> wrote:

> Hi Robert,
>
> ok, thanks for clarifying. Yes, I agree it makes sense to support a) as
> well - and actually I'm a little bit surprised that it is not :)
> I guess the only change needed is to recursively process replacements of
> variables which should be an easy fix
>
> Regards
> Carsten
>
> Am 24.08.2020 um 12:55 schrieb Robert Munteanu:
> > Hi Carsten,
> >
> > On Sat, 2020-08-22 at 14:27 +0200, Carsten Ziegeler wrote:
> >> Hi,
> >>
> >> I guess it depends on how this support should look like. I would
> >> assume,
> >> that "-V persistence.dir=/data" with your example works and uses
> >> "/data"
> >> for the persistence. It will not use "${sling.home}/data" - not sure
> >> if
> >> that was your intention?
> >
> > I wanted to achieve both scenarios:
> >
> > a) if no variable is passed from the CLI, persistence.dir should point
> > to the resovled value of "sling.home" and "/persistence"
> > b) if the variable value is overridden, the override should be used
> >
> > b) works today, but a) does not. I tried to give my problem a bit more
> > context with an exampe, but I guess I ended up creating confusion :-)
> >
> > So basically I would like "${sling.home}/repository" to be properly
> > resolved for variables like it is done for configurations for instance.
> >
> > Thanks,
> > Robert
> >
>
> --
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziegeler@apache.org
>

Re: [feature] Support for variables within variables?

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi Robert,

ok, thanks for clarifying. Yes, I agree it makes sense to support a) as 
well - and actually I'm a little bit surprised that it is not :)
I guess the only change needed is to recursively process replacements of 
variables which should be an easy fix

Regards
Carsten

Am 24.08.2020 um 12:55 schrieb Robert Munteanu:
> Hi Carsten,
> 
> On Sat, 2020-08-22 at 14:27 +0200, Carsten Ziegeler wrote:
>> Hi,
>>
>> I guess it depends on how this support should look like. I would
>> assume,
>> that "-V persistence.dir=/data" with your example works and uses
>> "/data"
>> for the persistence. It will not use "${sling.home}/data" - not sure
>> if
>> that was your intention?
> 
> I wanted to achieve both scenarios:
> 
> a) if no variable is passed from the CLI, persistence.dir should point
> to the resovled value of "sling.home" and "/persistence"
> b) if the variable value is overridden, the override should be used
> 
> b) works today, but a) does not. I tried to give my problem a bit more
> context with an exampe, but I guess I ended up creating confusion :-)
> 
> So basically I would like "${sling.home}/repository" to be properly
> resolved for variables like it is done for configurations for instance.
> 
> Thanks,
> Robert
> 

-- 
--
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org

Re: [feature] Support for variables within variables?

Posted by Robert Munteanu <ro...@apache.org>.
Hi Carsten,

On Sat, 2020-08-22 at 14:27 +0200, Carsten Ziegeler wrote:
> Hi,
> 
> I guess it depends on how this support should look like. I would
> assume, 
> that "-V persistence.dir=/data" with your example works and uses
> "/data" 
> for the persistence. It will not use "${sling.home}/data" - not sure
> if 
> that was your intention?

I wanted to achieve both scenarios:

a) if no variable is passed from the CLI, persistence.dir should point
to the resovled value of "sling.home" and "/persistence"
b) if the variable value is overridden, the override should be used

b) works today, but a) does not. I tried to give my problem a bit more
context with an exampe, but I guess I ended up creating confusion :-)

So basically I would like "${sling.home}/repository" to be properly
resolved for variables like it is done for configurations for instance.

Thanks,
Robert


Re: [feature] Support for variables within variables?

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,

I guess it depends on how this support should look like. I would assume, 
that "-V persistence.dir=/data" with your example works and uses "/data" 
for the persistence. It will not use "${sling.home}/data" - not sure if 
that was your intention?

Regards
Carsten

Am 20.08.2020 um 23:03 schrieb Robert Munteanu:
> Hi,
> 
> I noticed that variables are declared to be supported as part of
> configurations and framework properties. In addition to that, I think
> it would be very useful to replace them in variable values as well. It
> would go well with providing reasonable defaults which can then be
> overriden from the command line.
> 
> As an example, the following feature file:
> 
> {
>    "variables": {
>      "persistence.dir": "${sling.home}/persistence"
>    },
>    "configurations": {
>      "com.foo.Persister": {
>        "data": "${persistence.dir}"
>      }
>    }
> }
> 
> will by default store data under launcher/persistence. However, I will
> be able to redirect it anywhere with
> 
>    -V persistence.dir=/data
> 
> Right now this isn't possible. Is this something that could be done
> with the feature model?
> 
> Thanks,
> Robert
> 

-- 
--
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org