@@ -370,6 +370,25 @@ func TestAccArgoCDCluster_uniqueByServerTrimmed(t *testing.T) {
370370 })
371371}
372372
373+ func TestAccArgoCDCluster_namespacesErrorWhenEmpty (t * testing.T ) {
374+ name := acctest .RandString (10 )
375+
376+ resource .Test (t , resource.TestCase {
377+ PreCheck : func () { testAccPreCheck (t ); testAccPreCheckFeatureSupported (t , featureProjectScopedClusters ) },
378+ ProviderFactories : testAccProviders ,
379+ Steps : []resource.TestStep {
380+ {
381+ Config : testAccArgoCDClusterNamespacesContainsEmptyString (name ),
382+ ExpectError : regexp .MustCompile ("namespaces: must contain non-empty strings" ),
383+ },
384+ {
385+ Config : testAccArgoCDClusterNamespacesContainsEmptyString_MultipleItems (name ),
386+ ExpectError : regexp .MustCompile ("namespaces: must contain non-empty strings" ),
387+ },
388+ },
389+ })
390+ }
391+
373392func testAccArgoCDClusterBearerToken (clusterName string ) string {
374393 return fmt .Sprintf (`
375394resource "argocd_cluster" "simple" {
@@ -610,6 +629,42 @@ resource "argocd_cluster" "cluster_metadata" {
610629` , clusterName )
611630}
612631
632+ func testAccArgoCDClusterNamespacesContainsEmptyString (clusterName string ) string {
633+ return fmt .Sprintf (`
634+ resource "argocd_cluster" "simple" {
635+ server = "https://kubernetes.default.svc.cluster.local"
636+ name = "%s"
637+ shard = "1"
638+ namespaces = [""]
639+ config {
640+ # Uses Kind's bootstrap token whose ttl is 24 hours after cluster bootstrap.
641+ bearer_token = "abcdef.0123456789abcdef"
642+ tls_client_config {
643+ insecure = true
644+ }
645+ }
646+ }
647+ ` , clusterName )
648+ }
649+
650+ func testAccArgoCDClusterNamespacesContainsEmptyString_MultipleItems (clusterName string ) string {
651+ return fmt .Sprintf (`
652+ resource "argocd_cluster" "simple" {
653+ server = "https://kubernetes.default.svc.cluster.local"
654+ name = "%s"
655+ shard = "1"
656+ namespaces = ["default", ""]
657+ config {
658+ # Uses Kind's bootstrap token whose ttl is 24 hours after cluster bootstrap.
659+ bearer_token = "abcdef.0123456789abcdef"
660+ tls_client_config {
661+ insecure = true
662+ }
663+ }
664+ }
665+ ` , clusterName )
666+ }
667+
613668// getInternalRestConfig returns the internal Kubernetes cluster REST config.
614669func getInternalRestConfig () (* rest.Config , error ) {
615670 rc := & rest.Config {}
0 commit comments