Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

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.

@refcell refcell moved this to Todo in Project Tracking Jan 7, 2025
@refcell refcell moved this from Backlog to Out of Scope in Project Tracking Feb 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Out of Scope
Development

No branches or pull requests

1 participant