From 46f169666b8af7318fd86c5b414cabdb58cfe6cd Mon Sep 17 00:00:00 2001 From: akinross Date: Tue, 21 Jan 2025 19:04:51 +0100 Subject: [PATCH] [ignore] add support for null to plan when state is null and plan unknown attributes inside of sets --- gen/generator.go | 12 + gen/templates/resource.go.tmpl | 44 +- .../resource_aci_access_interface_override.go | 6 + .../provider/resource_aci_application_epg.go | 480 ++++++++++++++++++ .../provider/resource_aci_bridge_domain.go | 131 +++++ .../resource_aci_certificate_authority.go | 4 +- .../resource_aci_custom_qos_policy.go | 2 + ...resource_aci_data_plane_policing_policy.go | 2 + .../resource_aci_endpoint_security_group.go | 175 +++++++ .../provider/resource_aci_endpoint_tag_ip.go | 2 + .../provider/resource_aci_endpoint_tag_mac.go | 2 + ...esource_aci_epg_useg_ad_group_attribute.go | 2 + .../resource_aci_epg_useg_block_statement.go | 2 + .../resource_aci_epg_useg_dns_attribute.go | 2 + .../resource_aci_epg_useg_ip_attribute.go | 2 + .../resource_aci_epg_useg_mac_attribute.go | 2 + ...source_aci_epg_useg_sub_block_statement.go | 2 + .../resource_aci_epg_useg_vm_attribute.go | 2 + ...nal_management_network_instance_profile.go | 37 ++ ..._aci_external_management_network_subnet.go | 2 + .../resource_aci_first_hop_security_policy.go | 4 + .../resource_aci_igmp_snooping_policy.go | 4 +- internal/provider/resource_aci_key_ring.go | 2 + .../resource_aci_l3out_consumer_label.go | 68 +++ .../resource_aci_l3out_node_sid_profile.go | 2 + .../resource_aci_l3out_provider_label.go | 2 + .../resource_aci_l3out_redistribute_policy.go | 2 + .../resource_aci_management_access_policy.go | 16 + .../resource_aci_mld_snooping_policy.go | 4 +- ...aci_neighbor_discovery_interface_policy.go | 4 +- .../resource_aci_netflow_exporter_policy.go | 6 + .../resource_aci_netflow_monitor_policy.go | 35 ++ .../resource_aci_netflow_record_policy.go | 6 +- .../resource_aci_out_of_band_contract.go | 2 + .../resource_aci_pim_route_map_entry.go | 2 + .../resource_aci_pim_route_map_policy.go | 2 + ...lation_from_bridge_domain_to_l3_outside.go | 2 + ...bridge_domain_to_netflow_monitor_policy.go | 2 + ...om_l3out_consumer_label_to_external_epg.go | 2 + ...consumer_label_to_route_control_profile.go | 2 + ...ource_aci_relation_to_consumed_contract.go | 2 + ...lation_to_consumed_out_of_band_contract.go | 2 + ...esource_aci_relation_to_contract_master.go | 2 + .../resource_aci_relation_to_domain.go | 2 + ...urce_aci_relation_to_fibre_channel_path.go | 2 + ...ource_aci_relation_to_imported_contract.go | 2 + ...urce_aci_relation_to_intra_epg_contract.go | 2 + ...source_aci_relation_to_netflow_exporter.go | 2 + ...ource_aci_relation_to_provided_contract.go | 2 + .../resource_aci_relation_to_static_leaf.go | 2 + .../resource_aci_relation_to_static_path.go | 2 + ...resource_aci_relation_to_taboo_contract.go | 2 + ...ci_relation_to_vrf_fallback_route_group.go | 2 + .../resource_aci_rogue_coop_exception.go | 2 + .../resource_aci_route_control_profile.go | 2 + .../resource_aci_trust_control_policy.go | 2 + .../resource_aci_vrf_fallback_route.go | 2 + .../resource_aci_vrf_fallback_route_group.go | 47 ++ ...rce_aci_vrf_fallback_route_group_member.go | 2 + internal/provider/utils.go | 12 +- 60 files changed, 1166 insertions(+), 11 deletions(-) diff --git a/gen/generator.go b/gen/generator.go index 6702ea28e..524d0dab8 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -142,6 +142,18 @@ var templateFuncs = template.FuncMap{ "addToChild": AddToChildInTestTemplate, "checkDeletableChild": CheckDeletableChild, "emptyChild": EmptyChild, + "excludeForNullInSetCheck": ExcludeForNullInSetCheck, +} + +func ExcludeForNullInSetCheck(resourceClassName string) bool { + // Function to exclude TagTag and TagAnnotation from the null check in the Set function + // Done to reduce the amount of functions created which are not needed for these classes + // During refactor to struct per class which is reused in children this is not needed anymore + var childClasses []string + for _, child := range alwaysIncludeChildren { + childClasses = append(childClasses, Capitalize(strings.ReplaceAll(child, ":", ""))) + } + return !slices.Contains(childClasses, resourceClassName) } func ContainsRequired(properties map[string]Property) bool { diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index ebbdbc5a1..dd19dd323 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -864,8 +864,8 @@ func (r *{{.ResourceClassName}}Resource) ModifyPlan(ctx context.Context, req res if GetMOName(stateData.Deprecated{{$SetName}}.ValueString()) == attributeValues.{{ .Name }}.ValueString() && !attributeValues.{{ .Name }}.IsNull() { planData.Deprecated{{$SetName}} = stateData.Deprecated{{$SetName}} } + {{- end}} {{- end}} - {{- end}} } } else if !configData.Deprecated{{ $SetName }}.IsNull() { var newAttributeValues {{ $SetName }}{{.ParentHierarchy}}ResourceModel @@ -1623,7 +1623,7 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc {{- if not .ReadOnly }} PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), - SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, {{- end}} @@ -2660,6 +2660,7 @@ func getEmpty{{.ResourceClassName}}{{.ParentHierarchy}}ResourceModel() {{.Resour {{- end}} } } + {{- if or (not .IdentifiedBy) .MaxOneClassAllowed}} var {{.ResourceClassName}}{{.ParentHierarchy}}Type = map[string]attr.Type{ {{- range .Properties}} @@ -2698,6 +2699,40 @@ var {{.ResourceClassName}}{{.ParentHierarchy}}Type = types.ObjectType{ {{- end}} }, } + +{{- if excludeForNullInSetCheck .ResourceClassName}} +func {{.ResourceClassName}}{{.ParentHierarchy}}SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []{{.ResourceClassName}}{{.ParentHierarchy}}ResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + {{- range .Properties}} + if stateValue.{{ .Name }}.IsNull() { + nullInStateFound = true + {{- if eq .ValueType "bitmask"}} + planSetValues[index].{{ .Name }} = basetypes.NewSetNull(types.StringType) + {{- else if .HasCustomType}} + planSetValues[index].{{ .Name }} = customTypes.New{{.ResourceClassName}}{{.Name}}StringNull() + {{- else}} + planSetValues[index].{{ .Name }} = basetypes.NewStringNull() + {{- end}} + } + {{- end}} + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, {{.ResourceClassName}}{{.ParentHierarchy}}Type, planSetValues) + return planSet + +} +{{- end}} {{- end}} {{- range .Children}} {{- template "childStructsAndAttributeTypes" . }} @@ -2780,6 +2815,11 @@ var {{.ResourceClassName}}{{.ParentHierarchy}}Type = types.ObjectType{ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + {{- if excludeForNullInSetCheck .ResourceClassName}} + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate({{.ResourceClassName}}{{.ParentHierarchy}}SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), + {{- else}} + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), + {{- end}} }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_access_interface_override.go b/internal/provider/resource_aci_access_interface_override.go index 66dd2cea3..b9eec99de 100644 --- a/internal/provider/resource_aci_access_interface_override.go +++ b/internal/provider/resource_aci_access_interface_override.go @@ -441,6 +441,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -467,6 +468,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -519,6 +521,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -545,6 +548,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -573,6 +577,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -599,6 +604,7 @@ func (r *InfraHPathSResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_application_epg.go b/internal/provider/resource_aci_application_epg.go index 47f36818a..0a6801822 100644 --- a/internal/provider/resource_aci_application_epg.go +++ b/internal/provider/resource_aci_application_epg.go @@ -613,6 +613,38 @@ var FvRsConsFvAEPgType = types.ObjectType{ }, } +func FvRsConsFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsConsFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Prio.IsNull() { + nullInStateFound = true + planSetValues[index].Prio = customTypes.NewFvRsConsPrioStringNull() + } + if stateValue.TnVzBrCPName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzBrCPName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsConsFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsConsFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsConsFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -692,6 +724,38 @@ var FvRsConsIfFvAEPgType = types.ObjectType{ }, } +func FvRsConsIfFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsConsIfFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Prio.IsNull() { + nullInStateFound = true + planSetValues[index].Prio = customTypes.NewFvRsConsIfPrioStringNull() + } + if stateValue.TnVzCPIfName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzCPIfName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsConsIfFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsConsIfFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsConsIfFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -911,6 +975,126 @@ var FvRsDomAttFvAEPgType = types.ObjectType{ }, } +func FvRsDomAttFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsDomAttFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.BindingType.IsNull() { + nullInStateFound = true + planSetValues[index].BindingType = basetypes.NewStringNull() + } + if stateValue.ClassPref.IsNull() { + nullInStateFound = true + planSetValues[index].ClassPref = basetypes.NewStringNull() + } + if stateValue.CustomEpgName.IsNull() { + nullInStateFound = true + planSetValues[index].CustomEpgName = basetypes.NewStringNull() + } + if stateValue.Delimiter.IsNull() { + nullInStateFound = true + planSetValues[index].Delimiter = basetypes.NewStringNull() + } + if stateValue.Encap.IsNull() { + nullInStateFound = true + planSetValues[index].Encap = basetypes.NewStringNull() + } + if stateValue.EncapMode.IsNull() { + nullInStateFound = true + planSetValues[index].EncapMode = basetypes.NewStringNull() + } + if stateValue.EpgCos.IsNull() { + nullInStateFound = true + planSetValues[index].EpgCos = basetypes.NewStringNull() + } + if stateValue.EpgCosPref.IsNull() { + nullInStateFound = true + planSetValues[index].EpgCosPref = basetypes.NewStringNull() + } + if stateValue.InstrImedcy.IsNull() { + nullInStateFound = true + planSetValues[index].InstrImedcy = basetypes.NewStringNull() + } + if stateValue.IpamDhcpOverride.IsNull() { + nullInStateFound = true + planSetValues[index].IpamDhcpOverride = basetypes.NewStringNull() + } + if stateValue.IpamEnabled.IsNull() { + nullInStateFound = true + planSetValues[index].IpamEnabled = basetypes.NewStringNull() + } + if stateValue.IpamGateway.IsNull() { + nullInStateFound = true + planSetValues[index].IpamGateway = basetypes.NewStringNull() + } + if stateValue.LagPolicyName.IsNull() { + nullInStateFound = true + planSetValues[index].LagPolicyName = basetypes.NewStringNull() + } + if stateValue.NetflowDir.IsNull() { + nullInStateFound = true + planSetValues[index].NetflowDir = basetypes.NewStringNull() + } + if stateValue.NetflowPref.IsNull() { + nullInStateFound = true + planSetValues[index].NetflowPref = basetypes.NewStringNull() + } + if stateValue.NumPorts.IsNull() { + nullInStateFound = true + planSetValues[index].NumPorts = basetypes.NewStringNull() + } + if stateValue.PortAllocation.IsNull() { + nullInStateFound = true + planSetValues[index].PortAllocation = basetypes.NewStringNull() + } + if stateValue.PrimaryEncap.IsNull() { + nullInStateFound = true + planSetValues[index].PrimaryEncap = basetypes.NewStringNull() + } + if stateValue.PrimaryEncapInner.IsNull() { + nullInStateFound = true + planSetValues[index].PrimaryEncapInner = basetypes.NewStringNull() + } + if stateValue.ResImedcy.IsNull() { + nullInStateFound = true + planSetValues[index].ResImedcy = basetypes.NewStringNull() + } + if stateValue.SecondaryEncapInner.IsNull() { + nullInStateFound = true + planSetValues[index].SecondaryEncapInner = basetypes.NewStringNull() + } + if stateValue.SwitchingMode.IsNull() { + nullInStateFound = true + planSetValues[index].SwitchingMode = basetypes.NewStringNull() + } + if stateValue.TDn.IsNull() { + nullInStateFound = true + planSetValues[index].TDn = basetypes.NewStringNull() + } + if stateValue.Untagged.IsNull() { + nullInStateFound = true + planSetValues[index].Untagged = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsDomAttFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsDomAttFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsDomAttFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1070,6 +1254,46 @@ var FvRsFcPathAttFvAEPgType = types.ObjectType{ }, } +func FvRsFcPathAttFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsFcPathAttFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Descr.IsNull() { + nullInStateFound = true + planSetValues[index].Descr = basetypes.NewStringNull() + } + if stateValue.TDn.IsNull() { + nullInStateFound = true + planSetValues[index].TDn = basetypes.NewStringNull() + } + if stateValue.Vsan.IsNull() { + nullInStateFound = true + planSetValues[index].Vsan = basetypes.NewStringNull() + } + if stateValue.VsanMode.IsNull() { + nullInStateFound = true + planSetValues[index].VsanMode = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsFcPathAttFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsFcPathAttFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsFcPathAttFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1146,6 +1370,34 @@ var FvRsIntraEpgFvAEPgType = types.ObjectType{ }, } +func FvRsIntraEpgFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsIntraEpgFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.TnVzBrCPName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzBrCPName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsIntraEpgFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsIntraEpgFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsIntraEpgFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1234,6 +1486,50 @@ var FvRsNodeAttFvAEPgType = types.ObjectType{ }, } +func FvRsNodeAttFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsNodeAttFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Descr.IsNull() { + nullInStateFound = true + planSetValues[index].Descr = basetypes.NewStringNull() + } + if stateValue.Encap.IsNull() { + nullInStateFound = true + planSetValues[index].Encap = basetypes.NewStringNull() + } + if stateValue.InstrImedcy.IsNull() { + nullInStateFound = true + planSetValues[index].InstrImedcy = basetypes.NewStringNull() + } + if stateValue.Mode.IsNull() { + nullInStateFound = true + planSetValues[index].Mode = basetypes.NewStringNull() + } + if stateValue.TDn.IsNull() { + nullInStateFound = true + planSetValues[index].TDn = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsNodeAttFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsNodeAttFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsNodeAttFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1325,6 +1621,54 @@ var FvRsPathAttFvAEPgType = types.ObjectType{ }, } +func FvRsPathAttFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsPathAttFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Descr.IsNull() { + nullInStateFound = true + planSetValues[index].Descr = basetypes.NewStringNull() + } + if stateValue.Encap.IsNull() { + nullInStateFound = true + planSetValues[index].Encap = basetypes.NewStringNull() + } + if stateValue.InstrImedcy.IsNull() { + nullInStateFound = true + planSetValues[index].InstrImedcy = basetypes.NewStringNull() + } + if stateValue.Mode.IsNull() { + nullInStateFound = true + planSetValues[index].Mode = basetypes.NewStringNull() + } + if stateValue.PrimaryEncap.IsNull() { + nullInStateFound = true + planSetValues[index].PrimaryEncap = basetypes.NewStringNull() + } + if stateValue.TDn.IsNull() { + nullInStateFound = true + planSetValues[index].TDn = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsPathAttFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsPathAttFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsPathAttFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1401,6 +1745,34 @@ var FvRsProtByFvAEPgType = types.ObjectType{ }, } +func FvRsProtByFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsProtByFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.TnVzTabooName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzTabooName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsProtByFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsProtByFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsProtByFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1483,6 +1855,42 @@ var FvRsProvFvAEPgType = types.ObjectType{ }, } +func FvRsProvFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsProvFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.MatchT.IsNull() { + nullInStateFound = true + planSetValues[index].MatchT = basetypes.NewStringNull() + } + if stateValue.Prio.IsNull() { + nullInStateFound = true + planSetValues[index].Prio = customTypes.NewFvRsProvPrioStringNull() + } + if stateValue.TnVzBrCPName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzBrCPName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsProvFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsProvFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsProvFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1559,6 +1967,34 @@ var FvRsSecInheritedFvAEPgType = types.ObjectType{ }, } +func FvRsSecInheritedFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsSecInheritedFvAEPgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.TDn.IsNull() { + nullInStateFound = true + planSetValues[index].TDn = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsSecInheritedFvAEPgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsSecInheritedFvAEPgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsSecInheritedFvAEPgResourceModel struct { Key types.String `tfsdk:"key"` @@ -4186,6 +4622,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4220,6 +4657,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4282,6 +4720,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4316,6 +4755,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4378,6 +4818,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4412,6 +4853,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4448,6 +4890,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsConsFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4492,6 +4935,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4526,6 +4970,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4563,6 +5008,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsConsIfFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4607,6 +5053,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4641,6 +5088,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4704,6 +5152,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4738,6 +5187,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4774,6 +5224,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsDomAttFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5036,6 +5487,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5070,6 +5522,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5133,6 +5586,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5167,6 +5621,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5206,6 +5661,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsFcPathAttFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5264,6 +5720,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5298,6 +5755,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5339,6 +5797,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsIntraEpgFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5368,6 +5827,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5402,6 +5862,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5439,6 +5900,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsNodeAttFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5510,6 +5972,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5544,6 +6007,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5581,6 +6045,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsPathAttFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5661,6 +6126,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5695,6 +6161,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5732,6 +6199,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsProtByFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5761,6 +6229,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5795,6 +6264,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5832,6 +6302,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsProvFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5887,6 +6358,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5921,6 +6393,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5958,6 +6431,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsSecInheritedFvAEPgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -5987,6 +6461,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -6021,6 +6496,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -6084,6 +6560,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -6118,6 +6595,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -6154,6 +6632,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -6188,6 +6667,7 @@ func (r *FvAEPgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_bridge_domain.go b/internal/provider/resource_aci_bridge_domain.go index 41ebd5e32..1fd58aac5 100644 --- a/internal/provider/resource_aci_bridge_domain.go +++ b/internal/provider/resource_aci_bridge_domain.go @@ -423,6 +423,46 @@ var FvRogueExceptionMacFvBDType = types.ObjectType{ }, } +func FvRogueExceptionMacFvBDSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRogueExceptionMacFvBDResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Descr.IsNull() { + nullInStateFound = true + planSetValues[index].Descr = basetypes.NewStringNull() + } + if stateValue.Mac.IsNull() { + nullInStateFound = true + planSetValues[index].Mac = basetypes.NewStringNull() + } + if stateValue.Name.IsNull() { + nullInStateFound = true + planSetValues[index].Name = basetypes.NewStringNull() + } + if stateValue.NameAlias.IsNull() { + nullInStateFound = true + planSetValues[index].NameAlias = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRogueExceptionMacFvBDType, planSetValues) + return planSet + +} + // TagAnnotationFvRogueExceptionMacFvBDResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRogueExceptionMacFvBDResourceModel struct { Key types.String `tfsdk:"key"` @@ -724,6 +764,38 @@ var FvRsBDToNetflowMonitorPolFvBDType = types.ObjectType{ }, } +func FvRsBDToNetflowMonitorPolFvBDSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsBDToNetflowMonitorPolFvBDResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.FltType.IsNull() { + nullInStateFound = true + planSetValues[index].FltType = basetypes.NewStringNull() + } + if stateValue.TnNetflowMonitorPolName.IsNull() { + nullInStateFound = true + planSetValues[index].TnNetflowMonitorPolName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsBDToNetflowMonitorPolFvBDType, planSetValues) + return planSet + +} + // TagAnnotationFvRsBDToNetflowMonitorPolFvBDResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsBDToNetflowMonitorPolFvBDResourceModel struct { Key types.String `tfsdk:"key"` @@ -800,6 +872,34 @@ var FvRsBDToOutFvBDType = types.ObjectType{ }, } +func FvRsBDToOutFvBDSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsBDToOutFvBDResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.TnL3extOutName.IsNull() { + nullInStateFound = true + planSetValues[index].TnL3extOutName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsBDToOutFvBDType, planSetValues) + return planSet + +} + // TagAnnotationFvRsBDToOutFvBDResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsBDToOutFvBDResourceModel struct { Key types.String `tfsdk:"key"` @@ -3471,6 +3571,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3497,6 +3598,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3525,6 +3627,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRogueExceptionMacFvBDSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3573,6 +3676,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3599,6 +3703,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3652,6 +3757,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3678,6 +3784,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3730,6 +3837,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3756,6 +3864,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3808,6 +3917,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3834,6 +3944,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3862,6 +3973,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsBDToNetflowMonitorPolFvBDSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3897,6 +4009,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3923,6 +4036,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3952,6 +4066,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsBDToOutFvBDSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -3976,6 +4091,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4002,6 +4118,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4063,6 +4180,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4089,6 +4207,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4141,6 +4260,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4167,6 +4287,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4230,6 +4351,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4256,6 +4378,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4308,6 +4431,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4334,6 +4458,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4386,6 +4511,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4412,6 +4538,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4464,6 +4591,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4490,6 +4618,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4518,6 +4647,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -4544,6 +4674,7 @@ func (r *FvBDResource) Schema(ctx context.Context, req resource.SchemaRequest, r Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_certificate_authority.go b/internal/provider/resource_aci_certificate_authority.go index d1a24fbd2..f078939a8 100644 --- a/internal/provider/resource_aci_certificate_authority.go +++ b/internal/provider/resource_aci_certificate_authority.go @@ -208,7 +208,7 @@ func (r *PkiTPResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), - SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, Validators: []validator.Set{ setvalidator.SizeAtMost(2), @@ -269,6 +269,7 @@ func (r *PkiTPResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -295,6 +296,7 @@ func (r *PkiTPResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_custom_qos_policy.go b/internal/provider/resource_aci_custom_qos_policy.go index 67eba93aa..1116e572e 100644 --- a/internal/provider/resource_aci_custom_qos_policy.go +++ b/internal/provider/resource_aci_custom_qos_policy.go @@ -235,6 +235,7 @@ func (r *QosCustomPolResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -261,6 +262,7 @@ func (r *QosCustomPolResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_data_plane_policing_policy.go b/internal/provider/resource_aci_data_plane_policing_policy.go index 5349561f6..ecdfff6cd 100644 --- a/internal/provider/resource_aci_data_plane_policing_policy.go +++ b/internal/provider/resource_aci_data_plane_policing_policy.go @@ -561,6 +561,7 @@ func (r *QosDppPolResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -587,6 +588,7 @@ func (r *QosDppPolResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_endpoint_security_group.go b/internal/provider/resource_aci_endpoint_security_group.go index 0177a54eb..e4fc192dd 100644 --- a/internal/provider/resource_aci_endpoint_security_group.go +++ b/internal/provider/resource_aci_endpoint_security_group.go @@ -210,6 +210,38 @@ var FvRsConsFvESgType = types.ObjectType{ }, } +func FvRsConsFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsConsFvESgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Prio.IsNull() { + nullInStateFound = true + planSetValues[index].Prio = customTypes.NewFvRsConsPrioStringNull() + } + if stateValue.TnVzBrCPName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzBrCPName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsConsFvESgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsConsFvESgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsConsFvESgResourceModel struct { Key types.String `tfsdk:"key"` @@ -289,6 +321,38 @@ var FvRsConsIfFvESgType = types.ObjectType{ }, } +func FvRsConsIfFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsConsIfFvESgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Prio.IsNull() { + nullInStateFound = true + planSetValues[index].Prio = customTypes.NewFvRsConsIfPrioStringNull() + } + if stateValue.TnVzCPIfName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzCPIfName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsConsIfFvESgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsConsIfFvESgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsConsIfFvESgResourceModel struct { Key types.String `tfsdk:"key"` @@ -365,6 +429,34 @@ var FvRsIntraEpgFvESgType = types.ObjectType{ }, } +func FvRsIntraEpgFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsIntraEpgFvESgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.TnVzBrCPName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzBrCPName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsIntraEpgFvESgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsIntraEpgFvESgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsIntraEpgFvESgResourceModel struct { Key types.String `tfsdk:"key"` @@ -447,6 +539,42 @@ var FvRsProvFvESgType = types.ObjectType{ }, } +func FvRsProvFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsProvFvESgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.MatchT.IsNull() { + nullInStateFound = true + planSetValues[index].MatchT = basetypes.NewStringNull() + } + if stateValue.Prio.IsNull() { + nullInStateFound = true + planSetValues[index].Prio = customTypes.NewFvRsProvPrioStringNull() + } + if stateValue.TnVzBrCPName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzBrCPName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsProvFvESgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsProvFvESgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsProvFvESgResourceModel struct { Key types.String `tfsdk:"key"` @@ -597,6 +725,34 @@ var FvRsSecInheritedFvESgType = types.ObjectType{ }, } +func FvRsSecInheritedFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvRsSecInheritedFvESgResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.TDn.IsNull() { + nullInStateFound = true + planSetValues[index].TDn = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvRsSecInheritedFvESgType, planSetValues) + return planSet + +} + // TagAnnotationFvRsSecInheritedFvESgResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvRsSecInheritedFvESgResourceModel struct { Key types.String `tfsdk:"key"` @@ -1943,6 +2099,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsConsFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1987,6 +2144,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2021,6 +2179,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2058,6 +2217,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsConsIfFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2102,6 +2262,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2136,6 +2297,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2177,6 +2339,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsIntraEpgFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2206,6 +2369,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2240,6 +2404,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2277,6 +2442,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsProvFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2332,6 +2498,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2366,6 +2533,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2429,6 +2597,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2463,6 +2632,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2499,6 +2669,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvRsSecInheritedFvESgSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2528,6 +2699,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2562,6 +2734,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2599,6 +2772,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2633,6 +2807,7 @@ func (r *FvESgResource) Schema(ctx context.Context, req resource.SchemaRequest, Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_endpoint_tag_ip.go b/internal/provider/resource_aci_endpoint_tag_ip.go index 1300f50a7..d0ee088b8 100644 --- a/internal/provider/resource_aci_endpoint_tag_ip.go +++ b/internal/provider/resource_aci_endpoint_tag_ip.go @@ -237,6 +237,7 @@ func (r *FvEpIpTagResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -263,6 +264,7 @@ func (r *FvEpIpTagResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_endpoint_tag_mac.go b/internal/provider/resource_aci_endpoint_tag_mac.go index 8408a81ab..173852967 100644 --- a/internal/provider/resource_aci_endpoint_tag_mac.go +++ b/internal/provider/resource_aci_endpoint_tag_mac.go @@ -237,6 +237,7 @@ func (r *FvEpMacTagResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -263,6 +264,7 @@ func (r *FvEpMacTagResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_epg_useg_ad_group_attribute.go b/internal/provider/resource_aci_epg_useg_ad_group_attribute.go index 272ef1544..ae1f0e88f 100644 --- a/internal/provider/resource_aci_epg_useg_ad_group_attribute.go +++ b/internal/provider/resource_aci_epg_useg_ad_group_attribute.go @@ -246,6 +246,7 @@ func (r *FvIdGroupAttrResource) Schema(ctx context.Context, req resource.SchemaR Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -272,6 +273,7 @@ func (r *FvIdGroupAttrResource) Schema(ctx context.Context, req resource.SchemaR Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_epg_useg_block_statement.go b/internal/provider/resource_aci_epg_useg_block_statement.go index ef48597f5..e72bcb5e8 100644 --- a/internal/provider/resource_aci_epg_useg_block_statement.go +++ b/internal/provider/resource_aci_epg_useg_block_statement.go @@ -272,6 +272,7 @@ func (r *FvCrtrnResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -298,6 +299,7 @@ func (r *FvCrtrnResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_epg_useg_dns_attribute.go b/internal/provider/resource_aci_epg_useg_dns_attribute.go index 9bc1d0f3c..e5f629afb 100644 --- a/internal/provider/resource_aci_epg_useg_dns_attribute.go +++ b/internal/provider/resource_aci_epg_useg_dns_attribute.go @@ -246,6 +246,7 @@ func (r *FvDnsAttrResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -272,6 +273,7 @@ func (r *FvDnsAttrResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_epg_useg_ip_attribute.go b/internal/provider/resource_aci_epg_useg_ip_attribute.go index 88a7b085e..c257fbb59 100644 --- a/internal/provider/resource_aci_epg_useg_ip_attribute.go +++ b/internal/provider/resource_aci_epg_useg_ip_attribute.go @@ -261,6 +261,7 @@ func (r *FvIpAttrResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -287,6 +288,7 @@ func (r *FvIpAttrResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_epg_useg_mac_attribute.go b/internal/provider/resource_aci_epg_useg_mac_attribute.go index fe8a5e9ac..caffa5335 100644 --- a/internal/provider/resource_aci_epg_useg_mac_attribute.go +++ b/internal/provider/resource_aci_epg_useg_mac_attribute.go @@ -245,6 +245,7 @@ func (r *FvMacAttrResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -271,6 +272,7 @@ func (r *FvMacAttrResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_epg_useg_sub_block_statement.go b/internal/provider/resource_aci_epg_useg_sub_block_statement.go index 57b0d3ce2..866365aec 100644 --- a/internal/provider/resource_aci_epg_useg_sub_block_statement.go +++ b/internal/provider/resource_aci_epg_useg_sub_block_statement.go @@ -251,6 +251,7 @@ func (r *FvSCrtrnResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -277,6 +278,7 @@ func (r *FvSCrtrnResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_epg_useg_vm_attribute.go b/internal/provider/resource_aci_epg_useg_vm_attribute.go index 044e46b3f..fec878d92 100644 --- a/internal/provider/resource_aci_epg_useg_vm_attribute.go +++ b/internal/provider/resource_aci_epg_useg_vm_attribute.go @@ -297,6 +297,7 @@ func (r *FvVmAttrResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -323,6 +324,7 @@ func (r *FvVmAttrResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_external_management_network_instance_profile.go b/internal/provider/resource_aci_external_management_network_instance_profile.go index 458166b1e..07ac5a2b7 100644 --- a/internal/provider/resource_aci_external_management_network_instance_profile.go +++ b/internal/provider/resource_aci_external_management_network_instance_profile.go @@ -127,6 +127,38 @@ var MgmtRsOoBConsMgmtInstPType = types.ObjectType{ }, } +func MgmtRsOoBConsMgmtInstPSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []MgmtRsOoBConsMgmtInstPResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Prio.IsNull() { + nullInStateFound = true + planSetValues[index].Prio = customTypes.NewMgmtRsOoBConsPrioStringNull() + } + if stateValue.TnVzOOBBrCPName.IsNull() { + nullInStateFound = true + planSetValues[index].TnVzOOBBrCPName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, MgmtRsOoBConsMgmtInstPType, planSetValues) + return planSet + +} + // TagAnnotationMgmtRsOoBConsMgmtInstPResourceModel describes the resource data model for the children without relation ships. type TagAnnotationMgmtRsOoBConsMgmtInstPResourceModel struct { Key types.String `tfsdk:"key"` @@ -315,6 +347,7 @@ func (r *MgmtInstPResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(MgmtRsOoBConsMgmtInstPSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -354,6 +387,7 @@ func (r *MgmtInstPResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -380,6 +414,7 @@ func (r *MgmtInstPResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -409,6 +444,7 @@ func (r *MgmtInstPResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -435,6 +471,7 @@ func (r *MgmtInstPResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_external_management_network_subnet.go b/internal/provider/resource_aci_external_management_network_subnet.go index 4ce69bbf2..537309927 100644 --- a/internal/provider/resource_aci_external_management_network_subnet.go +++ b/internal/provider/resource_aci_external_management_network_subnet.go @@ -224,6 +224,7 @@ func (r *MgmtSubnetResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -250,6 +251,7 @@ func (r *MgmtSubnetResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_first_hop_security_policy.go b/internal/provider/resource_aci_first_hop_security_policy.go index 75a519c0d..dfcecf0b0 100644 --- a/internal/provider/resource_aci_first_hop_security_policy.go +++ b/internal/provider/resource_aci_first_hop_security_policy.go @@ -539,6 +539,7 @@ func (r *FhsBDPolResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -565,6 +566,7 @@ func (r *FhsBDPolResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -593,6 +595,7 @@ func (r *FhsBDPolResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -619,6 +622,7 @@ func (r *FhsBDPolResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_igmp_snooping_policy.go b/internal/provider/resource_aci_igmp_snooping_policy.go index 8018726c1..28549405c 100644 --- a/internal/provider/resource_aci_igmp_snooping_policy.go +++ b/internal/provider/resource_aci_igmp_snooping_policy.go @@ -222,7 +222,7 @@ func (r *IgmpSnoopPolResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), - SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, Validators: []validator.Set{ setvalidator.SizeAtMost(4), @@ -340,6 +340,7 @@ func (r *IgmpSnoopPolResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -366,6 +367,7 @@ func (r *IgmpSnoopPolResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_key_ring.go b/internal/provider/resource_aci_key_ring.go index 355020b09..e6b5fd7fa 100644 --- a/internal/provider/resource_aci_key_ring.go +++ b/internal/provider/resource_aci_key_ring.go @@ -343,6 +343,7 @@ func (r *PkiKeyRingResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -369,6 +370,7 @@ func (r *PkiKeyRingResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_l3out_consumer_label.go b/internal/provider/resource_aci_l3out_consumer_label.go index 1a27f1738..89e678e35 100644 --- a/internal/provider/resource_aci_l3out_consumer_label.go +++ b/internal/provider/resource_aci_l3out_consumer_label.go @@ -138,6 +138,34 @@ var L3extRsLblToInstPL3extConsLblType = types.ObjectType{ }, } +func L3extRsLblToInstPL3extConsLblSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []L3extRsLblToInstPL3extConsLblResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.TDn.IsNull() { + nullInStateFound = true + planSetValues[index].TDn = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, L3extRsLblToInstPL3extConsLblType, planSetValues) + return planSet + +} + // TagAnnotationL3extRsLblToInstPL3extConsLblResourceModel describes the resource data model for the children without relation ships. type TagAnnotationL3extRsLblToInstPL3extConsLblResourceModel struct { Key types.String `tfsdk:"key"` @@ -217,6 +245,38 @@ var L3extRsLblToProfileL3extConsLblType = types.ObjectType{ }, } +func L3extRsLblToProfileL3extConsLblSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []L3extRsLblToProfileL3extConsLblResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Direction.IsNull() { + nullInStateFound = true + planSetValues[index].Direction = basetypes.NewStringNull() + } + if stateValue.TDn.IsNull() { + nullInStateFound = true + planSetValues[index].TDn = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, L3extRsLblToProfileL3extConsLblType, planSetValues) + return planSet + +} + // TagAnnotationL3extRsLblToProfileL3extConsLblResourceModel describes the resource data model for the children without relation ships. type TagAnnotationL3extRsLblToProfileL3extConsLblResourceModel struct { Key types.String `tfsdk:"key"` @@ -439,6 +499,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(L3extRsLblToInstPL3extConsLblSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -463,6 +524,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -489,6 +551,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -518,6 +581,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(L3extRsLblToProfileL3extConsLblSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -553,6 +617,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -579,6 +644,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -608,6 +674,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -634,6 +701,7 @@ func (r *L3extConsLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_l3out_node_sid_profile.go b/internal/provider/resource_aci_l3out_node_sid_profile.go index 4b18cc99b..e55109677 100644 --- a/internal/provider/resource_aci_l3out_node_sid_profile.go +++ b/internal/provider/resource_aci_l3out_node_sid_profile.go @@ -235,6 +235,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -261,6 +262,7 @@ func (r *MplsNodeSidPResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_l3out_provider_label.go b/internal/provider/resource_aci_l3out_provider_label.go index 9f1ed80eb..27e62b130 100644 --- a/internal/provider/resource_aci_l3out_provider_label.go +++ b/internal/provider/resource_aci_l3out_provider_label.go @@ -251,6 +251,7 @@ func (r *L3extProvLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -277,6 +278,7 @@ func (r *L3extProvLblResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_l3out_redistribute_policy.go b/internal/provider/resource_aci_l3out_redistribute_policy.go index 2297e9c4d..b408289fa 100644 --- a/internal/provider/resource_aci_l3out_redistribute_policy.go +++ b/internal/provider/resource_aci_l3out_redistribute_policy.go @@ -208,6 +208,7 @@ func (r *L3extRsRedistributePolResource) Schema(ctx context.Context, req resourc Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -234,6 +235,7 @@ func (r *L3extRsRedistributePolResource) Schema(ctx context.Context, req resourc Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_management_access_policy.go b/internal/provider/resource_aci_management_access_policy.go index aba7a8afb..813ddb29e 100644 --- a/internal/provider/resource_aci_management_access_policy.go +++ b/internal/provider/resource_aci_management_access_policy.go @@ -1357,6 +1357,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1383,6 +1384,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1659,6 +1661,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1685,6 +1688,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1737,6 +1741,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1763,6 +1768,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1791,6 +1797,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1817,6 +1824,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1896,6 +1904,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -1922,6 +1931,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2080,6 +2090,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2106,6 +2117,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2193,6 +2205,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2219,6 +2232,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2247,6 +2261,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -2273,6 +2288,7 @@ func (r *CommPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_mld_snooping_policy.go b/internal/provider/resource_aci_mld_snooping_policy.go index 4f78f55af..f014facde 100644 --- a/internal/provider/resource_aci_mld_snooping_policy.go +++ b/internal/provider/resource_aci_mld_snooping_policy.go @@ -222,7 +222,7 @@ func (r *MldSnoopPolResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), - SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, Validators: []validator.Set{ setvalidator.SizeAtMost(4), @@ -340,6 +340,7 @@ func (r *MldSnoopPolResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -366,6 +367,7 @@ func (r *MldSnoopPolResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_neighbor_discovery_interface_policy.go b/internal/provider/resource_aci_neighbor_discovery_interface_policy.go index acc585d11..ccb582534 100644 --- a/internal/provider/resource_aci_neighbor_discovery_interface_policy.go +++ b/internal/provider/resource_aci_neighbor_discovery_interface_policy.go @@ -218,7 +218,7 @@ func (r *NdIfPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), - SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, Validators: []validator.Set{ setvalidator.SizeAtMost(6), @@ -378,6 +378,7 @@ func (r *NdIfPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -404,6 +405,7 @@ func (r *NdIfPolResource) Schema(ctx context.Context, req resource.SchemaRequest Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_netflow_exporter_policy.go b/internal/provider/resource_aci_netflow_exporter_policy.go index 918c7e050..2b7a694a3 100644 --- a/internal/provider/resource_aci_netflow_exporter_policy.go +++ b/internal/provider/resource_aci_netflow_exporter_policy.go @@ -525,6 +525,7 @@ func (r *NetflowExporterPolResource) Schema(ctx context.Context, req resource.Sc Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -551,6 +552,7 @@ func (r *NetflowExporterPolResource) Schema(ctx context.Context, req resource.Sc Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -603,6 +605,7 @@ func (r *NetflowExporterPolResource) Schema(ctx context.Context, req resource.Sc Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -629,6 +632,7 @@ func (r *NetflowExporterPolResource) Schema(ctx context.Context, req resource.Sc Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -657,6 +661,7 @@ func (r *NetflowExporterPolResource) Schema(ctx context.Context, req resource.Sc Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -683,6 +688,7 @@ func (r *NetflowExporterPolResource) Schema(ctx context.Context, req resource.Sc Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_netflow_monitor_policy.go b/internal/provider/resource_aci_netflow_monitor_policy.go index 46b3375ad..9a08f373b 100644 --- a/internal/provider/resource_aci_netflow_monitor_policy.go +++ b/internal/provider/resource_aci_netflow_monitor_policy.go @@ -130,6 +130,34 @@ var NetflowRsMonitorToExporterNetflowMonitorPolType = types.ObjectType{ }, } +func NetflowRsMonitorToExporterNetflowMonitorPolSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []NetflowRsMonitorToExporterNetflowMonitorPolResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.TnNetflowExporterPolName.IsNull() { + nullInStateFound = true + planSetValues[index].TnNetflowExporterPolName = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, NetflowRsMonitorToExporterNetflowMonitorPolType, planSetValues) + return planSet + +} + // TagAnnotationNetflowRsMonitorToExporterNetflowMonitorPolResourceModel describes the resource data model for the children without relation ships. type TagAnnotationNetflowRsMonitorToExporterNetflowMonitorPolResourceModel struct { Key types.String `tfsdk:"key"` @@ -588,6 +616,7 @@ func (r *NetflowMonitorPolResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(NetflowRsMonitorToExporterNetflowMonitorPolSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -612,6 +641,7 @@ func (r *NetflowMonitorPolResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -638,6 +668,7 @@ func (r *NetflowMonitorPolResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -691,6 +722,7 @@ func (r *NetflowMonitorPolResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -717,6 +749,7 @@ func (r *NetflowMonitorPolResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -745,6 +778,7 @@ func (r *NetflowMonitorPolResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -771,6 +805,7 @@ func (r *NetflowMonitorPolResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_netflow_record_policy.go b/internal/provider/resource_aci_netflow_record_policy.go index dee1fe244..d0fd3a1cb 100644 --- a/internal/provider/resource_aci_netflow_record_policy.go +++ b/internal/provider/resource_aci_netflow_record_policy.go @@ -200,7 +200,7 @@ func (r *NetflowRecordPolResource) Schema(ctx context.Context, req resource.Sche Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), - SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, Validators: []validator.Set{ setvalidator.SizeAtMost(8), @@ -225,7 +225,7 @@ func (r *NetflowRecordPolResource) Schema(ctx context.Context, req resource.Sche Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), - SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, Validators: []validator.Set{ setvalidator.SizeAtMost(14), @@ -277,6 +277,7 @@ func (r *NetflowRecordPolResource) Schema(ctx context.Context, req resource.Sche Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -303,6 +304,7 @@ func (r *NetflowRecordPolResource) Schema(ctx context.Context, req resource.Sche Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_out_of_band_contract.go b/internal/provider/resource_aci_out_of_band_contract.go index 4d7bc5543..dc570d4fd 100644 --- a/internal/provider/resource_aci_out_of_band_contract.go +++ b/internal/provider/resource_aci_out_of_band_contract.go @@ -294,6 +294,7 @@ func (r *VzOOBBrCPResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -320,6 +321,7 @@ func (r *VzOOBBrCPResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_pim_route_map_entry.go b/internal/provider/resource_aci_pim_route_map_entry.go index 39ec7d6c7..8f8f48f1c 100644 --- a/internal/provider/resource_aci_pim_route_map_entry.go +++ b/internal/provider/resource_aci_pim_route_map_entry.go @@ -273,6 +273,7 @@ func (r *PimRouteMapEntryResource) Schema(ctx context.Context, req resource.Sche Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -299,6 +300,7 @@ func (r *PimRouteMapEntryResource) Schema(ctx context.Context, req resource.Sche Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_pim_route_map_policy.go b/internal/provider/resource_aci_pim_route_map_policy.go index 63077ce6a..a7255176f 100644 --- a/internal/provider/resource_aci_pim_route_map_policy.go +++ b/internal/provider/resource_aci_pim_route_map_policy.go @@ -235,6 +235,7 @@ func (r *PimRouteMapPolResource) Schema(ctx context.Context, req resource.Schema Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -261,6 +262,7 @@ func (r *PimRouteMapPolResource) Schema(ctx context.Context, req resource.Schema Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_from_bridge_domain_to_l3_outside.go b/internal/provider/resource_aci_relation_from_bridge_domain_to_l3_outside.go index b095d702f..152873ed8 100644 --- a/internal/provider/resource_aci_relation_from_bridge_domain_to_l3_outside.go +++ b/internal/provider/resource_aci_relation_from_bridge_domain_to_l3_outside.go @@ -191,6 +191,7 @@ func (r *FvRsBDToOutResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -217,6 +218,7 @@ func (r *FvRsBDToOutResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_from_bridge_domain_to_netflow_monitor_policy.go b/internal/provider/resource_aci_relation_from_bridge_domain_to_netflow_monitor_policy.go index 054842f2d..59785b334 100644 --- a/internal/provider/resource_aci_relation_from_bridge_domain_to_netflow_monitor_policy.go +++ b/internal/provider/resource_aci_relation_from_bridge_domain_to_netflow_monitor_policy.go @@ -208,6 +208,7 @@ func (r *FvRsBDToNetflowMonitorPolResource) Schema(ctx context.Context, req reso Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -234,6 +235,7 @@ func (r *FvRsBDToNetflowMonitorPolResource) Schema(ctx context.Context, req reso Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go index 8e9e51210..c7ebe2141 100644 --- a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go +++ b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go @@ -191,6 +191,7 @@ func (r *L3extRsLblToInstPResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -217,6 +218,7 @@ func (r *L3extRsLblToInstPResource) Schema(ctx context.Context, req resource.Sch Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go index 2f3a6f640..4df60f920 100644 --- a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go +++ b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go @@ -208,6 +208,7 @@ func (r *L3extRsLblToProfileResource) Schema(ctx context.Context, req resource.S Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -234,6 +235,7 @@ func (r *L3extRsLblToProfileResource) Schema(ctx context.Context, req resource.S Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_consumed_contract.go b/internal/provider/resource_aci_relation_to_consumed_contract.go index 5f4163f9d..6c06594b7 100644 --- a/internal/provider/resource_aci_relation_to_consumed_contract.go +++ b/internal/provider/resource_aci_relation_to_consumed_contract.go @@ -213,6 +213,7 @@ func (r *FvRsConsResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -239,6 +240,7 @@ func (r *FvRsConsResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go b/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go index 04b9f7a64..f046de2e0 100644 --- a/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go +++ b/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go @@ -213,6 +213,7 @@ func (r *MgmtRsOoBConsResource) Schema(ctx context.Context, req resource.SchemaR Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -239,6 +240,7 @@ func (r *MgmtRsOoBConsResource) Schema(ctx context.Context, req resource.SchemaR Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_contract_master.go b/internal/provider/resource_aci_relation_to_contract_master.go index a3727439f..a5b810cd8 100644 --- a/internal/provider/resource_aci_relation_to_contract_master.go +++ b/internal/provider/resource_aci_relation_to_contract_master.go @@ -191,6 +191,7 @@ func (r *FvRsSecInheritedResource) Schema(ctx context.Context, req resource.Sche Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -217,6 +218,7 @@ func (r *FvRsSecInheritedResource) Schema(ctx context.Context, req resource.Sche Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_domain.go b/internal/provider/resource_aci_relation_to_domain.go index 22adf68aa..fb30182ed 100644 --- a/internal/provider/resource_aci_relation_to_domain.go +++ b/internal/provider/resource_aci_relation_to_domain.go @@ -486,6 +486,7 @@ func (r *FvRsDomAttResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -512,6 +513,7 @@ func (r *FvRsDomAttResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_fibre_channel_path.go b/internal/provider/resource_aci_relation_to_fibre_channel_path.go index 48c6ea3c7..c4a88d9f8 100644 --- a/internal/provider/resource_aci_relation_to_fibre_channel_path.go +++ b/internal/provider/resource_aci_relation_to_fibre_channel_path.go @@ -229,6 +229,7 @@ func (r *FvRsFcPathAttResource) Schema(ctx context.Context, req resource.SchemaR Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -255,6 +256,7 @@ func (r *FvRsFcPathAttResource) Schema(ctx context.Context, req resource.SchemaR Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_imported_contract.go b/internal/provider/resource_aci_relation_to_imported_contract.go index 4eac1a5c8..4038f122f 100644 --- a/internal/provider/resource_aci_relation_to_imported_contract.go +++ b/internal/provider/resource_aci_relation_to_imported_contract.go @@ -213,6 +213,7 @@ func (r *FvRsConsIfResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -239,6 +240,7 @@ func (r *FvRsConsIfResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_intra_epg_contract.go b/internal/provider/resource_aci_relation_to_intra_epg_contract.go index 486c3fbf6..3c4f61c6e 100644 --- a/internal/provider/resource_aci_relation_to_intra_epg_contract.go +++ b/internal/provider/resource_aci_relation_to_intra_epg_contract.go @@ -191,6 +191,7 @@ func (r *FvRsIntraEpgResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -217,6 +218,7 @@ func (r *FvRsIntraEpgResource) Schema(ctx context.Context, req resource.SchemaRe Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_netflow_exporter.go b/internal/provider/resource_aci_relation_to_netflow_exporter.go index 01f4c984c..7907d2790 100644 --- a/internal/provider/resource_aci_relation_to_netflow_exporter.go +++ b/internal/provider/resource_aci_relation_to_netflow_exporter.go @@ -191,6 +191,7 @@ func (r *NetflowRsMonitorToExporterResource) Schema(ctx context.Context, req res Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -217,6 +218,7 @@ func (r *NetflowRsMonitorToExporterResource) Schema(ctx context.Context, req res Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_provided_contract.go b/internal/provider/resource_aci_relation_to_provided_contract.go index e8e44ec37..c3ccd402d 100644 --- a/internal/provider/resource_aci_relation_to_provided_contract.go +++ b/internal/provider/resource_aci_relation_to_provided_contract.go @@ -227,6 +227,7 @@ func (r *FvRsProvResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -253,6 +254,7 @@ func (r *FvRsProvResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_static_leaf.go b/internal/provider/resource_aci_relation_to_static_leaf.go index 7cb074d01..d0841da75 100644 --- a/internal/provider/resource_aci_relation_to_static_leaf.go +++ b/internal/provider/resource_aci_relation_to_static_leaf.go @@ -242,6 +242,7 @@ func (r *FvRsNodeAttResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -268,6 +269,7 @@ func (r *FvRsNodeAttResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_static_path.go b/internal/provider/resource_aci_relation_to_static_path.go index 61b6215ea..c0a7e592a 100644 --- a/internal/provider/resource_aci_relation_to_static_path.go +++ b/internal/provider/resource_aci_relation_to_static_path.go @@ -253,6 +253,7 @@ func (r *FvRsPathAttResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -279,6 +280,7 @@ func (r *FvRsPathAttResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_taboo_contract.go b/internal/provider/resource_aci_relation_to_taboo_contract.go index 6a86ae6df..0c2b31b33 100644 --- a/internal/provider/resource_aci_relation_to_taboo_contract.go +++ b/internal/provider/resource_aci_relation_to_taboo_contract.go @@ -191,6 +191,7 @@ func (r *FvRsProtByResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -217,6 +218,7 @@ func (r *FvRsProtByResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go index 42ec80bb1..72378ad64 100644 --- a/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go +++ b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go @@ -191,6 +191,7 @@ func (r *L3extRsOutToFBRGroupResource) Schema(ctx context.Context, req resource. Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -217,6 +218,7 @@ func (r *L3extRsOutToFBRGroupResource) Schema(ctx context.Context, req resource. Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_rogue_coop_exception.go b/internal/provider/resource_aci_rogue_coop_exception.go index 94408c0a7..3e491edd1 100644 --- a/internal/provider/resource_aci_rogue_coop_exception.go +++ b/internal/provider/resource_aci_rogue_coop_exception.go @@ -224,6 +224,7 @@ func (r *FvRogueExceptionMacResource) Schema(ctx context.Context, req resource.S Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -250,6 +251,7 @@ func (r *FvRogueExceptionMacResource) Schema(ctx context.Context, req resource.S Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_route_control_profile.go b/internal/provider/resource_aci_route_control_profile.go index 9f4f91d63..310a69b39 100644 --- a/internal/provider/resource_aci_route_control_profile.go +++ b/internal/provider/resource_aci_route_control_profile.go @@ -266,6 +266,7 @@ func (r *RtctrlProfileResource) Schema(ctx context.Context, req resource.SchemaR Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -292,6 +293,7 @@ func (r *RtctrlProfileResource) Schema(ctx context.Context, req resource.SchemaR Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_trust_control_policy.go b/internal/provider/resource_aci_trust_control_policy.go index ef816f025..163aaa8aa 100644 --- a/internal/provider/resource_aci_trust_control_policy.go +++ b/internal/provider/resource_aci_trust_control_policy.go @@ -321,6 +321,7 @@ func (r *FhsTrustCtrlPolResource) Schema(ctx context.Context, req resource.Schem Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -347,6 +348,7 @@ func (r *FhsTrustCtrlPolResource) Schema(ctx context.Context, req resource.Schem Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_vrf_fallback_route.go b/internal/provider/resource_aci_vrf_fallback_route.go index 868ef59de..500224881 100644 --- a/internal/provider/resource_aci_vrf_fallback_route.go +++ b/internal/provider/resource_aci_vrf_fallback_route.go @@ -224,6 +224,7 @@ func (r *FvFBRouteResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -250,6 +251,7 @@ func (r *FvFBRouteResource) Schema(ctx context.Context, req resource.SchemaReque Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_vrf_fallback_route_group.go b/internal/provider/resource_aci_vrf_fallback_route_group.go index 720c0843d..d8e79daed 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group.go @@ -142,6 +142,46 @@ var FvFBRMemberFvFBRGroupType = types.ObjectType{ }, } +func FvFBRMemberFvFBRGroupSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(ctx context.Context, planValue, stateValue types.Set) basetypes.SetValue { + var planSetValues, stateSetValues []FvFBRMemberFvFBRGroupResourceModel + stateValue.ElementsAs(ctx, &stateSetValues, false) + planValue.ElementsAs(ctx, &planSetValues, false) + + // If the length of the state and plan values are different a change is already detected thus reflection can be skipped + if len(stateSetValues) == len(planSetValues) { + for index, stateValue := range stateSetValues { + nullInStateFound := false + if stateValue.Annotation.IsNull() { + nullInStateFound = true + planSetValues[index].Annotation = basetypes.NewStringNull() + } + if stateValue.Descr.IsNull() { + nullInStateFound = true + planSetValues[index].Descr = basetypes.NewStringNull() + } + if stateValue.Name.IsNull() { + nullInStateFound = true + planSetValues[index].Name = basetypes.NewStringNull() + } + if stateValue.NameAlias.IsNull() { + nullInStateFound = true + planSetValues[index].NameAlias = basetypes.NewStringNull() + } + if stateValue.RnhAddr.IsNull() { + nullInStateFound = true + planSetValues[index].RnhAddr = basetypes.NewStringNull() + } + if !nullInStateFound { + // when there are no null fields we can conclude the version supports all attributes in set + break + } + } + } + planSet, _ := types.SetValueFrom(ctx, FvFBRMemberFvFBRGroupType, planSetValues) + return planSet + +} + // TagAnnotationFvFBRMemberFvFBRGroupResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvFBRMemberFvFBRGroupResourceModel struct { Key types.String `tfsdk:"key"` @@ -412,6 +452,7 @@ func (r *FvFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(FvFBRMemberFvFBRGroupSetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -460,6 +501,7 @@ func (r *FvFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -486,6 +528,7 @@ func (r *FvFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -566,6 +609,7 @@ func (r *FvFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -592,6 +636,7 @@ func (r *FvFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -620,6 +665,7 @@ func (r *FvFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -646,6 +692,7 @@ func (r *FvFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequ Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/resource_aci_vrf_fallback_route_group_member.go b/internal/provider/resource_aci_vrf_fallback_route_group_member.go index 2650d07fb..bbb61d8e4 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group_member.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group_member.go @@ -224,6 +224,7 @@ func (r *FvFBRMemberResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -250,6 +251,7 @@ func (r *FvFBRMemberResource) Schema(ctx context.Context, req resource.SchemaReq Computed: true, PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), + SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(nil), }, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ diff --git a/internal/provider/utils.go b/internal/provider/utils.go index ea7a11655..b49803748 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -170,10 +170,14 @@ func (m setToStringNullWhenStateIsNullPlanIsUnknownDuringUpdate) PlanModifyStrin } } -type setToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate struct{} +type setToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate struct { + resourceFunction func(ctx context.Context, planValue types.Set, stateValue types.Set) types.Set +} -func SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate() planmodifier.Set { - return setToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate{} +func SetToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate(resourceFunction func(ctx context.Context, planValue types.Set, stateValue types.Set) types.Set) planmodifier.Set { + return setToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate{ + resourceFunction: resourceFunction, + } } func (m setToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate) Description(_ context.Context) string { @@ -189,6 +193,8 @@ func (m setToSetNullWhenStateIsNullPlanIsUnknownDuringUpdate) PlanModifySet(ctx // Set the plan value to SetType null when state value is null and plan value is unknown during an Update if !req.State.Raw.IsNull() && req.StateValue.IsNull() && req.PlanValue.IsUnknown() { resp.PlanValue = types.SetNull(req.StateValue.ElementType(ctx)) + } else if !req.State.Raw.IsNull() && !req.StateValue.IsNull() && !req.PlanValue.IsUnknown() && m.resourceFunction != nil { + resp.PlanValue = m.resourceFunction(ctx, req.PlanValue, req.StateValue) } }