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

Make expansion of expressions optional per load #5

Closed
emicklei opened this issue Jun 23, 2015 · 4 comments
Closed

Make expansion of expressions optional per load #5

emicklei opened this issue Jun 23, 2015 · 4 comments
Milestone

Comments

@emicklei
Copy link

As part of our configuration service, we need to store configurations as is in key-value records without substituing the ${..} expressions. Application that retrieve properties from this service will do the expansions.

My suggestion is to provide another Load function that takes the extra boolean parameter expandExpressions

@emicklei
Copy link
Author

Another solution might be to provide a Load method on Properties itself as this struct has a Prefix,Postfix pair that can be changed to prevent expansion. (properties.go:596)

@magiconair
Copy link
Owner

Properties expands on Get() and checks for circular references on both Get() and Set(). I've added a DisableExpansion flag which you can set to true after Load which will disable both the expansion and the circular reference check. Please note that you can shoot yourself in the foot now by creating a Properties object with circular references which explodes when being used by your service. Also, you can construct a Properties object with circular references and then enable the circular reference check again. The next Get() of such a reference will then fail.

Let me know what you think. The change is in https:/magiconair/properties/tree/issue5

@emicklei
Copy link
Author

Thank you for the quick response and implementation.
I had the wrong assumption that expansion is part of the Load process.
The DisableExpansion will work for our case.

@magiconair
Copy link
Owner

Then I'll merge it

@magiconair magiconair added this to the 1.5.4 milestone Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants