2020-03-13 13:04:48 -04:00
|
|
|
//go:generate mapstructure-to-hcl2 -type KeyValue,KeyValues,KVFilter
|
2020-03-13 11:04:42 -04:00
|
|
|
|
|
|
|
package hcl2template
|
|
|
|
|
|
|
|
type KeyValue struct {
|
|
|
|
Key string
|
|
|
|
Value string
|
|
|
|
}
|
2020-03-13 12:17:00 -04:00
|
|
|
|
2020-03-13 13:04:48 -04:00
|
|
|
type KeyValues []KeyValue
|
|
|
|
|
|
|
|
func (kvs KeyValues) CopyOn(to map[string]string) []error {
|
|
|
|
for _, kv := range kvs {
|
|
|
|
to[kv.Key] = kv.Value
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-03-13 12:17:00 -04:00
|
|
|
type KVFilter struct {
|
|
|
|
Filters map[string]string
|
2020-03-13 13:04:48 -04:00
|
|
|
Filter KeyValues
|
2020-03-13 12:17:00 -04:00
|
|
|
}
|
|
|
|
|
2020-03-13 13:04:48 -04:00
|
|
|
func (kvf *KVFilter) Prepare() []error {
|
|
|
|
kvf.Filter.CopyOn(kvf.Filters)
|
2020-03-13 12:17:00 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (kvf *KVFilter) Empty() bool {
|
|
|
|
return len(kvf.Filters) == 0
|
|
|
|
}
|