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 passing configs via env vars #4734

Open
karalabe opened this issue Sep 14, 2023 · 8 comments
Open

Support passing configs via env vars #4734

karalabe opened this issue Sep 14, 2023 · 8 comments
Labels
enhancement New feature or request UX-and-logs

Comments

@karalabe
Copy link

We've just introduced a nifty feature into Geth where you can specify configurations in env vars too, not only cli flags. Each flag is mapped to an env var automatically, so it's fairly obvious and easy to understand.

E.g. --state.scheme would be GETH_STATE_SCHEME

Wondering if Lighthouse has a similar feature planned?

The benefit of this is that in many cloud or container provider settings, the usual way to configure stuff is via env vars. Most providers allow you to define env vars in templates, add defaults, docs, etc to them, making these templates easy to redistribute and even check for issues. Although they usually also support passing CLI flags, that's just one mega-mess of a single string containing everything, so it's very brittle.

My assumption is that whatever CLI library you're using already has support for env vars, you just need to tell them which var is mapped to which flag.

@michaelsproul
Copy link
Member

My hesitation about env vars is that they get silently ignored if you typo the variable name. It's probably something we could still have a go at though. Our track record with making sweeping changes to the CLI arg parsing is... not good however. We're on an old arg-parsing library at the moment, and previous attempts to add config file support bit-rotted and never merged (cf. #2748).

@michaelsproul michaelsproul added enhancement New feature or request UX-and-logs labels Sep 14, 2023
@karalabe
Copy link
Author

karalabe commented Sep 14, 2023

True, that mistyping could have adverse effects. Wondering how I'd solve it (for us too), perhaps one way would be to iterate over all the GETH_ prefixed env vars on startup, and anything not mapped to a flag would be printed in a warning log saying that an env var is present, but not used. Of course, it's still not as strict as flat out refusing to start on a bad flag, but it's a step closer to finding issues.

@karalabe
Copy link
Author

A quick implementation:

Screenshot 2023-09-14 at 17 24 26

@protolambda
Copy link

Is this feature still being considered? This would make docker setups less painful to configure.

@karalabe
Copy link
Author

karalabe commented Jan 21, 2024 via email

@karalabe
Copy link
Author

karalabe commented Jan 21, 2024 via email

@dapplion
Copy link
Collaborator

Linking related latest issue to overhaul the CLI

@protolambda
Copy link

Any chance this feature can be implemented, now that the mainnet Dencun release is out of the way? I am still interested in being able to configure lighthouse this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request UX-and-logs
Projects
None yet
Development

No branches or pull requests

4 participants