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: Do not modify the structure of opaque config #7935

Closed

Commits on May 27, 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 May 27, 2020
    Configuration menu
    Copy the full SHA
    8844d8d View commit details
    Browse the repository at this point in the history
  2. Add decode hooks to all lazy-decode parse functions

    So that if they encounter config accepted by a newer version of Consul
    they will know how to handle it.
    dnephin committed May 27, 2020
    Configuration menu
    Copy the full SHA
    7e7a67b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    09f5c48 View commit details
    Browse the repository at this point in the history
  4. config: Do not modify the structure of opaque config

    HCL and JSON config may have different structures. With this change the
    opaque configuration will not be modified. When the config is
    deserialized the same hook is used to handle this difference in
    structure.
    dnephin committed May 27, 2020
    Configuration menu
    Copy the full SHA
    e11c27a View commit details
    Browse the repository at this point in the history