From 759dd1b81ecf1f695a8df68fd4e444a7afed3c00 Mon Sep 17 00:00:00 2001 From: nicopfau Date: Thu, 7 Nov 2024 10:39:54 +0100 Subject: [PATCH] Adapt validation for azurerm_container_app.secret and fix error output --- internal/services/containerapps/validate/validate.go | 4 ++-- internal/services/containerapps/validate/validate_test.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/services/containerapps/validate/validate.go b/internal/services/containerapps/validate/validate.go index 91f59466ffaa..11d83de9a796 100644 --- a/internal/services/containerapps/validate/validate.go +++ b/internal/services/containerapps/validate/validate.go @@ -46,8 +46,8 @@ func SecretName(i interface{}, k string) (warnings []string, errors []error) { return } - if matched := regexp.MustCompile(`^[a-z0-9][a-z0-9-]*[a-z0-9]?$`).Match([]byte(v)); !matched || strings.HasSuffix(v, "-") || strings.HasSuffix(v, ".") { - errors = append(errors, fmt.Errorf("%q must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character", k)) + if matched := regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,251}[a-z0-9]?$`).Match([]byte(v)); !matched || strings.HasSuffix(v, "-") { + errors = append(errors, fmt.Errorf("%q must consist of lower case alphanumeric characters, '-', and must start and end with an alphanumeric character. The length must not be more than 253 characters", k)) } return } diff --git a/internal/services/containerapps/validate/validate_test.go b/internal/services/containerapps/validate/validate_test.go index 44203f9dc88f..784fd34a5823 100644 --- a/internal/services/containerapps/validate/validate_test.go +++ b/internal/services/containerapps/validate/validate_test.go @@ -98,6 +98,10 @@ func TestValidateSecretNames(t *testing.T) { Input: "Cannothavecapitals", Valid: false, }, + { + Input: "no.dots.allowed", + Valid: false, + }, { Input: "a", Valid: true,