Uploaded image for project: 'Fabric'
  1. Fabric
  2. FAB-16853

Add support to the configuration package to honor "defaultValue" tags



    • Story
    • Status: Backlog
    • Medium
    • Resolution: Unresolved
    • v2.0.0
    • Future
    • fabric-common
    • None


      As part of the drive to make configuration more centralized and explicit, configuration structures will be defined with yaml tags and, optionally, defaultValue tags.

      The configuration package support for the default tag needs to be extended to support a defaultValue tag. The defaultValue tag should reference an exported var that holds a literal containing the complex default value to use in configuration.

      The difference is that the default tag is used to provide simple values to leaf nodes while defaultValue is used to provide complex literal defaults like structures or maps. Where possible, default should be preferred but there are a handful of places where defaultValue is required.

      For example, decoding

      stringOne: one string

      into a reference to a zero value of this structure:

      type Config struct {
      	StringOne string `yaml:"stringOne" default:"one"`
      	Plugins []Plugin `yaml:"plugins" defaultValue:"DefaultPlugins"`

      where Plugins is defined as:

      type Plugins struct {
      	Name string `yaml:"name"`
      	Path string `yaml:"path"`

      and DefaultPlugins is:

      var DefaultPlugins = []Plugins{
      	{Name: "pluginOne", Path: "/path/to/one"},
      	{Name: "pluginTwo", Path: "/path/to/two"},

      should result in a value that is equivalent to one that is decoded from this yaml:

      stringOne: one string
      - name: pluginOne
        path: /path/to/one
      - name: pluginTwo
        path: /path/to/two

      Notice the default values from the DefaultPlugins var are populated.




            Unassigned Unassigned
            sykesm Matthew Sykes
            0 Vote for this issue
            1 Start watching this issue