Exemplo n.º 1
0
// UnmarshalJSON unmarshals JSON into a ConfigPolicy
func (c *ConfigPolicy) UnmarshalJSON(data []byte) error {
	m := map[string]map[string]interface{}{}
	decoder := json.NewDecoder(bytes.NewReader(data))
	if err := decoder.Decode(&m); err != nil {
		return err
	}
	c.config = ctree.New()
	if config, ok := m["config"]; ok {
		if node, ok := config["root"]; ok {
			if n, ok := node.(map[string]interface{}); ok {
				return unmarshalJSON(n, &[]string{}, c.config)
			}
		}
	}
	return nil
}
Exemplo n.º 2
0
// Returns a new ConfigDataTree.
func NewTree() *ConfigDataTree {
	return &ConfigDataTree{
		cTree: ctree.New(),
	}
}
Exemplo n.º 3
0
// Returns a new ConfigPolicy.
func New() *ConfigPolicy {
	return &ConfigPolicy{
		config: ctree.New(),
	}
}