diff --git a/kubernetes/resource_kubernetes_api_service_test.go b/kubernetes/resource_kubernetes_api_service_test.go index e09616b8b8..7abffcc293 100644 --- a/kubernetes/resource_kubernetes_api_service_test.go +++ b/kubernetes/resource_kubernetes_api_service_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesAPIService_basic(t *testing.T) { name := fmt.Sprintf("%s.%s", version, group) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_api_service.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesAPIServiceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_api_service.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesAPIServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesAPIServiceConfig_basic(name, group, version), diff --git a/kubernetes/resource_kubernetes_certificate_signing_request_test.go b/kubernetes/resource_kubernetes_certificate_signing_request_test.go index 23c7113443..7f889174b0 100644 --- a/kubernetes/resource_kubernetes_certificate_signing_request_test.go +++ b/kubernetes/resource_kubernetes_certificate_signing_request_test.go @@ -17,10 +17,10 @@ func TestAccKubernetesCertificateSigningRequest_basic(t *testing.T) { usages := []string{"client auth"} signerName := "kubernetes.io/legacy-unknown" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_certificate_signing_request.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesCertificateSigningRequestDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_certificate_signing_request.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesCertificateSigningRequestDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesCertificateSigningRequestConfig_basic(name, signerName, usages, true), @@ -33,10 +33,10 @@ func TestAccKubernetesCertificateSigningRequest_basic(t *testing.T) { func TestAccKubernetesCertificateSigningRequest_generateName(t *testing.T) { generateName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_certificate_signing_request.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesCertificateSigningRequestDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_certificate_signing_request.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesCertificateSigningRequestDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesCertificateSigningRequestConfig_generateName(generateName), @@ -62,9 +62,7 @@ func testAccCheckKubernetesCertificateSigningRequestValid(s *terraform.State) er } func testAccCheckKubernetesCertificateSigningRequestRemoteResourceDeleted(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_cluster_role_binding_test.go b/kubernetes/resource_kubernetes_cluster_role_binding_test.go index 44932480ae..713452ed77 100644 --- a/kubernetes/resource_kubernetes_cluster_role_binding_test.go +++ b/kubernetes/resource_kubernetes_cluster_role_binding_test.go @@ -17,10 +17,10 @@ func TestAccKubernetesClusterRoleBinding_basic(t *testing.T) { name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_cluster_role_binding.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_cluster_role_binding.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesClusterRoleBindingConfig_basic(name), @@ -128,10 +128,10 @@ func TestAccKubernetesClusterRoleBinding_serviceaccount_subject(t *testing.T) { name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_cluster_role_binding.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_cluster_role_binding.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesClusterRoleBindingConfig_serviceaccount_subject(name), @@ -161,10 +161,10 @@ func TestAccKubernetesClusterRoleBinding_group_subject(t *testing.T) { name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resourceName := "kubernetes_cluster_role_binding.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_cluster_role_binding.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_cluster_role_binding.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesClusterRoleBindingConfig_group_subject(name), @@ -199,10 +199,10 @@ func TestAccKubernetesClusterRoleBinding_UpdatePatchOperationsOrderWithRemovals( name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_cluster_role_binding.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_cluster_role_binding.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesClusterRoleBindingDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesClusterRoleBindingConfigBug_step_0(name), @@ -284,9 +284,7 @@ func TestAccKubernetesClusterRoleBinding_UpdatePatchOperationsOrderWithRemovals( } func testAccCheckKubernetesClusterRoleBindingDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_cluster_role_test.go b/kubernetes/resource_kubernetes_cluster_role_test.go index b681cea294..35cc625cdb 100644 --- a/kubernetes/resource_kubernetes_cluster_role_test.go +++ b/kubernetes/resource_kubernetes_cluster_role_test.go @@ -17,10 +17,10 @@ func TestAccKubernetesClusterRole_basic(t *testing.T) { resourceName := "kubernetes_cluster_role.test" name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesClusterRoleDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesClusterRoleDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesClusterRoleConfig_basic(name), @@ -69,10 +69,10 @@ func TestAccKubernetesClusterRole_UpdatePatchOperationsOrderWithRemovals(t *test resourceName := "kubernetes_cluster_role.test" name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesClusterRoleDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesClusterRoleDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesClusterRoleConfigBug_step_0(name), @@ -143,10 +143,10 @@ func TestAccKubernetesClusterRole_aggregationRuleBasic(t *testing.T) { resourceName := "kubernetes_cluster_role.test" name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesClusterRoleDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesClusterRoleDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesClusterRoleConfig_aggRule(name), @@ -187,10 +187,10 @@ func TestAccKubernetesClusterRole_aggregationRuleRuleAggregation(t *testing.T) { resourceName := "kubernetes_cluster_role.test" name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesClusterRoleDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesClusterRoleDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesClusterRoleConfig_aggRule2(name), @@ -216,9 +216,7 @@ func TestAccKubernetesClusterRole_aggregationRuleRuleAggregation(t *testing.T) { } func testAccCheckKubernetesClusterRoleDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_config_map_test.go b/kubernetes/resource_kubernetes_config_map_test.go index 8300bb275f..cc7c5a6252 100644 --- a/kubernetes/resource_kubernetes_config_map_test.go +++ b/kubernetes/resource_kubernetes_config_map_test.go @@ -20,10 +20,10 @@ func TestAccKubernetesConfigMap_basic(t *testing.T) { resourceName := "kubernetes_config_map.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesConfigMapDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesConfigMapDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesConfigMapConfig_nodata(name), @@ -127,10 +127,10 @@ func TestAccKubernetesConfigMap_binaryData(t *testing.T) { resourceName := "kubernetes_config_map.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesConfigMapDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesConfigMapDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesConfigMapConfig_binaryData(prefix), @@ -161,10 +161,10 @@ func TestAccKubernetesConfigMap_generatedName(t *testing.T) { resourceName := "kubernetes_config_map.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesConfigMapDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesConfigMapDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesConfigMapConfig_generatedName(prefix), @@ -205,9 +205,7 @@ func testAccCheckConfigMapData(m *api.ConfigMap, expected map[string]string) res } func testAccCheckKubernetesConfigMapDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_cron_job_test.go b/kubernetes/resource_kubernetes_cron_job_test.go index 391ac070c1..89ad5f0d30 100644 --- a/kubernetes/resource_kubernetes_cron_job_test.go +++ b/kubernetes/resource_kubernetes_cron_job_test.go @@ -17,10 +17,10 @@ func TestAccKubernetesCronJob_basic(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_cron_job.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesCronJobDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_cron_job.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesCronJobDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesCronJobConfig_basic(name), @@ -77,10 +77,10 @@ func TestAccKubernetesCronJob_extra(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_cron_job.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesCronJobDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_cron_job.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesCronJobDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesCronJobConfig_extra(name), @@ -113,9 +113,7 @@ func TestAccKubernetesCronJob_extra(t *testing.T) { } func testAccCheckKubernetesCronJobDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_csi_driver_test.go b/kubernetes/resource_kubernetes_csi_driver_test.go index dffcda4d93..df8039119d 100644 --- a/kubernetes/resource_kubernetes_csi_driver_test.go +++ b/kubernetes/resource_kubernetes_csi_driver_test.go @@ -20,10 +20,10 @@ func TestAccKubernetesCSIDriver_basic(t *testing.T) { name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesCSIDriverDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesCSIDriverDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesCSIDriverBasicConfig(name, true), @@ -45,9 +45,7 @@ func TestAccKubernetesCSIDriver_basic(t *testing.T) { } func testAccCheckKubernetesCSIDriverDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_daemonset_test.go b/kubernetes/resource_kubernetes_daemonset_test.go index 39acba6a18..278a878381 100644 --- a/kubernetes/resource_kubernetes_daemonset_test.go +++ b/kubernetes/resource_kubernetes_daemonset_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesDaemonSet_minimal(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_daemonset.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesDaemonSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_daemonset.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesDaemonSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesDaemonSetConfig_minimal(name), @@ -261,9 +261,7 @@ func TestAccKubernetesDaemonSet_with_tolerations_unset_toleration_seconds(t *tes } func testAccCheckKubernetesDaemonSetDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_default_service_account_test.go b/kubernetes/resource_kubernetes_default_service_account_test.go index a53172eecf..6468815985 100644 --- a/kubernetes/resource_kubernetes_default_service_account_test.go +++ b/kubernetes/resource_kubernetes_default_service_account_test.go @@ -21,10 +21,10 @@ func TestAccKubernetesDefaultServiceAccount_basic(t *testing.T) { resourceName := "kubernetes_default_service_account.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesDefaultServiceAccountConfig_basic(namespace), @@ -63,10 +63,10 @@ func TestAccKubernetesDefaultServiceAccount_secrets(t *testing.T) { namespace := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_default_service_account.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_default_service_account.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesDefaultServiceAccountConfig_secrets(namespace), diff --git a/kubernetes/resource_kubernetes_deployment_test.go b/kubernetes/resource_kubernetes_deployment_test.go index 24d0e3b02d..5571436fda 100644 --- a/kubernetes/resource_kubernetes_deployment_test.go +++ b/kubernetes/resource_kubernetes_deployment_test.go @@ -23,10 +23,10 @@ func TestAccKubernetesDeployment_basic(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_deployment.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesDeploymentDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_deployment.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesDeploymentDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesDeploymentConfig_basic(name), @@ -65,10 +65,10 @@ func TestAccKubernetesDeployment_initContainer(t *testing.T) { resourceName := "kubernetes_deployment.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_deployment.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesDeploymentDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_deployment.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesDeploymentDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesDeploymentConfig_initContainer(name), @@ -113,10 +113,10 @@ func TestAccKubernetesDeployment_generatedName(t *testing.T) { resourceName := "kubernetes_deployment.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_deployment.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesDeploymentDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_deployment.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesDeploymentDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesDeploymentConfig_generatedName(prefix), @@ -885,9 +885,7 @@ func TestAccKubernetesDeployment_config_with_automount_service_account_token(t * } func testAccCheckKubernetesDeploymentDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err @@ -921,9 +919,7 @@ func getDeploymentFromResourceName(s *terraform.State, n string) (*appsv1.Deploy return nil, fmt.Errorf("Not found: %s", n) } - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return nil, err diff --git a/kubernetes/resource_kubernetes_endpoints_test.go b/kubernetes/resource_kubernetes_endpoints_test.go index c9cd3c9548..7b605fe05d 100644 --- a/kubernetes/resource_kubernetes_endpoints_test.go +++ b/kubernetes/resource_kubernetes_endpoints_test.go @@ -19,10 +19,10 @@ func TestAccKubernetesEndpoints_basic(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_endpoints.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesEndpointDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_endpoints.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesEndpointDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesEndpointsConfig_basic(name), @@ -199,10 +199,10 @@ func TestAccKubernetesEndpoints_generatedName(t *testing.T) { prefix := "tf-acc-test-gen-" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_endpoints.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesEndpointDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_endpoints.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesEndpointDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesEndpointsConfig_generatedName(prefix), @@ -246,9 +246,7 @@ func testAccCheckEndpointSubsets(svc *api.Endpoints, expected []api.EndpointSubs } func testAccCheckKubernetesEndpointDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_horizontal_pod_autoscaler_test.go b/kubernetes/resource_kubernetes_horizontal_pod_autoscaler_test.go index 575d64742d..464c7aef04 100644 --- a/kubernetes/resource_kubernetes_horizontal_pod_autoscaler_test.go +++ b/kubernetes/resource_kubernetes_horizontal_pod_autoscaler_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesHorizontalPodAutoscaler_basic(t *testing.T) { resourceName := "kubernetes_horizontal_pod_autoscaler.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_horizontal_pod_autoscaler.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesHorizontalPodAutoscalerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_horizontal_pod_autoscaler.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesHorizontalPodAutoscalerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesHorizontalPodAutoscalerConfig_basic(name), @@ -109,10 +109,10 @@ func TestAccKubernetesHorizontalPodAutoscaler_generatedName(t *testing.T) { prefix := "tf-acc-test-" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_horizontal_pod_autoscaler.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesHorizontalPodAutoscalerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_horizontal_pod_autoscaler.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesHorizontalPodAutoscalerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesHorizontalPodAutoscalerConfig_generatedName(prefix), @@ -140,9 +140,7 @@ func TestAccKubernetesHorizontalPodAutoscaler_generatedName(t *testing.T) { } func testAccCheckKubernetesHorizontalPodAutoscalerDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_horizontal_pod_autoscaler_v2_test.go b/kubernetes/resource_kubernetes_horizontal_pod_autoscaler_v2_test.go index 5d901d7198..909defe811 100644 --- a/kubernetes/resource_kubernetes_horizontal_pod_autoscaler_v2_test.go +++ b/kubernetes/resource_kubernetes_horizontal_pod_autoscaler_v2_test.go @@ -16,10 +16,10 @@ func TestAccKubernetesHorizontalPodAutoscalerV2_basic(t *testing.T) { resourceName := "kubernetes_horizontal_pod_autoscaler.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_horizontal_pod_autoscaler.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesHorizontalPodAutoscalerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_horizontal_pod_autoscaler.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesHorizontalPodAutoscalerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesHorizontalPodAutoscalerV2Config_basic(name), diff --git a/kubernetes/resource_kubernetes_ingress_test.go b/kubernetes/resource_kubernetes_ingress_test.go index c835a1ede4..e2bfb9d2c9 100644 --- a/kubernetes/resource_kubernetes_ingress_test.go +++ b/kubernetes/resource_kubernetes_ingress_test.go @@ -17,10 +17,10 @@ func TestAccKubernetesIngress_basic(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_ingress.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesIngressDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_ingress.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesIngressDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesIngressConfig_basic(name), @@ -68,10 +68,10 @@ func TestAccKubernetesIngress_TLS(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_ingress.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesIngressDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_ingress.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesIngressDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesIngressConfig_TLS(name), @@ -113,10 +113,10 @@ func TestAccKubernetesIngress_InternalKey(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_ingress.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesIngressDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_ingress.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesIngressDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesIngressConfig_internalKey(name), @@ -154,10 +154,10 @@ func TestAccKubernetesIngress_WaitForLoadBalancerGoogleCloud(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: "kubernetes_ingress.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesIngressDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: "kubernetes_ingress.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesIngressDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesIngressConfig_waitForLoadBalancer(name), @@ -171,9 +171,7 @@ func TestAccKubernetesIngress_WaitForLoadBalancerGoogleCloud(t *testing.T) { } func testAccCheckKubernetesIngressDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_job_test.go b/kubernetes/resource_kubernetes_job_test.go index 7d3df2ca57..df6fac7e56 100644 --- a/kubernetes/resource_kubernetes_job_test.go +++ b/kubernetes/resource_kubernetes_job_test.go @@ -64,10 +64,10 @@ func TestAccKubernetesJob_basic(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_job.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesJobDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_job.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesJobDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesJobConfig_basic(name), @@ -123,10 +123,10 @@ func TestAccKubernetesJob_ttl_seconds_after_finished(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_job.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesJobDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_job.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesJobDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesJobConfig_ttl_seconds_after_finished(name), @@ -140,9 +140,7 @@ func TestAccKubernetesJob_ttl_seconds_after_finished(t *testing.T) { } func testAccCheckKubernetesJobDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_limit_range_test.go b/kubernetes/resource_kubernetes_limit_range_test.go index bddf1fbe0b..6a114c9e14 100644 --- a/kubernetes/resource_kubernetes_limit_range_test.go +++ b/kubernetes/resource_kubernetes_limit_range_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesLimitRange_basic(t *testing.T) { resourceName := "kubernetes_limit_range.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_limit_range.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_limit_range.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesLimitRangeConfig_basic(name), @@ -121,10 +121,10 @@ func TestAccKubernetesLimitRange_empty(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_limit_range.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_limit_range.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesLimitRangeConfig_empty(name), @@ -151,10 +151,10 @@ func TestAccKubernetesLimitRange_generatedName(t *testing.T) { prefix := "tf-acc-test-" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_limit_range.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_limit_range.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesLimitRangeConfig_generatedName(prefix), @@ -182,10 +182,10 @@ func TestAccKubernetesLimitRange_typeChange(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_limit_range.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_limit_range.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesLimitRangeConfig_typeChange(name), @@ -236,10 +236,10 @@ func TestAccKubernetesLimitRange_multipleLimits(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_limit_range.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_limit_range.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesLimitRangeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesLimitRangeConfig_multipleLimits(name), @@ -273,9 +273,7 @@ func TestAccKubernetesLimitRange_multipleLimits(t *testing.T) { } func testAccCheckKubernetesLimitRangeDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_mutating_webhook_configuration_test.go b/kubernetes/resource_kubernetes_mutating_webhook_configuration_test.go index f6efd6dbc0..50c122038c 100644 --- a/kubernetes/resource_kubernetes_mutating_webhook_configuration_test.go +++ b/kubernetes/resource_kubernetes_mutating_webhook_configuration_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesMutatingWebhookConfiguration_basic(t *testing.T) { resourceName := "kubernetes_mutating_webhook_configuration.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_mutating_webhook_configuration.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesMutatingWebhookConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_mutating_webhook_configuration.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesMutatingWebhookConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesMutatingWebhookConfigurationConfig_basic(name), @@ -115,9 +115,7 @@ func TestAccKubernetesMutatingWebhookConfiguration_basic(t *testing.T) { } func testAccCheckKubernetesMutatingWebhookConfigurationDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_namespace_test.go b/kubernetes/resource_kubernetes_namespace_test.go index 653807d5c0..74d256aa20 100644 --- a/kubernetes/resource_kubernetes_namespace_test.go +++ b/kubernetes/resource_kubernetes_namespace_test.go @@ -20,10 +20,10 @@ func TestAccKubernetesNamespace_basic(t *testing.T) { resourceName := "kubernetes_namespace.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_namespace.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesNamespaceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_namespace.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesNamespaceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesNamespaceConfig_basic(nsName), @@ -124,10 +124,10 @@ func TestAccKubernetesNamespace_generatedName(t *testing.T) { resourceName := "kubernetes_namespace.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_namespace.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesNamespaceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_namespace.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesNamespaceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesNamespaceConfig_generatedName(prefix), @@ -160,10 +160,10 @@ func TestAccKubernetesNamespace_withSpecialCharacters(t *testing.T) { nsName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_namespace.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesNamespaceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_namespace.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesNamespaceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesNamespaceConfig_specialCharacters(nsName), @@ -199,10 +199,10 @@ func TestAccKubernetesNamespace_deleteTimeout(t *testing.T) { nsName := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_namespace.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesNamespaceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_namespace.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesNamespaceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesNamespaceConfig_deleteTimeout(nsName), @@ -268,9 +268,7 @@ func testAccCheckMetaLabels(om *metav1.ObjectMeta, expected map[string]string) r } func testAccCheckKubernetesNamespaceDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_network_policy_test.go b/kubernetes/resource_kubernetes_network_policy_test.go index 27f073dc85..d3cbafd240 100644 --- a/kubernetes/resource_kubernetes_network_policy_test.go +++ b/kubernetes/resource_kubernetes_network_policy_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesNetworkPolicy_basic(t *testing.T) { resourceName := "kubernetes_network_policy.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_network_policy.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesNetworkPolicyDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_network_policy.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesNetworkPolicyDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesNetworkPolicyConfig_basic(name), @@ -286,10 +286,10 @@ func TestAccKubernetesNetworkPolicy_withEgressAtCreation(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_network_policy.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesNetworkPolicyDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_network_policy.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesNetworkPolicyDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesNetworkPolicyConfig_withEgress(name), @@ -350,9 +350,7 @@ func TestAccKubernetesNetworkPolicy_withEgressAtCreation(t *testing.T) { } func testAccCheckKubernetesNetworkPolicyDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_persistent_volume_claim_test.go b/kubernetes/resource_kubernetes_persistent_volume_claim_test.go index b52de60ad8..8bc5798b37 100644 --- a/kubernetes/resource_kubernetes_persistent_volume_claim_test.go +++ b/kubernetes/resource_kubernetes_persistent_volume_claim_test.go @@ -21,10 +21,10 @@ func TestAccKubernetesPersistentVolumeClaim_basic(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume_claim.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume_claim.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeClaimConfig_basic(name), @@ -141,10 +141,10 @@ func TestAccKubernetesPersistentVolumeClaim_googleCloud_volumeMatch(t *testing.T zone := os.Getenv("GOOGLE_ZONE") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: "kubernetes_persistent_volume_claim.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: "kubernetes_persistent_volume_claim.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeClaimConfig_volumeMatch(volumeName, claimName, diskName, zone), @@ -213,7 +213,7 @@ func TestAccKubernetesPersistentVolumeClaim_googleCloud_volumeMatch(t *testing.T // resource.Test(t, resource.TestCase{ // PreCheck: func() { testAccPreCheck(t) }, // IDRefreshName: "kubernetes_persistent_volume_claim.test", -// Providers: testAccProviders, +// ProviderFactories: testAccProviderFactories, // CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, // Steps: []resource.TestStep{ // { @@ -251,7 +251,7 @@ func TestAccKubernetesPersistentVolumeClaim_googleCloud_volumeMatch(t *testing.T // resource.Test(t, resource.TestCase{ // PreCheck: func() { testAccPreCheck(t) }, // IDRefreshName: "kubernetes_persistent_volume_claim.test", -// Providers: testAccProviders, +// ProviderFactories: testAccProviderFactories, // CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, // Steps: []resource.TestStep{ // { @@ -296,10 +296,10 @@ func TestAccKubernetesPersistentVolumeClaim_googleCloud_volumeUpdate(t *testing. zone := os.Getenv("GOOGLE_ZONE") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: "kubernetes_persistent_volume_claim.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: "kubernetes_persistent_volume_claim.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeClaimConfig_volumeUpdate(volumeName, claimName, "5Gi", diskName, zone), @@ -362,10 +362,10 @@ func TestAccKubernetesPersistentVolumeClaim_googleCloud_storageClass(t *testing. claimName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: "kubernetes_persistent_volume_claim.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: "kubernetes_persistent_volume_claim.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeClaimConfig_storageClass(className, claimName), @@ -432,10 +432,10 @@ func TestAccKubernetesPersistentVolumeClaim_expansionGoogleCloud(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: "kubernetes_persistent_volume_claim.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: "kubernetes_persistent_volume_claim.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, Steps: []resource.TestStep{ { // GKE specific check -- initial create. Config: testAccKubernetesPersistentVolumeClaimConfig_updateStorageGKE(name, "1Gi"), @@ -471,10 +471,10 @@ func TestAccKubernetesPersistentVolumeClaim_expansionMinikube(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInMinikube(t) }, - IDRefreshName: "kubernetes_persistent_volume_claim.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInMinikube(t) }, + IDRefreshName: "kubernetes_persistent_volume_claim.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeClaimDestroy, Steps: []resource.TestStep{ { // Minikube specific check -- initial create. Config: testAccKubernetesPersistentVolumeClaimConfig_updateStorageMinikube(name, "1Gi", "5Gi"), @@ -535,8 +535,7 @@ func TestAccKubernetesPersistentVolumeClaim_regression(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - // ProviderFactories: testAccProviderFactories, + PreCheck: func() { testAccPreCheck(t) }, ExternalProviders: testAccExternalProviders, Steps: []resource.TestStep{ { // The first apply downloads and uses the latest released version of the provider. @@ -552,7 +551,7 @@ func TestAccKubernetesPersistentVolumeClaim_regression(t *testing.T) { resource.TestCheckResourceAttr("kubernetes_persistent_volume_claim.test", "spec.0.resources.0.requests.storage", "5Gi"), ), }, - { // The second apply uses a local, compiled version of the current branch. The plan should be empty. + { // The second apply uses a local, compiled version of the current branch. Config: requiredProviders() + testAccKubernetesPersistentVolumeClaimConfig_regression("kubernetes-local", name), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckKubernetesPersistentVolumeClaimExists("kubernetes_persistent_volume_claim.test", &conf2), @@ -571,9 +570,7 @@ func TestAccKubernetesPersistentVolumeClaim_regression(t *testing.T) { } func testAccCheckKubernetesPersistentVolumeClaimDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err } diff --git a/kubernetes/resource_kubernetes_persistent_volume_test.go b/kubernetes/resource_kubernetes_persistent_volume_test.go index dee7565513..524573366f 100644 --- a/kubernetes/resource_kubernetes_persistent_volume_test.go +++ b/kubernetes/resource_kubernetes_persistent_volume_test.go @@ -26,10 +26,10 @@ func TestAccKubernetesPersistentVolume_azure_basic(t *testing.T) { diskURI := "/subscriptions/" + subscriptionID + "/resourceGroups/" + name + "/providers/Microsoft.Compute/disks/" + name resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInAks(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInAks(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_azure_managedDisk(name, location) + @@ -89,10 +89,10 @@ func TestAccKubernetesPersistentVolume_azure_blobStorageDisk(t *testing.T) { wantError := persistentVolumeAzureBlobError resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInAks(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInAks(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { // Create a PV using the existing blob storage disk. Kind is omitted to test backwards compatibility. Config: testAccKubernetesPersistentVolumeConfig_azure_blobStorage(name, location) + @@ -145,10 +145,10 @@ func TestAccKubernetesPersistentVolume_googleCloud_basic(t *testing.T) { zone := os.Getenv("GOOGLE_ZONE") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_googleCloud_basic(name, diskName, zone, region), @@ -230,10 +230,10 @@ func TestAccKubernetesPersistentVolume_aws_basic(t *testing.T) { region := os.Getenv("AWS_DEFAULT_REGION") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInEks(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInEks(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_aws_basic(name, region, zone), @@ -310,10 +310,10 @@ func TestAccKubernetesPersistentVolume_googleCloud_volumeSource(t *testing.T) { zone := os.Getenv("GOOGLE_ZONE") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_googleCloud_volumeSource(name, diskName, zone), @@ -373,10 +373,10 @@ func TestAccKubernetesPersistentVolume_hostPath_volumeSource(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", randString) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_hostPath_volumeSource(name, "/first/path", "DirectoryOrCreate"), @@ -435,10 +435,10 @@ func TestAccKubernetesPersistentVolume_local_volumeSource(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", randString) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_local_volumeSource(name, "1Gi", "/first/path", "test-node"), @@ -487,10 +487,10 @@ func TestAccKubernetesPersistentVolume_cephFsSecretRef(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", randString) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_cephFsSecretRef(name), @@ -532,10 +532,10 @@ func TestAccKubernetesPersistentVolume_storageClass(t *testing.T) { zone := os.Getenv("GOOGLE_ZONE") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_storageClass(name, diskName, storageClassName, secondStorageClassName, zone, "test"), @@ -595,10 +595,10 @@ func TestAccKubernetesPersistentVolume_hostPath_nodeAffinity(t *testing.T) { replacedSelectorValueHash := schema.HashString(replacedSelectorValue) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_hostPath_nodeAffinity_match(name, selectorLabel, selectorValue), @@ -660,10 +660,10 @@ func TestAccKubernetesPersistentVolume_hostPath_mountOptions(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", randString) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_hostPath_mountOptions(name), @@ -681,10 +681,10 @@ func TestAccKubernetesPersistentVolume_csi_basic(t *testing.T) { var conf api.PersistentVolume name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_csi_basic(name), @@ -755,10 +755,10 @@ func TestAccKubernetesPersistentVolume_csi_secrets(t *testing.T) { var conf api.PersistentVolume name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeConfig_csi_secrets(name), @@ -804,10 +804,10 @@ func TestAccKubernetesPersistentVolume_volumeMode(t *testing.T) { var conf api.PersistentVolume name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_persistent_volume.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_persistent_volume.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPersistentVolumeDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPersistentVolumeVolumeModeConfig(name, "Block"), @@ -853,9 +853,7 @@ func testAccCheckKubernetesPersistentVolumeForceNew(old, new *api.PersistentVolu } func waitForPersistentVolumeDeleted(pvName string, poll, timeout time.Duration) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err @@ -872,9 +870,7 @@ func waitForPersistentVolumeDeleted(pvName string, poll, timeout time.Duration) } func testAccCheckKubernetesPersistentVolumeDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_pod_disruption_budget_test.go b/kubernetes/resource_kubernetes_pod_disruption_budget_test.go index 14daef5e8b..99adc617fd 100644 --- a/kubernetes/resource_kubernetes_pod_disruption_budget_test.go +++ b/kubernetes/resource_kubernetes_pod_disruption_budget_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesPodDisruptionBudget_basic(t *testing.T) { resourceName := "kubernetes_pod_disruption_budget.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPodDisruptionBudgetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPodDisruptionBudgetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPodDisruptionBudgetConfig_maxUnavailable(name), @@ -89,9 +89,7 @@ func TestAccKubernetesPodDisruptionBudget_basic(t *testing.T) { } func testAccCheckKubernetesPodDisruptionBudgetDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_pod_security_policy_test.go b/kubernetes/resource_kubernetes_pod_security_policy_test.go index 21abe189ce..788d0b8bd9 100644 --- a/kubernetes/resource_kubernetes_pod_security_policy_test.go +++ b/kubernetes/resource_kubernetes_pod_security_policy_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesPodSecurityPolicy_basic(t *testing.T) { resourceName := "kubernetes_pod_security_policy.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPodSecurityPolicyDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPodSecurityPolicyDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPodSecurityPolicyConfig_basic(name), @@ -167,9 +167,7 @@ func TestAccKubernetesPodSecurityPolicy_basic(t *testing.T) { } func testAccCheckKubernetesPodSecurityPolicyDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_pod_test.go b/kubernetes/resource_kubernetes_pod_test.go index a1d4fbc14c..97c4e3793d 100644 --- a/kubernetes/resource_kubernetes_pod_test.go +++ b/kubernetes/resource_kubernetes_pod_test.go @@ -911,9 +911,7 @@ func TestAccKubernetesPod_enableServiceLinks(t *testing.T) { } func testAccCheckKubernetesPodDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_priority_class_test.go b/kubernetes/resource_kubernetes_priority_class_test.go index 1f84ffc3cf..f59e3b78c6 100644 --- a/kubernetes/resource_kubernetes_priority_class_test.go +++ b/kubernetes/resource_kubernetes_priority_class_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesPriorityClass_basic(t *testing.T) { resourceName := "kubernetes_priority_class.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPriorityClassDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPriorityClassDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPriorityClassConfig_basic(name), @@ -97,10 +97,10 @@ func TestAccKubernetesPriorityClass_generatedName(t *testing.T) { prefix := "tf-acc-test-" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_priority_class.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesPriorityClassDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_priority_class.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesPriorityClassDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesPriorityClassConfig_generatedName(prefix), @@ -123,9 +123,7 @@ func TestAccKubernetesPriorityClass_generatedName(t *testing.T) { } func testAccCheckKubernetesPriorityClassDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_replication_controller_deprecated_test.go b/kubernetes/resource_kubernetes_replication_controller_deprecated_test.go index 4c1e7065a1..042cbf74e8 100644 --- a/kubernetes/resource_kubernetes_replication_controller_deprecated_test.go +++ b/kubernetes/resource_kubernetes_replication_controller_deprecated_test.go @@ -16,10 +16,10 @@ func TestAccKubernetesReplicationController_deprecated_basic(t *testing.T) { resourceName := "kubernetes_replication_controller.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesReplicationControllerConfig_deprecated_basic(name), @@ -78,10 +78,10 @@ func TestAccKubernetesReplicationController_deprecated_initContainer(t *testing. name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_replication_controller.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_replication_controller.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesReplicationControllerConfig_deprecated_initContainer(name), @@ -107,10 +107,10 @@ func TestAccKubernetesReplicationController_deprecated_generatedName(t *testing. resourceName := "kubernetes_replication_controller.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesReplicationControllerConfig_deprecated_generatedName(prefix), diff --git a/kubernetes/resource_kubernetes_replication_controller_test.go b/kubernetes/resource_kubernetes_replication_controller_test.go index 941d0b399f..cccb5ceecf 100644 --- a/kubernetes/resource_kubernetes_replication_controller_test.go +++ b/kubernetes/resource_kubernetes_replication_controller_test.go @@ -19,10 +19,10 @@ func TestAccKubernetesReplicationController_basic(t *testing.T) { resourceName := "kubernetes_replication_controller.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesReplicationControllerConfig_basic(name), @@ -86,10 +86,10 @@ func TestAccKubernetesReplicationController_initContainer(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_replication_controller.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_replication_controller.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesReplicationControllerConfig_initContainer(name), @@ -128,10 +128,10 @@ func TestAccKubernetesReplicationController_generatedName(t *testing.T) { resourceName := "kubernetes_replication_controller.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesReplicationControllerDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesReplicationControllerConfig_generatedName(prefix), @@ -432,9 +432,7 @@ func TestAccKubernetesReplicationController_with_empty_dir_volume(t *testing.T) } func testAccCheckKubernetesReplicationControllerDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_resource_quota_test.go b/kubernetes/resource_kubernetes_resource_quota_test.go index a37bbff47b..33b10cc78c 100644 --- a/kubernetes/resource_kubernetes_resource_quota_test.go +++ b/kubernetes/resource_kubernetes_resource_quota_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesResourceQuota_basic(t *testing.T) { resourceName := "kubernetes_resource_quota.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_resource_quota.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesResourceQuotaDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_resource_quota.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesResourceQuotaDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesResourceQuotaConfig_basic(name), @@ -105,10 +105,10 @@ func TestAccKubernetesResourceQuota_generatedName(t *testing.T) { prefix := "tf-acc-test-" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_resource_quota.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesResourceQuotaDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_resource_quota.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesResourceQuotaDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesResourceQuotaConfig_generatedName(prefix), @@ -137,10 +137,10 @@ func TestAccKubernetesResourceQuota_withScopes(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_resource_quota.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesResourceQuotaDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_resource_quota.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesResourceQuotaDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesResourceQuotaConfig_withScopes(name), @@ -185,9 +185,7 @@ func TestAccKubernetesResourceQuota_withScopes(t *testing.T) { } func testAccCheckKubernetesResourceQuotaDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_role_binding_test.go b/kubernetes/resource_kubernetes_role_binding_test.go index d49ae789c7..da8deeb251 100644 --- a/kubernetes/resource_kubernetes_role_binding_test.go +++ b/kubernetes/resource_kubernetes_role_binding_test.go @@ -18,10 +18,10 @@ func TestAccKubernetesRoleBinding_basic(t *testing.T) { resourceName := "kubernetes_role_binding.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesRoleBindingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesRoleBindingDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesRoleBindingConfig_basic(name), @@ -134,10 +134,10 @@ func TestAccKubernetesRoleBinding_sa_subject(t *testing.T) { name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_role_binding.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesRoleBindingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_role_binding.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesRoleBindingDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesRoleBindingConfig_sa_subject(name), @@ -167,10 +167,10 @@ func TestAccKubernetesRoleBinding_group_subject(t *testing.T) { name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_role_binding.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesRoleBindingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_role_binding.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesRoleBindingDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesRoleBindingConfig_group_subject(name), @@ -200,10 +200,10 @@ func TestAccKubernetesRoleBinding_Bug(t *testing.T) { name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_role_binding.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesRoleBindingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_role_binding.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesRoleBindingDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesRoleBindingConfigBug_step_0(name), @@ -285,9 +285,7 @@ func TestAccKubernetesRoleBinding_Bug(t *testing.T) { } func testAccCheckKubernetesRoleBindingDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_role_test.go b/kubernetes/resource_kubernetes_role_test.go index 27d407c272..7e2fdc5ea8 100644 --- a/kubernetes/resource_kubernetes_role_test.go +++ b/kubernetes/resource_kubernetes_role_test.go @@ -19,10 +19,10 @@ func TestAccKubernetesRole_basic(t *testing.T) { resourceName := "kubernetes_role.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesRoleDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesRoleDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesRoleConfig_basic(name), @@ -88,10 +88,10 @@ func TestAccKubernetesRole_generatedName(t *testing.T) { prefix := "tf-acc-test-gen:" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_role.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesRoleDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_role.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesRoleDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesRoleConfig_generatedName(prefix), @@ -117,10 +117,10 @@ func TestAccKubernetesRole_Bug(t *testing.T) { var conf api.Role name := fmt.Sprintf("tf-acc-test:%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_role.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesRoleDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_role.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesRoleDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesRoleConfigBug_step_0(name), @@ -287,9 +287,7 @@ func testAccCheckKubernetesRoleExists(n string, obj *api.Role) resource.TestChec } func testAccCheckKubernetesRoleDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_secret_test.go b/kubernetes/resource_kubernetes_secret_test.go index 21dc2365e9..2ac94d472b 100644 --- a/kubernetes/resource_kubernetes_secret_test.go +++ b/kubernetes/resource_kubernetes_secret_test.go @@ -20,10 +20,10 @@ func TestAccKubernetesSecret_basic(t *testing.T) { resourceName := "kubernetes_secret.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesSecretDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesSecretDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesSecretConfig_emptyData(name), @@ -169,10 +169,10 @@ func TestAccKubernetesSecret_generatedName(t *testing.T) { resourceName := "kubernetes_secret.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesSecretDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesSecretDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesSecretConfig_generatedName(prefix), @@ -212,7 +212,7 @@ func TestAccKubernetesSecret_generatedName(t *testing.T) { // resource.Test(t, resource.TestCase{ // PreCheck: func() { testAccPreCheck(t) }, // IDRefreshName: "kubernetes_secret.test", -// Providers: testAccProviders, +// ProviderFactories: testAccProviderFactories, // CheckDestroy: testAccCheckKubernetesSecretDestroy, // Steps: []resource.TestStep{ // { @@ -247,9 +247,7 @@ func testAccCheckSecretData(m *api.Secret, expected map[string]string) resource. } func testAccCheckKubernetesSecretDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_service_account_test.go b/kubernetes/resource_kubernetes_service_account_test.go index ddbd4bd4ea..e47edc99fc 100644 --- a/kubernetes/resource_kubernetes_service_account_test.go +++ b/kubernetes/resource_kubernetes_service_account_test.go @@ -19,10 +19,10 @@ func TestAccKubernetesServiceAccount_basic(t *testing.T) { resourceName := "kubernetes_service_account.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceAccountConfig_basic(name), @@ -71,10 +71,10 @@ func TestAccKubernetesServiceAccount_automount(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_service_account.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_service_account.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceAccountConfig_automount(name), @@ -117,10 +117,10 @@ func TestAccKubernetesServiceAccount_update(t *testing.T) { name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_service_account.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_service_account.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceAccountConfig_basic(name), @@ -215,10 +215,10 @@ func TestAccKubernetesServiceAccount_generatedName(t *testing.T) { prefix := "tf-acc-test-gen-" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "kubernetes_service_account.test", - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "kubernetes_service_account.test", + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceAccountDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceAccountConfig_generatedName(prefix), @@ -298,9 +298,7 @@ func matchObjectReferenceName(lor []api.ObjectReference, expected []*regexp.Rege } func testAccCheckKubernetesServiceAccountDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_service_test.go b/kubernetes/resource_kubernetes_service_test.go index 1dde53b7c4..4062bf2562 100644 --- a/kubernetes/resource_kubernetes_service_test.go +++ b/kubernetes/resource_kubernetes_service_test.go @@ -21,10 +21,10 @@ func TestAccKubernetesService_basic(t *testing.T) { resourceName := "kubernetes_service.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_basic(name), @@ -129,10 +129,10 @@ func TestAccKubernetesService_loadBalancer(t *testing.T) { name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_loadBalancer(name), @@ -210,10 +210,10 @@ func TestAccKubernetesService_loadBalancer_healthcheck(t *testing.T) { name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_loadBalancer_healthcheck(name, 31111), @@ -243,10 +243,10 @@ func TestAccKubernetesService_loadBalancer_annotations_aws(t *testing.T) { name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_loadBalancer_annotations_aws(name), @@ -330,10 +330,10 @@ func TestAccKubernetesService_nodePort(t *testing.T) { name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_nodePort(name), @@ -388,10 +388,10 @@ func TestAccKubernetesService_noTargetPort(t *testing.T) { name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_noTargetPort(name), @@ -442,10 +442,10 @@ func TestAccKubernetesService_stringTargetPort(t *testing.T) { name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNoLoadBalancersAvailable(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_stringTargetPort(name), @@ -470,10 +470,10 @@ func TestAccKubernetesService_externalName(t *testing.T) { name := acctest.RandomWithPrefix("tf-acc-test") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_externalName(name), @@ -502,10 +502,10 @@ func TestAccKubernetesService_generatedName(t *testing.T) { resourceName := "kubernetes_service.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesServiceDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesServiceDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesServiceConfig_generatedName(prefix), @@ -556,9 +556,7 @@ func testAccCheckServicePorts(svc *api.Service, expected []api.ServicePort) reso } func testAccCheckKubernetesServiceDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_stateful_set_test.go b/kubernetes/resource_kubernetes_stateful_set_test.go index 4bd2fc9e4b..fb4d4ffc48 100644 --- a/kubernetes/resource_kubernetes_stateful_set_test.go +++ b/kubernetes/resource_kubernetes_stateful_set_test.go @@ -19,10 +19,10 @@ func TestAccKubernetesStatefulSet_basic(t *testing.T) { var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -39,10 +39,10 @@ func TestAccKubernetesStatefulSet_basic_idempotency(t *testing.T) { var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -68,10 +68,10 @@ func TestAccKubernetesStatefulSet_update_image(t *testing.T) { var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -95,10 +95,10 @@ func TestAccKubernetesStatefulSet_update_template_selector_labels(t *testing.T) var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -127,10 +127,10 @@ func TestAccKubernetesStatefulSet_update_replicas_to_five(t *testing.T) { var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -155,10 +155,10 @@ func TestAccKubernetesStatefulSet_update_replicas_to_zero(t *testing.T) { var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -183,10 +183,10 @@ func TestAccKubernetesStatefulSet_update_rolling_update_partition(t *testing.T) var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -211,10 +211,10 @@ func TestAccKubernetesStatefulSet_update_update_strategy_on_delete(t *testing.T) var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -241,10 +241,10 @@ func TestAccKubernetesStatefulSet_update_update_strategy_rolling_update(t *testi var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigUpdateStrategyOnDelete(name), @@ -272,10 +272,10 @@ func TestAccKubernetesStatefulSet_update_pod_template(t *testing.T) { var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigBasic(name), @@ -317,10 +317,10 @@ func TestAccKubernetesStatefulSet_waitForRollout(t *testing.T) { var conf api.StatefulSet name := fmt.Sprintf("tf-acc-test-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: statefulSetTestResourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: statefulSetTestResourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStatefulSetDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStatefulSetConfigWaitForRollout(name), @@ -334,9 +334,7 @@ func TestAccKubernetesStatefulSet_waitForRollout(t *testing.T) { } func testAccCheckKubernetesStatefulSetDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err @@ -370,9 +368,7 @@ func getStatefulSetFromResourceName(s *terraform.State, n string) (*appsv1.State return nil, fmt.Errorf("Not found: %s", n) } - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return nil, err diff --git a/kubernetes/resource_kubernetes_storage_class_test.go b/kubernetes/resource_kubernetes_storage_class_test.go index e0b9890626..e351cb5672 100644 --- a/kubernetes/resource_kubernetes_storage_class_test.go +++ b/kubernetes/resource_kubernetes_storage_class_test.go @@ -20,10 +20,10 @@ func TestAccKubernetesStorageClass_minikube(t *testing.T) { resourceName := "kubernetes_storage_class.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInMinikube(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStorageClassDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInMinikube(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStorageClassDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStorageClassConfig_basic(name, "k8s.io/minikube-hostpath"), @@ -93,10 +93,10 @@ func TestAccKubernetesStorageClass_basic(t *testing.T) { resourceName := "kubernetes_storage_class.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStorageClassDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInGke(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStorageClassDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStorageClassConfig_basic(name, "kubernetes.io/gce-pd"), @@ -194,10 +194,10 @@ func TestAccKubernetesStorageClass_allowedTopologies(t *testing.T) { resourceName := "kubernetes_storage_class.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInMinikube(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStorageClassDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInMinikube(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStorageClassDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStorageClassConfig_allowedTopologies(name, "k8s.io/minikube-hostpath"), @@ -222,10 +222,10 @@ func TestAccKubernetesStorageClass_generatedName(t *testing.T) { resourceName := "kubernetes_storage_class.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInMinikube(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesStorageClassDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotRunningInMinikube(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesStorageClassDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesStorageClassConfig_generatedName(prefix, "k8s.io/minikube"), @@ -267,9 +267,7 @@ func testAccCheckStorageClassParameters(m *api.StorageClass, expected map[string } func testAccCheckKubernetesStorageClassDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err diff --git a/kubernetes/resource_kubernetes_validating_webhook_configuration_test.go b/kubernetes/resource_kubernetes_validating_webhook_configuration_test.go index d0a8d0d4e4..4fb29a9230 100644 --- a/kubernetes/resource_kubernetes_validating_webhook_configuration_test.go +++ b/kubernetes/resource_kubernetes_validating_webhook_configuration_test.go @@ -8,6 +8,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -18,15 +20,15 @@ func TestAccKubernetesValidatingWebhookConfiguration_basic(t *testing.T) { resourceName := "kubernetes_validating_webhook_configuration.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: resourceName, - Providers: testAccProviders, - CheckDestroy: testAccCheckKubernetesValdiatingWebhookConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t); skipIfNotAdmissionRegistrationV1(t) }, + IDRefreshName: resourceName, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckKubernetesValdiatingWebhookConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccKubernetesValidatingWebhookConfigurationConfig_basic(name), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckKubernetesValdiatingWebhookConfigurationExists(resourceName), + testAccCheckKubernetesValidatingWebhookConfigurationExists(resourceName), resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name), resource.TestCheckResourceAttrSet(resourceName, "metadata.0.generation"), resource.TestCheckResourceAttrSet(resourceName, "metadata.0.resource_version"), @@ -114,10 +116,192 @@ func TestAccKubernetesValidatingWebhookConfiguration_basic(t *testing.T) { }) } +func TestAccKubernetesValidatingWebhookConfiguration_regressionV1(t *testing.T) { + name := fmt.Sprintf("acc-test-%v.terraform.io", acctest.RandString(10)) + resourceName := "kubernetes_validating_webhook_configuration.test" + var conf1, conf2 admissionregistrationv1.ValidatingWebhookConfiguration + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); skipIfNotAdmissionRegistrationV1(t) }, + IDRefreshName: resourceName, + ExternalProviders: testAccExternalProviders, + CheckDestroy: testAccCheckKubernetesValdiatingWebhookConfigurationDestroy, + Steps: []resource.TestStep{ + { // The first apply downloads and uses the latest released version of the provider. + Config: requiredProviders() + testAccKubernetesValidatingWebhookConfigurationConfig_regression("kubernetes-released", name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckKubernetesValidatingWebhookConfigurationExists(resourceName), + testAccCheckKubernetesValidatingWebhookGetObjectV1(resourceName, &conf1), + resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.generation"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.resource_version"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.self_link"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.uid"), + resource.TestCheckResourceAttr(resourceName, "webhook.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.#", "2"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.0", "v1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.1", "v1beta1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.name", "example-service"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.namespace", "example-namespace"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.port", "443"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.failure_policy", "Fail"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.match_policy", "Equivalent"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.name", name), + resource.TestCheckResourceAttr(resourceName, "webhook.0.namespace_selector.#", "0"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.object_selector.#", "0"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_groups.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_groups.0", "apps"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_versions.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_versions.0", "v1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.operations.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.operations.0", "CREATE"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.resources.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.resources.0", "pods"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.scope", "Namespaced"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.side_effects", "None"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.timeout_seconds", "10"), + ), + }, + { // The second apply uses a local, compiled version of the current branch. + Config: requiredProviders() + testAccKubernetesValidatingWebhookConfigurationConfig_regression("kubernetes-local", name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckKubernetesValidatingWebhookConfigurationExists(resourceName), + testAccCheckKubernetesValidatingWebhookGetObjectV1(resourceName, &conf2), + resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.generation"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.resource_version"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.self_link"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.uid"), + resource.TestCheckResourceAttr(resourceName, "webhook.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.#", "2"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.0", "v1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.1", "v1beta1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.name", "example-service"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.namespace", "example-namespace"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.port", "443"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.failure_policy", "Fail"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.match_policy", "Equivalent"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.name", name), + resource.TestCheckResourceAttr(resourceName, "webhook.0.namespace_selector.#", "0"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.object_selector.#", "0"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_groups.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_groups.0", "apps"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_versions.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_versions.0", "v1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.operations.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.operations.0", "CREATE"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.resources.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.resources.0", "pods"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.scope", "Namespaced"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.side_effects", "None"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.timeout_seconds", "10"), + testAccCheckKubernetesValidatingWebhookConfigV1ForceNew(&conf1, &conf2, false), + ), + }, + }, + }) +} + +func TestAccKubernetesValidatingWebhookConfiguration_regressionV1Beta1(t *testing.T) { + name := fmt.Sprintf("acc-test-%v.terraform.io", acctest.RandString(10)) + resourceName := "kubernetes_validating_webhook_configuration.test" + var conf1, conf2 admissionregistrationv1beta1.ValidatingWebhookConfiguration + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); skipIfNotAdmissionRegistrationV1Beta1(t) }, + IDRefreshName: resourceName, + ExternalProviders: testAccExternalProviders, + CheckDestroy: testAccCheckKubernetesValdiatingWebhookConfigurationDestroy, + Steps: []resource.TestStep{ + { // The first apply downloads and uses the latest released version of the provider. + Config: requiredProviders() + testAccKubernetesValidatingWebhookConfigurationConfig_regression("kubernetes-released", name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckKubernetesValidatingWebhookConfigurationExists(resourceName), + testAccCheckKubernetesValidatingWebhookGetObjectV1Beta1(resourceName, &conf1), + resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.generation"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.resource_version"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.self_link"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.uid"), + resource.TestCheckResourceAttr(resourceName, "webhook.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.#", "2"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.0", "v1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.1", "v1beta1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.name", "example-service"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.namespace", "example-namespace"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.port", "443"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.failure_policy", "Fail"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.match_policy", "Equivalent"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.name", name), + resource.TestCheckResourceAttr(resourceName, "webhook.0.namespace_selector.#", "0"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.object_selector.#", "0"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_groups.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_groups.0", "apps"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_versions.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_versions.0", "v1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.operations.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.operations.0", "CREATE"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.resources.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.resources.0", "pods"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.scope", "Namespaced"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.side_effects", "None"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.timeout_seconds", "10"), + ), + }, + { // The second apply uses a local, compiled version of the current branch. + Config: requiredProviders() + testAccKubernetesValidatingWebhookConfigurationConfig_regression("kubernetes-local", name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckKubernetesValidatingWebhookConfigurationExists(resourceName), + testAccCheckKubernetesValidatingWebhookGetObjectV1Beta1(resourceName, &conf2), + resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.generation"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.resource_version"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.self_link"), + resource.TestCheckResourceAttrSet(resourceName, "metadata.0.uid"), + resource.TestCheckResourceAttr(resourceName, "webhook.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.#", "2"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.0", "v1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.admission_review_versions.1", "v1beta1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.name", "example-service"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.namespace", "example-namespace"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.client_config.0.service.0.port", "443"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.failure_policy", "Fail"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.match_policy", "Equivalent"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.name", name), + resource.TestCheckResourceAttr(resourceName, "webhook.0.namespace_selector.#", "0"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.object_selector.#", "0"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_groups.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_groups.0", "apps"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_versions.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.api_versions.0", "v1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.operations.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.operations.0", "CREATE"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.resources.#", "1"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.resources.0", "pods"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.rule.0.scope", "Namespaced"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.side_effects", "None"), + resource.TestCheckResourceAttr(resourceName, "webhook.0.timeout_seconds", "10"), + testAccCheckKubernetesValidatingWebhookConfigV1Beta1ForceNew(&conf1, &conf2, false), + ), + }, + }, + }) +} + func testAccCheckKubernetesValdiatingWebhookConfigurationDestroy(s *terraform.State) error { - providerInit, _ := testAccProviderFactories["kubernetes"] - prov, _ := providerInit() - conn, err := prov.Meta().(KubeClientsets).MainClientset() + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() if err != nil { return err @@ -154,7 +338,7 @@ func testAccCheckKubernetesValdiatingWebhookConfigurationDestroy(s *terraform.St return nil } -func testAccCheckKubernetesValdiatingWebhookConfigurationExists(n string) resource.TestCheckFunc { +func testAccCheckKubernetesValidatingWebhookConfigurationExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { @@ -186,6 +370,70 @@ func testAccCheckKubernetesValdiatingWebhookConfigurationExists(n string) resour } } +func testAccCheckKubernetesValidatingWebhookGetObjectV1(n string, obj *admissionregistrationv1.ValidatingWebhookConfiguration) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() + if err != nil { + return err + } + ctx := context.TODO() + name := rs.Primary.ID + obj, err = conn.AdmissionregistrationV1().ValidatingWebhookConfigurations().Get(ctx, name, metav1.GetOptions{}) + return nil + } +} + +func testAccCheckKubernetesValidatingWebhookGetObjectV1Beta1(n string, obj *admissionregistrationv1beta1.ValidatingWebhookConfiguration) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() + if err != nil { + return err + } + ctx := context.TODO() + name := rs.Primary.ID + obj, err = conn.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Get(ctx, name, metav1.GetOptions{}) + return nil + } +} + +func testAccCheckKubernetesValidatingWebhookConfigV1ForceNew(old, new *admissionregistrationv1.ValidatingWebhookConfiguration, wantNew bool) resource.TestCheckFunc { + return func(s *terraform.State) error { + if wantNew { + if old.ObjectMeta.UID == new.ObjectMeta.UID { + return fmt.Errorf("Expecting new resource for ValidatingWebhookConfiguration %s", old.ObjectMeta.UID) + } + } else { + if old.ObjectMeta.UID != new.ObjectMeta.UID { + return fmt.Errorf("Expecting ValidatingWebhookConfiguration UIDs to be the same: expected %s got %s", old.ObjectMeta.UID, new.ObjectMeta.UID) + } + } + return nil + } +} + +func testAccCheckKubernetesValidatingWebhookConfigV1Beta1ForceNew(old, new *admissionregistrationv1beta1.ValidatingWebhookConfiguration, wantNew bool) resource.TestCheckFunc { + return func(s *terraform.State) error { + if wantNew { + if old.ObjectMeta.UID == new.ObjectMeta.UID { + return fmt.Errorf("Expecting new resource for ValidatingWebhookConfiguration %s", old.ObjectMeta.UID) + } + } else { + if old.ObjectMeta.UID != new.ObjectMeta.UID { + return fmt.Errorf("Expecting ValidatingWebhookConfiguration UIDs to be the same: expected %s got %s", old.ObjectMeta.UID, new.ObjectMeta.UID) + } + } + return nil + } +} + func testAccKubernetesValidatingWebhookConfigurationConfig_basic(name string) string { return fmt.Sprintf(`resource "kubernetes_validating_webhook_configuration" "test" { metadata { @@ -276,3 +524,68 @@ func testAccKubernetesValidatingWebhookConfigurationConfig_modified(name string) } `, name, name) } + +func testAccKubernetesValidatingWebhookConfigurationConfig_regression(provider, name string) string { + return fmt.Sprintf(`resource "kubernetes_validating_webhook_configuration" "test" { + provider = %s + metadata { + name = %q + } + + webhook { + name = %q + + admission_review_versions = [ + "v1", + "v1beta1" + ] + + client_config { + service { + namespace = "example-namespace" + name = "example-service" + } + } + + rule { + api_groups = ["apps"] + api_versions = ["v1"] + operations = ["CREATE"] + resources = ["pods"] + scope = "Namespaced" + } + + side_effects = "None" + timeout_seconds = 10 + } +} +`, provider, name, name) +} + +func skipIfNotAdmissionRegistrationV1Beta1(t *testing.T) { + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() + if err != nil { + t.Fatal(err) + } + useadmissionregistrationv1beta1, err := useAdmissionregistrationV1beta1(conn) + if err != nil { + t.Fatal(err) + } + if !useadmissionregistrationv1beta1 { + t.Skip("The Kubernetes endpoint is not using admissionregistrationv1beta1 - skipping.") + } +} + +func skipIfNotAdmissionRegistrationV1(t *testing.T) { + conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset() + if err != nil { + t.Fatal(err) + } + useadmissionregistrationv1beta1, err := useAdmissionregistrationV1beta1(conn) + if err != nil { + t.Fatal(err) + } + if useadmissionregistrationv1beta1 { + t.Skip("The Kubernetes endpoint is not using admissionregistrationv1 - skipping.") + } +}