fix(networkinterface): Recognize the removal of allowed_addresses and security_group_ids from terraform config (#940)
Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
This commit is contained in:
parent
721e10a02f
commit
f16b83170a
3 changed files with 172 additions and 0 deletions
|
|
@ -7,7 +7,10 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/hashicorp/terraform-plugin-framework/path"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
|
|
@ -157,3 +160,16 @@ func FormatPossibleValues(values ...string) string {
|
|||
func BuildInternalTerraformId(idParts ...string) types.String {
|
||||
return types.StringValue(strings.Join(idParts, core.Separator))
|
||||
}
|
||||
|
||||
// If a List was completely removed from the terraform config this is not recognized by terraform.
|
||||
// This helper function checks if that is the case and adjusts the plan accordingly.
|
||||
func CheckListRemoval(ctx context.Context, configModelList, planModelList types.List, destination path.Path, listType attr.Type, createEmptyList bool, resp *resource.ModifyPlanResponse) {
|
||||
if configModelList.IsNull() && !planModelList.IsNull() {
|
||||
if createEmptyList {
|
||||
emptyList, _ := types.ListValueFrom(ctx, listType, []string{})
|
||||
resp.Diagnostics.Append(resp.Plan.SetAttribute(ctx, destination, emptyList)...)
|
||||
} else {
|
||||
resp.Diagnostics.Append(resp.Plan.SetAttribute(ctx, destination, types.ListNull(listType))...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue