From 97f1c5bd8d2438e99ac0e9719ea3d88712bd492b Mon Sep 17 00:00:00 2001 From: jackofallops Date: Mon, 23 Aug 2021 08:59:29 +0100 Subject: [PATCH 1/2] revert a-name validation and fix max recordset limit --- .../services/privatedns/private_dns_a_record_resource.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/services/privatedns/private_dns_a_record_resource.go b/internal/services/privatedns/private_dns_a_record_resource.go index 999cff623e0b..b7702386be87 100644 --- a/internal/services/privatedns/private_dns_a_record_resource.go +++ b/internal/services/privatedns/private_dns_a_record_resource.go @@ -7,9 +7,9 @@ import ( "github.com/Azure/azure-sdk-for-go/services/privatedns/mgmt/2018-09-01/privatedns" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/privatedns/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/privatedns/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -40,7 +40,7 @@ func resourcePrivateDnsARecord() *pluginsdk.Resource { Required: true, ForceNew: true, // lower-cased due to the broken API https://github.com/Azure/azure-rest-api-specs/issues/6641 - ValidateFunc: validate.PrivateDnsARecordName, + ValidateFunc: validate.LowerCasedString, }, // TODO: make this case sensitive once the API's fixed https://github.com/Azure/azure-rest-api-specs/issues/6641 @@ -54,6 +54,7 @@ func resourcePrivateDnsARecord() *pluginsdk.Resource { "records": { Type: pluginsdk.TypeSet, Required: true, + MaxItems: 20, Elem: &pluginsdk.Schema{Type: pluginsdk.TypeString}, Set: pluginsdk.HashString, }, From b0dfcda9347b8fa8d8d459d13e9a1354cf4fe41e Mon Sep 17 00:00:00 2001 From: jackofallops Date: Mon, 23 Aug 2021 09:04:10 +0100 Subject: [PATCH 2/2] remove unused validation --- .../validate/private_dns_a_record_name.go | 18 ------------- .../private_dns_a_record_name_test.go | 27 ------------------- 2 files changed, 45 deletions(-) delete mode 100644 internal/services/privatedns/validate/private_dns_a_record_name.go delete mode 100644 internal/services/privatedns/validate/private_dns_a_record_name_test.go diff --git a/internal/services/privatedns/validate/private_dns_a_record_name.go b/internal/services/privatedns/validate/private_dns_a_record_name.go deleted file mode 100644 index 77cb68f4ddd0..000000000000 --- a/internal/services/privatedns/validate/private_dns_a_record_name.go +++ /dev/null @@ -1,18 +0,0 @@ -package validate - -import ( - "fmt" - "strings" - - "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" -) - -func PrivateDnsARecordName(i interface{}, k string) (warnings []string, errors []error) { - validate.LowerCasedString(i, k) - - if strings.ContainsAny(i.(string), "@") { - return nil, []error{fmt.Errorf("%q cannot contain @", k)} - } - - return nil, nil -} diff --git a/internal/services/privatedns/validate/private_dns_a_record_name_test.go b/internal/services/privatedns/validate/private_dns_a_record_name_test.go deleted file mode 100644 index d8998dda06e9..000000000000 --- a/internal/services/privatedns/validate/private_dns_a_record_name_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package validate - -import "testing" - -func TestPrivateDnsARecordName(t *testing.T) { - cases := []struct { - Value string - TestName string - ErrCount int - }{ - { - Value: "@", - TestName: "At", - ErrCount: 1, - }, - } - - for _, tc := range cases { - t.Run(tc.TestName, func(t *testing.T) { - _, errors := PrivateDnsARecordName(tc.Value, tc.TestName) - - if len(errors) != tc.ErrCount { - t.Fatalf("Expected NoEmptyStrings to have %d not %d errors for %q", tc.ErrCount, len(errors), tc.TestName) - } - }) - } -}