2017-12-20 21:21:11 +00:00
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
)
|
|
|
|
|
2018-05-07 22:02:14 +00:00
|
|
|
func TestAccContainerClusterDatasource_zonal(t *testing.T) {
|
2017-12-20 21:21:11 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
{
|
2018-05-07 22:02:14 +00:00
|
|
|
Config: testAccContainerClusterDatasource_zonal(),
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
2019-05-20 23:11:01 +00:00
|
|
|
checkDataSourceStateMatchesResourceStateWithIgnores(
|
|
|
|
"data.google_container_cluster.kubes",
|
|
|
|
"google_container_cluster.kubes",
|
|
|
|
// Remove once https://github.com/hashicorp/terraform/issues/21347 is fixed.
|
|
|
|
map[string]struct{}{
|
|
|
|
"enable_tpu": {},
|
|
|
|
"enable_binary_authorization": {},
|
|
|
|
"pod_security_policy_config.#": {},
|
|
|
|
},
|
|
|
|
),
|
2018-05-07 22:02:14 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccContainerClusterDatasource_regional(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
{
|
|
|
|
Config: testAccContainerClusterDatasource_regional(),
|
2017-12-20 21:21:11 +00:00
|
|
|
Check: resource.ComposeTestCheckFunc(
|
2019-05-20 23:11:01 +00:00
|
|
|
checkDataSourceStateMatchesResourceStateWithIgnores(
|
|
|
|
"data.google_container_cluster.kubes",
|
|
|
|
"google_container_cluster.kubes",
|
|
|
|
// Remove once https://github.com/hashicorp/terraform/issues/21347 is fixed.
|
|
|
|
map[string]struct{}{
|
|
|
|
"enable_tpu": {},
|
|
|
|
"enable_binary_authorization": {},
|
|
|
|
"pod_security_policy_config.#": {},
|
|
|
|
},
|
|
|
|
),
|
2017-12-20 21:21:11 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-05-07 22:02:14 +00:00
|
|
|
func testAccContainerClusterDatasource_zonal() string {
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "google_container_cluster" "kubes" {
|
|
|
|
name = "cluster-test-%s"
|
2019-03-13 16:32:46 +00:00
|
|
|
location = "us-central1-a"
|
2018-05-07 22:02:14 +00:00
|
|
|
initial_node_count = 1
|
2019-03-13 16:32:46 +00:00
|
|
|
|
2018-05-07 22:02:14 +00:00
|
|
|
master_auth {
|
|
|
|
username = "mr.yoda"
|
|
|
|
password = "adoy.rm.123456789"
|
2017-12-20 21:21:11 +00:00
|
|
|
}
|
2018-05-07 22:02:14 +00:00
|
|
|
}
|
2019-03-13 16:32:46 +00:00
|
|
|
|
2018-05-07 22:02:14 +00:00
|
|
|
data "google_container_cluster" "kubes" {
|
2019-03-13 16:32:46 +00:00
|
|
|
name = "${google_container_cluster.kubes.name}"
|
|
|
|
location = "${google_container_cluster.kubes.zone}"
|
2018-05-07 22:02:14 +00:00
|
|
|
}
|
2017-12-20 21:21:11 +00:00
|
|
|
`, acctest.RandString(10))
|
2018-05-07 22:02:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func testAccContainerClusterDatasource_regional() string {
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "google_container_cluster" "kubes" {
|
|
|
|
name = "cluster-test-%s"
|
2019-03-13 16:32:46 +00:00
|
|
|
location = "us-central1"
|
2018-05-07 22:02:14 +00:00
|
|
|
initial_node_count = 1
|
|
|
|
}
|
2019-03-13 16:32:46 +00:00
|
|
|
|
2018-05-07 22:02:14 +00:00
|
|
|
data "google_container_cluster" "kubes" {
|
2019-03-13 16:32:46 +00:00
|
|
|
name = "${google_container_cluster.kubes.name}"
|
|
|
|
location = "${google_container_cluster.kubes.region}"
|
2018-05-07 22:02:14 +00:00
|
|
|
}
|
|
|
|
`, acctest.RandString(10))
|
|
|
|
}
|