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

feat(node): Persist Node Config to disk and Merge with Figment #124

Open
refcell opened this issue Nov 20, 2024 · 0 comments
Open

feat(node): Persist Node Config to disk and Merge with Figment #124

refcell opened this issue Nov 20, 2024 · 0 comments

Comments

@refcell
Copy link
Contributor

refcell commented Nov 20, 2024

Description

Currently, the hilo-node's cli args are directly transformed into the hilo-node Config. Instead, the node binary should use Figment to attempt to read environment variables, then the toml file, and lastly the CLI args to build the Config.

This could look like the following.

use hilo_node::Config;
use figment::{Figment, providers::{Serialized, Env, Toml}};

let cli = NodeArgs.parse()?;
let toml_file = cli.static-config;        // This can be a cli arg, so you can do `node --static-config hilo.toml`
let defaults_provider = Serialized::defaults(DefaultsProvider::default());
let toml_provider = Toml::file(toml_file).nested();
let cli_provider = Serialized::defaults(cli);

let config: Config = Figment::new()
    .merge(defaults_provider)
    .merge(Env::prefixed("HILO_"))
    .merge(toml_provider)
    .merge(cli_provider)
    .extract()?;

Note, the CliArgs should be modified to make arguments optional.

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

1 participant