packer-cn/hcl2template/types.kv.go

32 lines
529 B
Go
Raw Normal View History

2020-03-13 13:04:48 -04:00
//go:generate mapstructure-to-hcl2 -type KeyValue,KeyValues,KVFilter
package hcl2template
type KeyValue struct {
Key string
Value string
}
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
}
type KVFilter struct {
Filters map[string]string
2020-03-13 13:04:48 -04:00
Filter KeyValues
}
2020-03-13 13:04:48 -04:00
func (kvf *KVFilter) Prepare() []error {
kvf.Filter.CopyOn(kvf.Filters)
return nil
}
func (kvf *KVFilter) Empty() bool {
return len(kvf.Filters) == 0
}