JsonOpt Support for oslo.config
In oslo.config.cfg, it will be useful to have an Option for specifying Json, in addition to the existing types such as StrOpt, DictOpt, etc. For example, this will allows specifying a valid Json string as value to a config parameter as shown below:
[custom_
default=
Although this can be done in an indirect way by treating this as a StrOpt and then loading it into json after reading it from config file, it will be useful to have a native JsonOpt that performs this functionality.
The implementation of this is straight-forward with something like the following. Note that the below code needs to be enhanced with error checking, etc.
class Json(object):
def __init__(self):
super(Json, self).__init__()
def __call__(self, value):
import json
return json.loads(
def __repr__(self):
return 'Json'
....
class JsonOpt(Opt):
def __init__(self, name, **kwargs):
Blueprint information
- Status:
- Started
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- Sudheendra Murthy
- Direction:
- Needs approval
- Assignee:
- Sudheendra Murthy
- Definition:
- New
- Series goal:
- None
- Implementation:
- Good progress
- Milestone target:
- None
- Started by
- Sudheendra Murthy
- Completed by