From 78ba90e5e309cbfa9dde2eb7952bd1afa14350e5 Mon Sep 17 00:00:00 2001 From: danischm Date: Fri, 6 Oct 2023 15:22:48 +0200 Subject: [PATCH] Fix key model incompatibility --- gen/templates/model.go | 6 +++--- internal/provider/model_ise_network_access_condition.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gen/templates/model.go b/gen/templates/model.go index e83d4dd..2bbb55d 100644 --- a/gen/templates/model.go +++ b/gen/templates/model.go @@ -385,7 +385,7 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R {{- else if or (eq .Type "List") (eq .Type "Set")}} {{- $list := (toGoName .TfName)}} for i := range data.{{toGoName .TfName}} { - keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}} } + keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else if eq .Type "String"}}data.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} } var r gjson.Result @@ -425,7 +425,7 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R {{- else if or (eq .Type "List") (eq .Type "Set")}} {{- $clist := (toGoName .TfName)}} for ci := range data.{{$list}}[i].{{toGoName .TfName}} { - keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}} } + keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else if eq .Type "String"}}data.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} } var cr gjson.Result @@ -465,7 +465,7 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R {{- else if or (eq .Type "List") (eq .Type "Set")}} {{- $cclist := (toGoName .TfName)}} for cci := range data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} { - keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}} } + keys := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if or (eq .Type "Int64") (eq .Type "Bool") (eq .Type "String")}}"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}", {{end}}{{end}}{{end}} } keyValues := [...]string{ {{$noId := not (hasId .Attributes)}}{{range .Attributes}}{{if or .Id $noId}}{{if eq .Type "Int64"}}strconv.FormatInt(data.{{$list}}[i].{{toGoName .TfName}}.ValueInt64(), 10), {{else if eq .Type "Bool"}}strconv.FormatBool(data.{{$list}}[i].{{toGoName .TfName}}.ValueBool()), {{else if eq .Type "String"}}data.{{$list}}[i].{{toGoName .TfName}}.Value{{.Type}}(), {{end}}{{end}}{{end}} } var ccr gjson.Result diff --git a/internal/provider/model_ise_network_access_condition.go b/internal/provider/model_ise_network_access_condition.go index 6183451..4e7b9bb 100644 --- a/internal/provider/model_ise_network_access_condition.go +++ b/internal/provider/model_ise_network_access_condition.go @@ -406,7 +406,7 @@ func (data *NetworkAccessCondition) updateFromBody(ctx context.Context, res gjso data.Operator = types.StringNull() } for i := range data.Children { - keys := [...]string{"name", "description", "conditionType", "id", "isNegate", "attributeName", "attributeValue", "dictionaryName", "dictionaryValue", "operator", "children"} + keys := [...]string{"name", "description", "conditionType", "id", "isNegate", "attributeName", "attributeValue", "dictionaryName", "dictionaryValue", "operator"} keyValues := [...]string{data.Children[i].Name.ValueString(), data.Children[i].Description.ValueString(), data.Children[i].ConditionType.ValueString(), data.Children[i].Id.ValueString(), strconv.FormatBool(data.Children[i].IsNegate.ValueBool()), data.Children[i].AttributeName.ValueString(), data.Children[i].AttributeValue.ValueString(), data.Children[i].DictionaryName.ValueString(), data.Children[i].DictionaryValue.ValueString(), data.Children[i].Operator.ValueString()} var r gjson.Result