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

Parameters from ENV #63

Closed
haf opened this issue Dec 5, 2016 · 5 comments
Closed

Parameters from ENV #63

haf opened this issue Dec 5, 2016 · 5 comments

Comments

@haf
Copy link
Member

haf commented Dec 5, 2016

Description

I'd like to use Argu to optionally take configuration from the environment. Do you think you could add that feature?

Currently writing a networked-linux tutorial and figured I wanted to showcase how to build micro-services with F#.

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Dec 7, 2016

I'm not the biggest fan of parameterization using env vars. That said, doing it is very simple; you just pass an implementation of IConfigurationReader to the ParseConfiguration method of your parser.

@haf
Copy link
Member Author

haf commented Dec 7, 2016

Does the GetValue : string -> string return null if it doesn't have it?

Also, what about the #if !CORE_CLR at the top of the parsers? No parsing for .Net core or is it WIP?

Also, why aren't you a fan? I'm interested to know.

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Dec 7, 2016 via email

@haf
Copy link
Member Author

haf commented Dec 7, 2016

You got a PR from me!

@eiriktsarpalis
Copy link
Member

@haf It's just that I think using env vars for parameterization is ugly, violates referential transparency considerations and can be potentially dangerous. If completely unavoidable, I would rather just dereference the vars at the script level and pass through the CLI:

./myApp --foo=$FOO --bar=$BAR

If I am going depend on ambient state for configuration I would much rather have the ability to explicitly specify which aspects of that ambient state I want to use.

Suppose you are consuming an application that I wrote which uses Argu for environment variable parsing. Unbeknownst to you, my application is also looking for a $BAZ environment variable that triggers a functionality you're completely unaware of: let's say it drops the database it connects to once completed. Now, If you were to accidentally expose an export BAZ=true statement in one of your machines, this could carry potentially catastrophic consequences.

The above example by the way is inspired by a true story.

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