Confluex / Zuul

Keymaster and Gatekeeper - Application Configuration Management
http://confluex.com
Apache License 2.0
42 stars 32 forks source link

Make the JSON format sane #23

Closed rhoegg closed 12 years ago

rhoegg commented 12 years ago

Example:

{
   "id":3,
   "name":"app-data-config"
   "entries":[
      {
         "id":11,
         "key":"jdbc.zuul.generate.ddl",
         "value":"none",
         "encrypted":false
      },
      {
         "id":13,
         "key":"jdbc.zuul.password",
         "value":"GsC6gO78e6ShyGYrD6k05tkgNdioeR0K",
         "encrypted":true
      },
      {
         "id":10,
         "key":"jdbc.zuul.url",
         "value":"jdbc:h2:file:zuul-qa",
         "encrypted":false
      },
      {
         "id":12,
         "key":"jdbc.zuul.username",
         "value":"zuul",
         "encrypted":false
      }
   ] 
} 

This format really makes you go out of your way when trying to use this as JSON. You have to write finders to match the KVPs you’re interested in instead of just doing something like:

var ddl = json[‘jdbc.zuul.generate.ddl’];

Conversely, The properties representation is rendered as such:

#Generated from Zuul  with parameters: name=app-data-config, environment=prod
#Tue Nov 20 13:26:08 CST 2012
jdbc.zuul.generate.ddl=none
jdbc.zuul.password=ENC(GsC6gO78e6ShyGYrD6k05tkgNdioeR0K)
jdbc.zuul.url=jdbc\:h2\:file\:zuul-qa
jdbc.zuul.username=zuul

Note the ENC(garbage) to denote encrypted properties. This was mainly done to make it compatible with Jasypt.

I was thinking about doing something similar for the JSON format. What do you guys think about this:

/settings.json:

[
   {
      "name":"app-data-config",
      "environment":"qa",
      "resourceUri":"/settings/qa/app-data-config.json"
   },
   {
      "name":"app-data-config",
      "environment":"dev",
      "resourceUri":"/settings/dev/app-data-config.json"
   }
]

/settings/qa/app-data-config.json:

{
   "jdbc.zuul.generate.ddl":"validate",
   "jdbc.zuul.password":"ENC(GsC6gO78e6ShyGYrD6k05tkgNdioeR0K)",
   "jdbc.zuul.url":"jdbc:h2:file:zuul-qa",
   "jdbc.zuul.username":"zuul"
}

I don’t particularly like the ENC(encryptedValue) convention but it keeps the data structure simple.

mcantrell commented 12 years ago

implemented