diff --git a/kubernetes/resource_kubernetes_secret_test.go b/kubernetes/resource_kubernetes_secret_test.go index 5f9db1abd8..b57fac4731 100644 --- a/kubernetes/resource_kubernetes_secret_test.go +++ b/kubernetes/resource_kubernetes_secret_test.go @@ -137,6 +137,25 @@ func TestAccKubernetesSecret_basic(t *testing.T) { }) } +func TestAccKuberNetesSecret_dotInName(t *testing.T) { + var conf api.Secret + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckKubernetesSecretDestroy, + Steps: []resource.TestStep{ + { + Config: testAccKubernetesSecretConfig_dotInSecretName, + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckKubernetesSecretExists("kubernetes_secret.test", &conf), + resource.TestCheckResourceAttr("kubernetes_secret.test", "metadata.0.name", "dot.test"), + ), + }, + }, + }) +} + func TestAccKubernetesSecret_importBasic(t *testing.T) { resourceName := "kubernetes_secret.test" name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) @@ -302,6 +321,14 @@ func testAccCheckKubernetesSecretExists(n string, obj *api.Secret) resource.Test } } +const testAccKubernetesSecretConfig_dotInSecretName = ` +resource "kubernetes_secret" "test" { + metadata { + name = "dot.test" + } + } +` + func testAccKubernetesSecretConfig_emptyData(name string) string { return fmt.Sprintf(` resource "kubernetes_secret" "test" { diff --git a/kubernetes/validators.go b/kubernetes/validators.go index 8a66d99ac3..308105c230 100644 --- a/kubernetes/validators.go +++ b/kubernetes/validators.go @@ -31,8 +31,7 @@ func validateAnnotations(value interface{}, key string) (ws []string, es []error func validateName(value interface{}, key string) (ws []string, es []error) { v := value.(string) - - errors := apiValidation.NameIsDNSLabel(v, false) + errors := apiValidation.NameIsDNSSubdomain(v, false) if len(errors) > 0 { for _, err := range errors { es = append(es, fmt.Errorf("%s %s", key, err))