From 570f62b78d98a52c1b6399ab6aed9bfca709dbdd Mon Sep 17 00:00:00 2001 From: Greg Althaus Date: Mon, 18 Dec 2017 12:22:06 -0600 Subject: [PATCH] This is a HACK - allow invalid JSON to be a string in terraform params processing. --- drp/resource_drp_plugin_test.go | 2 +- drp/resource_drp_profile_test.go | 2 +- drp/resource_drp_raw_machine_test.go | 2 +- drp/utils.go | 8 ++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drp/resource_drp_plugin_test.go b/drp/resource_drp_plugin_test.go index cc4fe26..1cce653 100644 --- a/drp/resource_drp_plugin_test.go +++ b/drp/resource_drp_plugin_test.go @@ -87,7 +87,7 @@ var testAccDrpPlugin_withParams = ` Name = "foo" PluginProvider = "ipmi" Params = { - "test/string" = "\"fred\"" + "test/string" = "fred" "test/int" = 3 "test/bool" = "true" "test/list" = "[\"one\",\"two\"]" diff --git a/drp/resource_drp_profile_test.go b/drp/resource_drp_profile_test.go index a970995..b535572 100644 --- a/drp/resource_drp_profile_test.go +++ b/drp/resource_drp_profile_test.go @@ -83,7 +83,7 @@ var testAccDrpProfile_withParams = ` Name = "foo" Description = "I am a profile again" Params = { - "test/string" = "\"fred\"" + "test/string" = "fred" "test/int" = 3 "test/bool" = "true" "test/list" = "[\"one\",\"two\"]" diff --git a/drp/resource_drp_raw_machine_test.go b/drp/resource_drp_raw_machine_test.go index c5f9951..8b16982 100644 --- a/drp/resource_drp_raw_machine_test.go +++ b/drp/resource_drp_raw_machine_test.go @@ -182,7 +182,7 @@ var testAccDrpRawMachine_withParams = ` Uuid = "3945838b-be8c-4b35-8b1c-b538ddc71f7c" Secret = "12" Params = { - "test/string" = "\"fred\"" + "test/string" = "fred" "test/int" = "3" "test/bool" = "true" "test/list" = "[\"one\",\"two\"]" diff --git a/drp/utils.go b/drp/utils.go index bbd4fda..9c55455 100644 --- a/drp/utils.go +++ b/drp/utils.go @@ -226,7 +226,11 @@ func updateResourceData(m models.Model, d *schema.ResourceData) error { if e != nil { return e } - answer[k] = string(b) + if s, ok := v.(string); ok { + answer[k] = s + } else { + answer[k] = string(b) + } } d.Set("Params", answer) continue @@ -329,7 +333,7 @@ func buildModel(m models.Model, d *schema.ResourceData) (models.Model, error) { var i interface{} if e := json.Unmarshal([]byte(s), &i); e != nil { - return nil, e + i = s } valueField.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(i))