Comments (9)
my current work around is custom url hander with extra parser:
include url("config:/${user.home}/.service/secret.properties")
this feels very wrong :-)
from config.
you have to write code to do that right now (though you could just parse a global and per user file directly instead of using includes, then merge with withFallback)
one issue is that currently all includes are loaded and then substitutions are resolved. so user.home may be defined inside the included file. supporting substitutions in includes would require an earlier resolve phase or something.
Another issue would be escaping (to expand user.home into a file URL it needs to be escaped; and differently depending on whether it's a query parameter or in the path or hostname I believe).
so the spec punts on this because the issues seem tricky and error-prone.
from config.
thanks for getting back;
re: "you have to write code to do that right now" - as you can see from all my issues here, I am trying to push back into typesafe.config as much as possible :-)
re: "so the spec punts on this because the issues seem tricky and error-prone" - would it be possible instead to permit some obvious default behavior and then scare people to death with log warnings or with documentation, instead of just denying this feature outright?
from config.
+1. This would be a great feature to have.
@havocp - personally I don't need to have ${user.home} substituted in the included file. I would just want, for example, environmental or system properties substitution in order to have flexibility with regard to included file. For example,
include "${STAGE}.conf"
where STAGE is an environment var for staging, production, test, or different environment-based settings. Then, deploys become super easy.
from config.
Another idea here would be to just have an environment variable equivalent for the config.file etc. system properties, perhaps. So you could set CONFIG_FILE=production.conf
or something like that.
I don't deny the utility I just don't quite know how to work out the details. Making ${}
mean something different (only env vars) in this context seems a little clunky. I don't see how to ignore the escaping issue, other than something lame like throwing an exception if the env var value contains anything that would need escaping in either URL or filename (on any platform) ... seems that list is long enough that people would encounter the exception in practice.
For the benefit of any bystanders who have not worked it out, the way you would solve this now is change your ConfigFactory.load()
to ConfigFactory.load(getenv("STAGE"))
and then in production.conf
start by doing include "application.conf"
from config.
Do you mean something like
include envvar("CONFIG_FILE") ?
That would work, I think.
-Evan
On Tue, Nov 13, 2012 at 12:38 PM, Havoc Pennington <[email protected]
wrote:
Another idea here would be to just have an environment variable equivalent
for the config.file etc. system properties, perhaps. So you could set
CONFIG_FILE=production.conf or something like that.I don't deny the utility I just don't quite know how to work out the
details. Making ${} mean something different (only env vars) in this
context seems a little clunky. I don't see how to ignore the escaping
issue, other than something lame like throwing an exception if the env var
value contains anything that would need escaping in either URL or filename
(on any platform) ... seems that list is long enough that people would
encounter the exception in practice.For the benefit of any bystanders who have not worked it out, the way you
would solve this now is change your ConfigFactory.load() to
ConfigFactory.load(getenv("STAGE")) and then in production.conf start by
doing include "application.conf"—
Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-10342537.
Because the people who are crazy enough to think they can change the world,
are the ones who do. -- Steve Jobs
from config.
I didn't mean syntax in the file itself, just that right now you can do "java -Dconfig.file=production.conf" and we could also support "CONFIG_FILE=production.conf java"
from config.
+1
This is something I assumed would work, and then when it didn't found the line in the spec. I know this has been dead for a while, but it would be really, really useful to be able to do simple substitution in the include line.
If the goal is to not overload the ${}
syntax, could we maybe add a new syntax that's only allowed in include lines,
%{}
or something?
from config.
This is the same as #122 I think which has more discussion, so I'll close this copy.
from config.
Related Issues (20)
- Find a StackOverflowError in config
- Find a StackOverflowError in config
- Find a StackOverflowError in config HOT 1
- underscore characters HOT 2
- Problems with com.typesafe/config and maven-dependency-plugin
- introduce method accepting a list of Objects to add a value
- Should this project be explicitly considered as deprecated/not supported? HOT 29
- Community fork? HOT 7
- Resolving Variable Substitutions Between Multiple Config HOT 1
- Something error when use com.typesafe.config API convert conf file to scala bean class
- withFallBack is not adding value if not present
- how to load the config with substitution details HOT 3
- Add info about which signing keys will be used for published artifacts.
- Cannot provide environment variables programmatically
- Rendering partially resolved appended array results in invalid configuration HOT 1
- Inconsistent behavior with Overflow/Underflow and Exceptions
- Regression in environment variable reading behavior HOT 2
- Add a module info HOT 6
- Question about `ConfigFactory.systemProperties()` on windows HOT 1
- When rendering unresolved ConfigConcatenation, whitespaces are erroneously included
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from config.