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

pkg/util: support custom yaml.Unmarshaler implementations for util.UnmarshalYAMLMerged #1244

Merged

Commits on Jan 10, 2022

  1. pkg/util: support custom yaml.Unmarshaler implementations for util.Un…

    …marshalYAMLMerged
    
    It's common for config types to have implement yaml.Unmarshaler for:
    
    * Applying defaults
    * Applying extra logic post-unmarshal
    
    If these config types were unmarshaled through util.UnmarshalYAMLMerged,
    the yaml.Unmarshaler implementation would never complete successfully,
    preventing the post-unmarshal logic from running.
    
    This issue was introduced in grafana#1192, but went unnoticed until grafana#1228
    implemented yaml.Unmarshaler to perform field migrations. grafana#1240 reported
    the issue.
    
    This commit fixes the bug by performing a second non-strict unmarshal to
    ensure that all input values unmarshal successfully, with the exception
    of unmarshal errors unrelated to unrecognized field names.
    
    This is hacky, but it's worthwhile noting that util.UnmarshalYAMLMerged
    is a temporary workaround needed for the integrations-next migration,
    and will eventually be removed.
    rfratto committed Jan 10, 2022
    Configuration menu
    Copy the full SHA
    8c2f41d View commit details
    Browse the repository at this point in the history