feat(dns): add validation for cname record-sets (#1019)
relates to #1014 and STACKITTPR-375
This commit is contained in:
parent
82c1d1e644
commit
87bc7415fc
3 changed files with 17 additions and 4 deletions
|
|
@ -5,8 +5,6 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
dnsUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/dns/utils"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
|
||||
|
|
@ -23,6 +21,7 @@ import (
|
|||
"github.com/stackitcloud/stackit-sdk-go/services/dns/wait"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
|
||||
dnsUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/dns/utils"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -132,6 +132,14 @@ func RecordSet() *Validator {
|
|||
))
|
||||
}
|
||||
case "CNAME":
|
||||
name := req.ConfigValue.ValueString()
|
||||
if name == "" || name[len(name)-1] != '.' {
|
||||
resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic(
|
||||
req.Path,
|
||||
"value must be a Fully Qualified Domain Name (FQDN) and end with dot '.'",
|
||||
req.ConfigValue.ValueString(),
|
||||
))
|
||||
}
|
||||
case "NS":
|
||||
case "MX":
|
||||
case "TXT":
|
||||
|
|
|
|||
|
|
@ -264,8 +264,14 @@ func TestRecordSet(t *testing.T) {
|
|||
false,
|
||||
},
|
||||
{
|
||||
"CNAME record",
|
||||
"some-record",
|
||||
"CNAME record Not a Fully Qualified Domain Name",
|
||||
"stackit.de",
|
||||
"CNAME",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"CNAME record ok Fully Qualified Domain Name",
|
||||
"stackit.de.",
|
||||
"CNAME",
|
||||
true,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue