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

Support for loading from a directory tree where each file represents one setting #94

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

flugeldoo
Copy link

I've added a ReadDir method that loads configuration from a directory tree. Each file in the tree is treated as a single setting: the filename is the key, and the file contents are the value. E.g.:

/config -- name (file contents: Skadi)
      |
      +--- debug (file contents: true)
      |
      +--- service -- port (file contents: 1234)
                 |
                 +--- ip (file contents: 1.2.3.4)

Calling ReadDir("/config") would produce the following configuration:

name=Skadi
debug=true
service.port=1234
service.ip=1.2.3.4

No idea if you'll find this useful, but I thought I'd send it your way nonetheless.

@flugeldoo
Copy link
Author

Actually this should use discovery instead of reading from a given directory. Instead of ReadDir("/config") you'd do:

AddConfigPath("/config")
ReadInConfigDir()

@kzvezdarov
Copy link
Contributor

What use case does this satisfy?

@philk
Copy link

philk commented Jul 16, 2015

We're looking for this because of the way kubernetes handles secret distribution. Basically it mounts a volume into the container with the secrets exposed as files.

@kzvezdarov
Copy link
Contributor

Sounds good. There is an in-progress PR for supporting cascading config files, it might be good to coordinate the two though I am not sure yet how (and if ) it would make sense to combine them.

@flugeldoo
Copy link
Author

Support for cascading configs will be great, especially since it means we could use kubernetes volumes for secrets, and JSON/YAML for other config. I'll take a look at that diff and see how the two might interact.

@spf13
Copy link
Owner

spf13 commented Jul 16, 2015

If we can marry these two together I think we’ve got an extremely powerful and useful tool. Just need to be mindful of how this interacts with nesting.

@flugeldoo
Copy link
Author

I've merged the changes from wrobbins cascading configs branch. I'd like to take a closer look before claiming any of this still works though.

At some point it might be nice to reorganize viper.go too—it's getting pretty long—but not in this branch.

@spf13
Copy link
Owner

spf13 commented Jul 30, 2015

@niccaluim Do you think this is ready for review/merge?

@spf13
Copy link
Owner

spf13 commented Sep 8, 2015

@niccaluim PING :)

@cynipe
Copy link

cynipe commented Jan 18, 2016

any progress on this?

@spf13
Copy link
Owner

spf13 commented Jan 18, 2016

Until the CLA is signed, this is stalled.

@niccaluim would need to sign it at https://cla-assistant.io/spf13/viper?pullRequest=94

Then someone can try to merge this in and test it.

@spf13
Copy link
Owner

spf13 commented Feb 8, 2016

@niccaluim can you sign the CLA https://cla-assistant.io/spf13/viper?pullRequest=94 so we can take over this PR and incorporate it into Viper?

@flugeldoo
Copy link
Author

Hey there, sorry. I'll sign it just as soon as I get the ok from Legal.

@flugeldoo
Copy link
Author

Alright, it's signed! Does it normally take a while for the check to update?

@spf13
Copy link
Owner

spf13 commented Feb 9, 2016

Not usually. Try this link instead https://cla-assistant.io/spf13/viper . If it says you are good then you are already signed.

@flugeldoo
Copy link
Author

Hmm, that doesn't seem to be working either. It shows me the CLA, I click to sign, it says I've signed and redirects me.

@spf13
Copy link
Owner

spf13 commented Feb 9, 2016

Thanks for being patient. I've checked in the CLA backend and you have indeed signed it. Not sure why the PR isn't updating, but it's all good. Thanks!

@vinodmut
Copy link

vinodmut commented Feb 27, 2017

Are there any updates on this? As mentioned earlier in the thread, it's useful for reading Kubernetes secrets.

@titpetric
Copy link

titpetric commented Apr 20, 2017

This is becoming more relevant. Docker introspection feature is being implemented in the same way, currently it's slated as experimental, but might land in the following months. Related issue here

@Ilyes512
Copy link

So this would have been nice to have? This was opened on Jul 15, 2015!? @spf13 I notice this with more of your (awesome) opensource projects (lots of open issue's and merge requests). A little disappointed but very understandable... time is limited. To bad we don't have the option to clone our selfs :)

@CLAassistant
Copy link

CLAassistant commented Jul 2, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ Bill Robbins
❌ wrobbins


Bill Robbins seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@kolaente
Copy link

Any updates on this considering it's been open since quite a while? There's now even an issue about this: #1022

@jedahan
Copy link

jedahan commented Nov 6, 2023

Would love to see this implemented to support the same use case - docker secrets

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

Successfully merging this pull request may close these issues.