Skip to content

Commit

Permalink
This is a HACK - allow invalid JSON to be a string
Browse files Browse the repository at this point in the history
in terraform params processing.
  • Loading branch information
galthaus committed Dec 18, 2017
1 parent 0ea15f4 commit 570f62b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drp/resource_drp_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\"]"
Expand Down
2 changes: 1 addition & 1 deletion drp/resource_drp_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\"]"
Expand Down
2 changes: 1 addition & 1 deletion drp/resource_drp_raw_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\"]"
Expand Down
8 changes: 6 additions & 2 deletions drp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 570f62b

Please sign in to comment.