-
Notifications
You must be signed in to change notification settings - Fork 28
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
Custom yaml unmarshaling (e.g. defaults) #26
Comments
FYSA @ashrayjain |
Thought about this further after our in-person discussion. I think the decision here stems on how opinionated we want to be in terms of how we deal with configuration. As you point out in this issue, right now witchcraft is opinionated in its use of If we decide that the usage of Right now I'm leaning slightly towards the first approach, but @bmoylan curious to hear your thoughts/opinion. |
Concretely, if there's some function like WithConfigUnmarshalFunction(func(data []byte, v interface{}) error {
if err := structfields.SetToDefaults(v); err != nil {
return err
}
return yaml.Unmarshal(data, v)
}) vs. implementing something like: func (cfg *AppInstallConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := structfields.SetToDefaults(cfg); err != nil {
return err
}
type RawAppInstallConfig AppInstallConfig
rawCfg := RawAppInstallConfig(*cfg)
if err := unmarshal(&rawCfg); err != nil {
return err
}
*cfg = AppInstallConfig(rawCfg)
return nil
} For the install and runtime structs. |
witchcraft calls yaml.Unmarshal for you, but this makes custom handling like loading defaults difficult.
The text was updated successfully, but these errors were encountered: