hapipal / confidence

Dynamic, declarative configurations
Other
263 stars 43 forks source link

multiple options for keys, not just values based on filters #59

Closed danielb2 closed 8 years ago

danielb2 commented 8 years ago

What if I have:

{
  "plugins": {
    "$filter": "env",
    "$base": {
      "inert": {}
    },

    "qa": {
      "blipp": {}
    },
    "prod": {
      "good": {}
    },

    "$filter": "debug",
    "prod": {
      "debug": {}
    }
    "qa": {
      "extra-debug": {}
    }
  }
}

Right now it's very easy to have values change based on particular filters, however, keys at the same level doesn't seem to have the ability to change. For instance, I may want to have extra debugging plugin loaded for qa. It would be nice to have multiple filters at the same key level.

I don't believe this is possible atm?

( yes I realize in this instance you could argue that a debug plugin should be able to take options for debug levels, but this is an example and not the actual use-case, so please bear with me )

danielb2 commented 8 years ago

I believe I can solve this with further nestings which gets a bit hairy

danielb2 commented 8 years ago

The equivalent will look like this:

{
  "plugins": {
    "$filter": "env",
    "$base": {
      "inert": {}
    },

    "qa": {
      "$filter": "debug",
      "$default": {
        "blipp": {}
      },
      "$base": {
        "blipp": {}
      },
      "on": {
        "extra-debug": {}
      }
    },

    "prod": {
      "$filter": "debug",
      "$default": {
        "good": {}
      },
      "$base": {
        "good": {}
      },
      "on": {
        "debug": {}
      }
    }
  }
danielb2 commented 8 years ago

I think the above is unnecessarily complex. Think there's a better way to solve this?

Basically prod should always load good, qa always load blipp. debug filter turns the appropriate filter on for each one.

patrickkettner commented 7 years ago

sorry for taking so long to get back to you on this.

We are not interested in adding the ability to mutate keys to confidence. This would be best suited to a function that would generate your object, that is then passed to confidence