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

config: Use HookWeakDecodeFromSlice in place of PatchSliceOfMaps #7964

Merged
merged 1 commit into from
Jun 8, 2020

Commits on Jun 8, 2020

  1. config: add HookWeakDecodeFromSlice

    Currently opaque config blocks (config entries, and CA provider config) are
    modified by PatchSliceOfMaps, making it impossible for these opaque
    config sections to contain slices of maps.
    
    In order to fix this problem, any lazy-decoding of these blocks needs to support
    weak decoding of []map[string]interface{} to a struct type before
    PatchSliceOfMaps is replaces. This is necessary because these config
    blobs are persisted, and during an upgrade an older version of Consul
    could read one of the new configuration values, which would cause an error.
    
    To support the upgrade path, this commit first introduces the new hooks
    for weak decoding of []map[string]interface{} and uses them only in the
    lazy-decode paths. That way, in a future release, new style
    configuration will be supported by the older version of Consul.
    
    This decode hook has a number of advantages:
    
    1. It no longer panics. It allows mapstructure to report the error
    2. It no longer requires the user to declare which fields are slices of
       structs. It can deduce that information from the 'to' value.
    3. It will make it possible to preserve opaque configuration, allowing
       for structured opaque config.
    dnephin committed Jun 8, 2020
    Configuration menu
    Copy the full SHA
    75cbbe2 View commit details
    Browse the repository at this point in the history