From ffd53702136e6f54c5682f854fea60238b3781d2 Mon Sep 17 00:00:00 2001 From: Gavin Williams Date: Wed, 5 Oct 2016 17:21:54 +0100 Subject: [PATCH] provider/openstack: gophercloud migration: Add a 'MapValueSpecs' function which can be used to convert 'value_specs' resource data to a map. --- builtin/providers/openstack/util.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/builtin/providers/openstack/util.go b/builtin/providers/openstack/util.go index 9643a579e..596067ce1 100644 --- a/builtin/providers/openstack/util.go +++ b/builtin/providers/openstack/util.go @@ -18,6 +18,15 @@ func CheckDeleted(d *schema.ResourceData, err error, msg string) error { return fmt.Errorf("%s: %s", msg, err) } +// MapValueSpecs converts ResourceData into a map +func MapValueSpecs(d *schema.ResourceData) map[string]string { + m := make(map[string]string) + for key, val := range d.Get("value_specs").(map[string]interface{}) { + m[key] = val.(string) + } + return m +} + // BuildRequest takes an opts struct and builds a request body for // Gophercloud to execute func BuildRequest(opts interface{}, parent string) (map[string]interface{}, error) {