Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ENV and Java Props substitution while reading file #28

Open
rickalm opened this issue Jul 12, 2017 · 4 comments
Open

Allow ENV and Java Props substitution while reading file #28

rickalm opened this issue Jul 12, 2017 · 4 comments
Labels
yaml Issue related to YAML format backend

Comments

@rickalm
Copy link

rickalm commented Jul 12, 2017

I'm looking for a feature similar to Spring, HandleBar, etc that would allow me to create a yaml (or any format) file that includes a reference to system variables during read. Having to "pre-process" a file using templating tools before launching an application is cumbersome and error-prone vs having a standard by which variables can be defined by the user (vs the developer) when crafting the files and then merged into the content delivered to the application. I realize the request is "extending" the yaml, json, etc standard but the point of libraries such as Jackson is to help establish new standards.

example:

system:
   host: ${HOSTNAME:defaulthost}
   port: ${PORT:8080}

if you wanted to allow the control of the source (System ENV vs Java Property) you could use a syntax as follows.

system:
   port: ${ENV:PORT:8080}
   port: ${PROPERTY:PORT:8080}
@cowtowncoder
Copy link
Member

Ok, first of all, I think this issue [https://github.com/FasterXML/jackson-core/issues/355] is related, and covers some ideas I had for something like this.

I have been thinking about this a bit myself, and am bit torn. There are some challenges here, including:

  1. Security: if allowing inclusion of external resources
  2. Need to build, retain full tree if cross-refs needed
  3. API for Customizability: almost certainly needs to be configurable, changeable, as it is difficult to find specific notation/sources that works for everyone
  4. Escaping aspects (related to customizability/configurability)

For just requested things (1) and (2) may not be relevant but I thought I'll mention them since these tend to become issues soon, when expanding functionality.

So. My thinking is that exposing hook(s) would make most sense because it'd allow

  1. Support by multiple formats (despite textual formats sharing one repo, code-wise there is not that much sharing)
  2. Ability to implement different kinds of extensions, both for different sources and likely different configurations.

From this I am not sure how much (if any) default functionality should be provided: perhaps ability to include system properties and env variables could be bundled with jackson-core.

There are other possibilities too: instead of handling this at low-level within JsonParser it could conceivably go in databind, as something StringDeserializer could be configured to do.

@cowtowncoder
Copy link
Member

Bit torn here wrt whether to close, as it probably should bind at jackson-core -- however, this is not necessarily true, depending on implementation: replacement might be needed at lower level.
So leaving open since I know something like this is what many users would like to see.
Even if that would be separate pre-processor; but at least ensure that JsonParser with delegation would work with it.

@Stranger65536
Copy link

Seems still relevant for me. Got any updates?

@cowtowncoder
Copy link
Member

Nothing new to report. The standard OP is that when there are updates, they are added to the issue. Easier to see that way than having to ask for updates.

@cowtowncoder cowtowncoder changed the title ENV and Java Props substitution while reading file Allow ENV and Java Props substitution while reading file Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
yaml Issue related to YAML format backend
Projects
None yet
Development

No branches or pull requests

3 participants