-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
bug-upstreamBug exists, but only fixable in upstream crateBug exists, but only fixable in upstream crate
Description
Say you have a serde tagged enum by #[confik(forward_serde(tag = "type"))] in the configuration:
use confik::Configuration;
#[derive(Debug, Clone, Configuration)]
#[confik(forward_serde(tag = "type", rename_all = "snake_case"))]
enum Config {
Foo(Foo),
Bar(Bar),
}
#[derive(Debug, Clone, Configuration)]
struct Foo {
foo: String,
}
#[derive(Debug, Clone, Configuration)]
struct Bar {
bar: String,
}
fn main() {
let config = Config::builder()
.override_with(confik::FileSource::new("config.toml"))
.override_with(confik::EnvSource::new().allow_secrets())
.try_build()
.unwrap();
}with config.toml
type = "foo"
foo = "hello"and environment variable
TYPE=foo
The above works.
However, remove either of type = "foo" from config.toml or TYPE=foo from the environment, and this fails with an error:
(...)
missing field `type`
(...)
Metadata
Metadata
Assignees
Labels
bug-upstreamBug exists, but only fixable in upstream crateBug exists, but only fixable in upstream crate