adorsys / keycloak-config-cli

Import YAML/JSON-formatted configuration files into Keycloak - Configuration as Code for Keycloak.
Apache License 2.0
714 stars 134 forks source link

Properties from files does not seem to be working. #634

Closed ianwallen closed 2 years ago

ianwallen commented 2 years ago

Current Behavior

I'm trying to use the configtree as indicated in the reame.md documentation. (https://github.com/adorsys/keycloak-config-cli#configure-properties-values-through-files)

I attempted to create a property replacement using something like $(test.configtree.value) and I can verify that the property is loaded correctly however it does not seem to work.

Expected Behavior

I expect that the regular properties could be used in the substitution logic but it seem to generate errors.

I looked for a sample that used regular properties but I cannot find any in the documentation. I only found system properties usage.

Steps To Reproduce

I modified one of the unit test to reproduce the issue. The changes are located in the following commit.

https://github.com/ianwallen/keycloak-config-cli/commit/ac0ff495099e6ad0122316ca5539f2bfcc963526

Environment

Anything else?

If it is identified that I'm doing the logic incorrectly then I would suggest that a unit test or other example be created to show how the properties from files is supposed to work.

jkroepke commented 2 years ago

Hi,

there is already a unit test to test system properties. If you take a look at https://github.com/adorsys/keycloak-config-cli#variable-substitution, you may see that

System Property:       $(sys:user.dir)

have a prefix sys. $(sys:test.configtree.value) should work while $(test.configtree.value) not.

Edit:

I'm not sure, if spring properties are exposed as system property. In case if not, that could be reason.

jkroepke commented 2 years ago

Thanks you test case. The library used by keycloak config cli had no access to the spring context. I added a custom lookup function which resolves properties from spring environment.

If possible, please test #635