From 19bfa6ac6e5272eaf82c842a77b78717d2dd3739 Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Tue, 9 Apr 2024 11:30:04 +0300 Subject: [PATCH] Switch sub-config with no IP assignment bug When a switch sub-config is created with no specification of IP assignment, the code mishandles it and tries set it anyway. Signed-off-by: Kobi Samoray --- nsxt/resource_nsxt_edge_transport_node.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nsxt/resource_nsxt_edge_transport_node.go b/nsxt/resource_nsxt_edge_transport_node.go index 52f008127..2c6d5df7b 100644 --- a/nsxt/resource_nsxt_edge_transport_node.go +++ b/nsxt/resource_nsxt_edge_transport_node.go @@ -1435,9 +1435,11 @@ func setHostSwitchSpecInSchema(d *schema.ResourceData, spec *data.StructValue, n if len(profiles) > 0 { hsCfgOpt["host_switch_profile"] = profiles } - hsCfgOpt["ip_assignment"], err = setIPAssignmentInSchema(tnpsc.HostSwitchConfigOption.IpAssignmentSpec) - if err != nil { - return err + if tnpsc.HostSwitchConfigOption.IpAssignmentSpec != nil { + hsCfgOpt["ip_assignment"], err = setIPAssignmentInSchema(tnpsc.HostSwitchConfigOption.IpAssignmentSpec) + if err != nil { + return err + } } hsCfgOpt["uplink"] = setUplinksFromSchema(tnpsc.HostSwitchConfigOption.Uplinks) e["host_switch_config_option"] = []interface{}{hsCfgOpt}