question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should Config.getValue() to support variable replacement

See original GitHub issue

To address the issue #118, we have this PR #392 introducing a way on variable replacement.

In the class ConfigAccessorBuilder.evaluateVariable(boolean evaluateVariables), we would like to suggest the evaluateVariable is on by default.

However, the above only impacts the variable values obtained via ConfigAccess. In ConfigProperty annotation, we also introduced a property evaluateVariables with the default value of true.

Base on this, it might make sense to support evaluateVaribles by default with Config.getValue(). Basically, if a config contains a variable replacement, the variable will be evaluated.

server.host=localhost
server.port=9080
server.url=http://${server.host}:${server.port}

If this issue is accepted, a backward incompatible change will be introduced. This will lead MP Config release to bump major version.

when calling config.getValue(server.url, String.class) will return

http://localhost:9080

If this issue is accepted, a backward incompatible change will be introduced. Hence, this issue will lead MP Config release to bump major version.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
radcortezcommented, Mar 31, 2020

There is a final interceptor in the chain that performs the regular lookup. So, if the property doesn’t exist, you get the exception.

0reactions
radcortezcommented, Mar 31, 2020

The same thing. The final chain will retrieve the raw value, but when going up the chain, that value can be modified by any interceptor. Something like:

Chain 
  Expand
    GetRawValue
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration in ASP.NET Core - Microsoft Learn
If a configuration value must be guaranteed, see GetValue. The preceding example only reads strings and doesn't support a default value.
Read more >
98 - Stack Overflow
In short, no, there's no variable interpolation within an application configuration. You have two options. You could roll your own to substitute variables...
Read more >
How to read configuration values in ASP.NET Core
Following the example, an environment variable MySettings__ASetting will change the value of ASetting read from the appsettings.json file.
Read more >
Overwriting configuration values with environment variable in ...
Using environment specific variables to overwrite configuration values in ASP.NET Core.
Read more >
Environment Variables and Configuration in ASP.NET Core ...
Alternative could be to use the new attribute TargetFrameworkAttribute . This attribute gets added by the compiler and might not exist all the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found