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

Description

@refcell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Out of Scope

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions