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.

Define a mapping rule from config property name to environment variable

See original GitHub issue

@Emily-Jiang commented on Wed Nov 15 2017

As the name of environment variable can only use alphabets and _ , it is difficult to override some config properties as environment variables.

e.g. com.acme.me=“blah”

This property cannot be specified as environment variable. How about to directly translate . to _ for the corresponding environment variables.

com.acme.me -> com_acme_me In this way, this property can be defined or override in environment variable.


@struberg commented on Wed Nov 15 2017

+1 to add it explicitly!

been there, done that 2 years ago 😉

https://issues.apache.org/jira/browse/DELTASPIKE-1090 https://github.com/apache/deltaspike/blame/master/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/EnvironmentPropertyConfigSource.java#L55


@kazumura commented on Wed Nov 15 2017

That means you cannot use ‘_’ as a property key.

e.g.
 foo._bar
 foo_.bar
 foo..bar
 foo__bar

 Are all these same ?

I prefer to add a flag to specify auto converting or not.


@struberg commented on Wed Nov 15 2017

yes, you could not distinguish those in the EnvironmentConfigSource, but everywhere else. In practice it’s not really an issue.

We first catched this issue when integrating Docker where ENV=… can also not contain any dots via scripts.


@kazumura commented on Wed Nov 15 2017

I agree the auto converting as the default behavior.

But there are some people who already use ‘’ as the keys. My point is, should we provide them an option to use this feature or not? I don’t know how many people already use '’. May not major.


@TFaga commented on Wed Nov 15 2017

+1 for . -> _ as well. We’re also doing this in KumuluzEE.

Another question though. How about other common characters that are used but not typically found or allowed in environemnt variable key names (like -, [, ], …)? While there’s not much that can be done about those examples, perhaps at least a note somewhere that certain characters may be problematic to use from the environment or that it’s up to the implementation how it’s additionally handled?


@Emily-Jiang commented on Thu Nov 16 2017

Yes, I think we should just pick the commonly used one like “.” for the reason of @kazumura brought up, which will create overlapping. We can clearly document this as you said@TFaga !


@lilian-benoit commented on Wed Nov 29 2017

+1 for . -> _ as well. Usually, we use _ for environment variable.

is property name case-sensitive ? In fact, we have COM_ACME_ME as environment variable.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
OndroMihcommented, Nov 30, 2017

I suggest to require that environment variables with underscores are mapped to multiple keys. It should be a problem if e.g. a variable COM_ACME_ME represents all of these keys:

  • COM_ACME_ME
  • com_acme_me
  • com.acme.me

All of them with the same value. There’s almost no chance that an application would want to distinguish between these keys and would expect that there are different values under those keys.

0reactions
smoyer64commented, Feb 15, 2018

Dashes in Java property names are something else the mapping rule will have to consider (and are somewhat common in Java property names). I’ve created https://github.com/eclipse/ConfigJSR/issues/53 since the microprofile-config team seems to be aligning this specification with the broader specification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

24. Externalized Configuration
You can use properties files, YAML files, environment variables and command-line arguments to externalize configuration. Property values can be injected ...
Read more >
Configuration Reference Guide
In this reference guide we're going to describe various aspects of Quarkus configuration. A Quarkus application and Quarkus itself (core and extensions) are ......
Read more >
Configure a Pod to Use a ConfigMap
ConfigMaps are the Kubernetes way to inject application pods with configuration data.
Read more >
Configuration for MicroProfile
If the prefix is absent, the field x maps to the property name x . ... from an environment variable, the following rules...
Read more >
Environment Variables - SmallRye Config
By default, the underscore _ of an Environment Variable name always maps to a dot . . If the property name contains a...
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