diff --git a/bigip/provider.go b/bigip/provider.go index a1e3c11e8..a148551af 100644 --- a/bigip/provider.go +++ b/bigip/provider.go @@ -7,8 +7,8 @@ If a copy of the MPL was not distributed with this file,You can obtain one at ht package bigip import ( - "log" "reflect" + "regexp" "strings" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -173,11 +173,8 @@ func mapEntity(d map[string]interface{}, obj interface{}) { f.Set(reflect.ValueOf(d[field])) } } else { - if field == "http_reply" { - f := val.FieldByName(strings.Title("httpReply")) - f.Set(reflect.ValueOf(d[field])) - } - log.Printf("[WARN] You probably weren't expecting %s to be an invalid field", field) + f := val.FieldByName(strings.Title(toCamelCase(field))) + f.Set(reflect.ValueOf(d[field])) } } } @@ -190,3 +187,10 @@ func parseF5Identifier(str string) (partition, name string) { } return "", str } + +func toCamelCase(str string) string { + var link = regexp.MustCompile("(^[A-Za-z])|_([A-Za-z])") + return link.ReplaceAllStringFunc(str, func(s string) string { + return strings.ToUpper(strings.Replace(s, "_", "", -1)) + }) +}