From 26db40de8074b486292568159a528b5b4551d2d0 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Tue, 13 Feb 2024 12:19:31 +0200 Subject: [PATCH] Set member index when matching display name member index should be set also when not matching member_index attribute. Signed-off-by: Kobi Samoray --- nsxt/data_source_nsxt_policy_edge_node.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nsxt/data_source_nsxt_policy_edge_node.go b/nsxt/data_source_nsxt_policy_edge_node.go index e3944deac..315e1fb0d 100644 --- a/nsxt/data_source_nsxt_policy_edge_node.go +++ b/nsxt/data_source_nsxt_policy_edge_node.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/vmware/vsphere-automation-sdk-go/runtime/bindings" "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra/sites/enforcement_points/edge_clusters" "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model" ) @@ -47,10 +48,17 @@ func dataSourceNsxtPolicyEdgeNodeRead(d *schema.ResourceData, m interface{}) err if memberIndexSet { query["member_index"] = strconv.Itoa(memberIndex.(int)) } - _, err := policyDataSourceResourceReadWithValidation(d, getPolicyConnector(m), getSessionContext(d, m), "PolicyEdgeNode", query, false) + obj, err := policyDataSourceResourceReadWithValidation(d, getPolicyConnector(m), getSessionContext(d, m), "PolicyEdgeNode", query, false) if err != nil { return err } + converter := bindings.NewTypeConverter() + dataValue, errors := converter.ConvertToGolang(obj, model.PolicyEdgeNodeBindingType()) + if len(errors) > 0 { + return errors[0] + } + policyEdgeNode := dataValue.(model.PolicyEdgeNode) + d.Set("member_index", policyEdgeNode.MemberIndex) return nil }