You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2019/11/09 16:58:18 UTC
A command like config:edit that will let you replace only some properties?
Is there a command similar to config:edit that will let you replace some
properties of an existing command instead of replacing all of them?
Whit config:edit you need to do a config:property-set for all of the
existing properties, of an existing config, even the properties that
haven't changed.
Thanks!
- Steinar
Re: A command like config:edit that will let you replace only some properties?
Posted by Christian Schneider <ch...@die-schneider.net>.
Be careful though. After each such command the config is provided to the
application. So if you want to change more than one property in one go then
the approach from JB is better.
Christian
Am So., 10. Nov. 2019 um 15:55 Uhr schrieb Steinar Bang <sb...@dod.no>:
> >>>>> Christian Schneider <ch...@die-schneider.net>:
>
> > If you only want to change a single property you can also do this in one
> > step:
> > config:property-set -p my.config foo bar
>
> Thanks! I will try this.
>
>
--
--
Christian Schneider
http://www.liquid-reality.de
Computer Scientist
http://www.adobe.com
Re: A command like config:edit that will let you replace only some properties?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Christian Schneider <ch...@die-schneider.net>:
> If you only want to change a single property you can also do this in one
> step:
> config:property-set -p my.config foo bar
Thanks! I will try this.
Re: A command like config:edit that will let you replace only some properties?
Posted by Christian Schneider <ch...@die-schneider.net>.
If you only want to change a single property you can also do this in one
step:
config:property-set -p my.config foo bar
Am So., 10. Nov. 2019 um 05:53 Uhr schrieb Jean-Baptiste Onofré <
jb@nanthrax.net>:
> Hi Steinar,
>
> If you do:
>
> karaf@root()> config:edit my.config
> karaf@root()> config:property-set foo bar
> karaf@root()> config:update
>
> only foo will be changed, other properties are kept.
>
> Not sure I follow what you mean.
>
> Regards
> JB
>
> On 09/11/2019 17:58, Steinar Bang wrote:
> > Is there a command similar to config:edit that will let you replace some
> > properties of an existing command instead of replacing all of them?
> >
> > Whit config:edit you need to do a config:property-set for all of the
> > existing properties, of an existing config, even the properties that
> > haven't changed.
> >
> > Thanks!
> >
> >
> > - Steinar
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
--
--
Christian Schneider
http://www.liquid-reality.de
Computer Scientist
http://www.adobe.com
Re: A command like config:edit that will let you replace only some properties?
Posted by Christian Schneider <ch...@die-schneider.net>.
Maybe it is related to the fact that the original configuration is a
factory config.
Perhaps you created a new non factory config that overrides the factory one.
Christian
Am Mo., 11. Nov. 2019 um 22:55 Uhr schrieb Steinar Bang <sb...@dod.no>:
> >>>>> Steinar Bang <sb...@dod.no>:
> >>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
>
> >> If you do:
>
> >> karaf@root()> config:edit my.config
> >> karaf@root()> config:property-set foo bar
> >> karaf@root()> config:update
>
> >> only foo will be changed, other properties are kept.
>
> >> Not sure I follow what you mean.
>
> > Hm... I thought that when I tried this last week the resulting file
> > only had those properties I had added with config:property-set,
> > ie. that the other properties had gone missing...?
>
> > Maybe I fooled myself while testing? I will try again and keep track
> > of what I'm doing...:-)
>
> Nope, I tried it again now, and it didn't work for me.
>
> Platform: karaf 4.2.7, openjdk 11, debian 10.1 "buster", amd64
>
> Here's what I did:
> 1. I installed my application using
> karaf@root()> feature:repo-add
> mvn:no.priv.bang.authservice/authservice/LATEST/xml/features
> Adding feature url
> mvn:no.priv.bang.authservice/authservice/LATEST/xml/features
> karaf@root()> feature:install user-admin-with-postgresql
> karaf@root()>
> 2. This created the following file in etc/
> -rw-r--r-- 1 sb sb 250 Nov 11 22:45
> org.ops4j.datasource-authservice-production.cfg
> 3. The content of the org.ops4j.datasource-authservice-production.cfg
> file is:
> osgi.jdbc.driver.name=PostgreSQL JDBC Driver
> dataSourceName=jdbc/authservice
> url=jdbc:postgresql:///authservice
> user=karaf
> password=karaf
> ops4j.preHook=authservicedb
> org.apache.karaf.features.configKey =
> org.ops4j.datasource-authservice-production
> 4. Then I tried replacing just the url property:
> karaf@root()> config:edit org.ops4j.datasource-authservice-production
> karaf@root()> config:property-set url "jdbc:postgresql:///ukelonn"
> karaf@root()> config:update
> karaf@root()>
> 5. The resulting file in the etc directory was much smaller
> -rw-r--r-- 1 sb sb 33 Nov 11 22:50
> org.ops4j.datasource-authservice-production.cfg
> 6. The updated file content is just the url setting
> url = jdbc:postgresql:///ukelonn
>
> Did I do something wrong? Or should I report this as a bug in karaf JIRA?
>
>
--
--
Christian Schneider
http://www.liquid-reality.de
Computer Scientist
http://www.adobe.com
Re: A command like config:edit that will let you replace only some properties?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
> The factory is org.ops4j.datasource, the pid is "foo".
Hm... I've read the docs but I don't understand how this is supposed to
work...?
Perhaps like this...?
karaf@root()> config:edit --factory --alias authservice-production org.ops4j.datasource
karaf@root()> config:property-set url "jdbc:postgresql:///ukelonn"
karaf@root()> config:update
karaf@root()>
Nope... that just overwrote the original config, so still no luck.
-rw------- 1 sb sb 33 Nov 12 19:26 org.ops4j.datasource-authservice-production-18185463578817080582.cfg
-rw-r--r-- 1 sb sb 33 Nov 12 21:44 org.ops4j.datasource-authservice-production.cfg
-rw-r--r-- 1 sb sb 208 Nov 12 19:24 org.ops4j.datasource-authservice-test.cfg
(Basically what I'm trying to do is to get the simplest possible config
commands to change the JDBC credentials of a pax-jdbc-config
configuration, while leaving the rest of the configuration in place.)
Re: A command like config:edit that will let you replace only some
properties?
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
The factory is org.ops4j.datasource, the pid is "foo".
Regards
JB
On 12/11/2019 19:41, Steinar Bang wrote:
>>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
>
>> Hi,
>> That's because it's a factory, not a config.
>
>> You have to use config:edit --factory.
>
> Hm... this was kind of strange...?
>
> I did this:
> karaf@root()> config:edit --factory org.ops4j.datasource-authservice-production
> karaf@root()> config:property-set url "jdbc:postgresql:///ukelonn"
> karaf@root()> config:update
> karaf@root()>
>
> And the result was this:
> -rw------- 1 sb sb 33 Nov 12 19:26 org.ops4j.datasource-authservice-production-18185463578817080582.cfg
> -rw-r--r-- 1 sb sb 250 Nov 12 19:24 org.ops4j.datasource-authservice-production.cfg
> -rw-r--r-- 1 sb sb 208 Nov 12 19:24 org.ops4j.datasource-authservice-test.cfg
>
> The edited property is in the separate file ie. the one with
> "-18185463578817080582".
>
> (I thought maybe karaf would combine the two files into one config. But
> unfortunately, it doesn't seem to work that way...?)
>
> The data I see in the application is the data from the database it
> connects to at default, and not the database I'm trying to set with the
> URL (the database is a user database so I verify by trying to log in
> with specific users).
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: A command like config:edit that will let you replace only some properties?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
> Hi,
> That's because it's a factory, not a config.
> You have to use config:edit --factory.
Hm... this was kind of strange...?
I did this:
karaf@root()> config:edit --factory org.ops4j.datasource-authservice-production
karaf@root()> config:property-set url "jdbc:postgresql:///ukelonn"
karaf@root()> config:update
karaf@root()>
And the result was this:
-rw------- 1 sb sb 33 Nov 12 19:26 org.ops4j.datasource-authservice-production-18185463578817080582.cfg
-rw-r--r-- 1 sb sb 250 Nov 12 19:24 org.ops4j.datasource-authservice-production.cfg
-rw-r--r-- 1 sb sb 208 Nov 12 19:24 org.ops4j.datasource-authservice-test.cfg
The edited property is in the separate file ie. the one with
"-18185463578817080582".
(I thought maybe karaf would combine the two files into one config. But
unfortunately, it doesn't seem to work that way...?)
The data I see in the application is the data from the database it
connects to at default, and not the database I'm trying to set with the
URL (the database is a user database so I verify by trying to log in
with specific users).
Re: A command like config:edit that will let you replace only some
properties?
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
That's because it's a factory, not a config.
You have to use config:edit --factory.
Regards
JB
On 11/11/2019 22:57, Steinar Bang wrote:
>>>>>> Steinar Bang <sb...@dod.no>:
>>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
>
>>> If you do:
>
>>> karaf@root()> config:edit my.config
>>> karaf@root()> config:property-set foo bar
>>> karaf@root()> config:update
>
>>> only foo will be changed, other properties are kept.
>
>>> Not sure I follow what you mean.
>
>> Hm... I thought that when I tried this last week the resulting file
>> only had those properties I had added with config:property-set,
>> ie. that the other properties had gone missing...?
>
>> Maybe I fooled myself while testing? I will try again and keep track
>> of what I'm doing...:-)
>
> Nope, I tried it again now, and it didn't work for me.
>
> Platform: karaf 4.2.7, openjdk 11, debian 10.1 "buster", amd64
>
> Here's what I did:
> 1. I installed my application using
> karaf@root()> feature:repo-add mvn:no.priv.bang.authservice/authservice/LATEST/xml/features
> Adding feature url mvn:no.priv.bang.authservice/authservice/LATEST/xml/features
> karaf@root()> feature:install user-admin-with-postgresql
> karaf@root()>
> 2. This created the following file in etc/
> -rw-r--r-- 1 sb sb 250 Nov 11 22:45 org.ops4j.datasource-authservice-production.cfg
> 3. The content of the org.ops4j.datasource-authservice-production.cfg file is:
> osgi.jdbc.driver.name=PostgreSQL JDBC Driver
> dataSourceName=jdbc/authservice
> url=jdbc:postgresql:///authservice
> user=karaf
> password=karaf
> ops4j.preHook=authservicedb
> org.apache.karaf.features.configKey = org.ops4j.datasource-authservice-production
> 4. Then I tried replacing just the url property:
> karaf@root()> config:edit org.ops4j.datasource-authservice-production
> karaf@root()> config:property-set url "jdbc:postgresql:///ukelonn"
> karaf@root()> config:update
> karaf@root()>
> 5. The resulting file in the etc directory was much smaller
> -rw-r--r-- 1 sb sb 33 Nov 11 22:50 org.ops4j.datasource-authservice-production.cfg
> 6. The updated file content is just the url setting
> url = jdbc:postgresql:///ukelonn
>
> Did I do something wrong? Or should I report this as a bug in karaf JIRA?
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: A command like config:edit that will let you replace only some properties?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
>> If you do:
>> karaf@root()> config:edit my.config
>> karaf@root()> config:property-set foo bar
>> karaf@root()> config:update
>> only foo will be changed, other properties are kept.
>> Not sure I follow what you mean.
> Hm... I thought that when I tried this last week the resulting file
> only had those properties I had added with config:property-set,
> ie. that the other properties had gone missing...?
> Maybe I fooled myself while testing? I will try again and keep track
> of what I'm doing...:-)
Nope, I tried it again now, and it didn't work for me.
Platform: karaf 4.2.7, openjdk 11, debian 10.1 "buster", amd64
Here's what I did:
1. I installed my application using
karaf@root()> feature:repo-add mvn:no.priv.bang.authservice/authservice/LATEST/xml/features
Adding feature url mvn:no.priv.bang.authservice/authservice/LATEST/xml/features
karaf@root()> feature:install user-admin-with-postgresql
karaf@root()>
2. This created the following file in etc/
-rw-r--r-- 1 sb sb 250 Nov 11 22:45 org.ops4j.datasource-authservice-production.cfg
3. The content of the org.ops4j.datasource-authservice-production.cfg file is:
osgi.jdbc.driver.name=PostgreSQL JDBC Driver
dataSourceName=jdbc/authservice
url=jdbc:postgresql:///authservice
user=karaf
password=karaf
ops4j.preHook=authservicedb
org.apache.karaf.features.configKey = org.ops4j.datasource-authservice-production
4. Then I tried replacing just the url property:
karaf@root()> config:edit org.ops4j.datasource-authservice-production
karaf@root()> config:property-set url "jdbc:postgresql:///ukelonn"
karaf@root()> config:update
karaf@root()>
5. The resulting file in the etc directory was much smaller
-rw-r--r-- 1 sb sb 33 Nov 11 22:50 org.ops4j.datasource-authservice-production.cfg
6. The updated file content is just the url setting
url = jdbc:postgresql:///ukelonn
Did I do something wrong? Or should I report this as a bug in karaf JIRA?
Re: A command like config:edit that will let you replace only some properties?
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
> Hi Steinar,
> If you do:
> karaf@root()> config:edit my.config
> karaf@root()> config:property-set foo bar
> karaf@root()> config:update
> only foo will be changed, other properties are kept.
> Not sure I follow what you mean.
Hm... I thought that when I tried this last week the resulting file only
had those properties I had added with config:property-set, ie. that the
other properties had gone missing...?
Maybe I fooled myself while testing? I will try again and keep track of
what I'm doing...:-)
Re: A command like config:edit that will let you replace only some
properties?
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Steinar,
If you do:
karaf@root()> config:edit my.config
karaf@root()> config:property-set foo bar
karaf@root()> config:update
only foo will be changed, other properties are kept.
Not sure I follow what you mean.
Regards
JB
On 09/11/2019 17:58, Steinar Bang wrote:
> Is there a command similar to config:edit that will let you replace some
> properties of an existing command instead of replacing all of them?
>
> Whit config:edit you need to do a config:property-set for all of the
> existing properties, of an existing config, even the properties that
> haven't changed.
>
> Thanks!
>
>
> - Steinar
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com