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

Variables expansion? #119

Open
lightglitch opened this issue Oct 15, 2015 · 3 comments
Open

Variables expansion? #119

lightglitch opened this issue Oct 15, 2015 · 3 comments

Comments

@lightglitch
Copy link

Support for ${key} or similar format in properties values and automatic expansion before getting the final value.

@pdalpra
Copy link

pdalpra commented Mar 31, 2016

This would really useful, even behind a configuration option disabled by default.
Bonus, implementation is quite easy, thanks to os.ExpandEnv.

@eloo
Copy link

eloo commented Aug 31, 2018

yes would be really great if this could be included..

for now i us e a simply workaround like this

	for _, k := range viper.AllKeys() {
		viper.Set(k, os.ExpandEnv(viper.GetString(k)))
	}

okay.. this is buggy...
now i'm trying the following at the moment

func expandConfig() {
	for _, k := range viper.AllKeys() {
		value := viper.Get(k)
		if _, ok := value.(string); ok {
			viper.Set(k, os.ExpandEnv(viper.GetString(k)))
		}
	}
}

@filinvadim
Copy link

@eloo thank you!

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

4 participants