Exemplo n.º 1
0
func (r *RawConfig) interpolate(fn interpolationWalkerFunc) error {
	config, err := copystructure.Copy(r.Raw)
	if err != nil {
		return err
	}
	r.config = config.(map[string]interface{})

	w := &interpolationWalker{F: fn, Replace: true}
	err = reflectwalk.Walk(r.config, w)
	if err != nil {
		return err
	}

	r.unknownKeys = w.unknownKeys
	return nil
}
Exemplo n.º 2
0
func (r *RawConfig) merge(r2 *RawConfig) *RawConfig {
	rawRaw, err := copystructure.Copy(r.Raw)
	if err != nil {
		panic(err)
	}

	raw := rawRaw.(map[string]interface{})
	for k, v := range r2.Raw {
		raw[k] = v
	}

	result, err := NewRawConfig(raw)
	if err != nil {
		panic(err)
	}

	return result
}