mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
0.12 Computed+Optional Attr syntax fixes (#3452)
<!-- This change is generated by MagicModules. --> Original Author: @rileykarson
This commit is contained in:
parent
2747e8261d
commit
9ac574e185
@ -48,6 +48,9 @@ var schemaNodeConfig = &schema.Schema{
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
// Legacy config mode allows removing GPU's from an existing resource
|
||||||
|
// See https://www.terraform.io/docs/configuration/attr-as-blocks.html
|
||||||
|
ConfigMode: schema.SchemaConfigModeAttr,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"count": {
|
"count": {
|
||||||
|
@ -159,7 +159,6 @@ func TestAccComputeInstanceFromTemplate_012_removableFields(t *testing.T) {
|
|||||||
testAccCheckComputeInstanceExists(resourceName, &instance),
|
testAccCheckComputeInstanceExists(resourceName, &instance),
|
||||||
|
|
||||||
// Check that fields were able to be removed
|
// Check that fields were able to be removed
|
||||||
resource.TestCheckResourceAttr(resourceName, "service_account.#", "0"),
|
|
||||||
resource.TestCheckResourceAttr(resourceName, "scratch_disk.#", "0"),
|
resource.TestCheckResourceAttr(resourceName, "scratch_disk.#", "0"),
|
||||||
resource.TestCheckResourceAttr(resourceName, "attached_disk.#", "0"),
|
resource.TestCheckResourceAttr(resourceName, "attached_disk.#", "0"),
|
||||||
resource.TestCheckResourceAttr(resourceName, "network_interface.0.alias_ip_range.#", "0"),
|
resource.TestCheckResourceAttr(resourceName, "network_interface.0.alias_ip_range.#", "0"),
|
||||||
|
@ -430,6 +430,39 @@ func TestAccContainerNodePool_regionalClusters(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccContainerNodePool_012_ConfigModeAttr(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
cluster := fmt.Sprintf("tf-nodepool-test-%s", acctest.RandString(10))
|
||||||
|
np := fmt.Sprintf("tf-nodepool-test-%s", acctest.RandString(10))
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckContainerNodePoolDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
{
|
||||||
|
Config: testAccContainerNodePool_012_ConfigModeAttr1(cluster, np),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ResourceName: "google_container_node_pool.np",
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Config: testAccContainerNodePool_012_ConfigModeAttr2(cluster, np),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ResourceName: "google_container_node_pool.np",
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckContainerNodePoolDestroy(s *terraform.State) error {
|
func testAccCheckContainerNodePoolDestroy(s *terraform.State) error {
|
||||||
config := testAccProvider.Meta().(*Config)
|
config := testAccProvider.Meta().(*Config)
|
||||||
|
|
||||||
@ -824,3 +857,46 @@ resource "google_container_node_pool" "np" {
|
|||||||
version = "${data.google_container_engine_versions.central1a.valid_node_versions.0}"
|
version = "${data.google_container_engine_versions.central1a.valid_node_versions.0}"
|
||||||
}`, cluster, np)
|
}`, cluster, np)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testAccContainerNodePool_012_ConfigModeAttr1(cluster, np string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "google_container_cluster" "cluster" {
|
||||||
|
name = "%s"
|
||||||
|
zone = "us-central1-f"
|
||||||
|
initial_node_count = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_container_node_pool" "np" {
|
||||||
|
name = "%s"
|
||||||
|
zone = "us-central1-f"
|
||||||
|
cluster = "${google_container_cluster.cluster.name}"
|
||||||
|
initial_node_count = 1
|
||||||
|
|
||||||
|
node_config {
|
||||||
|
guest_accelerator {
|
||||||
|
count = 1
|
||||||
|
type = "nvidia-tesla-p100"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`, cluster, np)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testAccContainerNodePool_012_ConfigModeAttr2(cluster, np string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "google_container_cluster" "cluster" {
|
||||||
|
name = "%s"
|
||||||
|
zone = "us-central1-f"
|
||||||
|
initial_node_count = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_container_node_pool" "np" {
|
||||||
|
name = "%s"
|
||||||
|
zone = "us-central1-f"
|
||||||
|
cluster = "${google_container_cluster.cluster.name}"
|
||||||
|
initial_node_count = 1
|
||||||
|
|
||||||
|
node_config {
|
||||||
|
guest_accelerator = []
|
||||||
|
}
|
||||||
|
}`, cluster, np)
|
||||||
|
}
|
||||||
|
@ -472,6 +472,8 @@ The `node_config` block supports:
|
|||||||
|
|
||||||
* `guest_accelerator` - (Optional) List of the type and count of accelerator cards attached to the instance.
|
* `guest_accelerator` - (Optional) List of the type and count of accelerator cards attached to the instance.
|
||||||
Structure documented below.
|
Structure documented below.
|
||||||
|
To support removal of guest_accelerators in Terraform 0.12 this field is an
|
||||||
|
[Attribute as Block](/docs/configuration/attr-as-blocks.html)
|
||||||
|
|
||||||
* `image_type` - (Optional) The image type to use for this node. Note that changing the image type
|
* `image_type` - (Optional) The image type to use for this node. Note that changing the image type
|
||||||
will delete and recreate all nodes in the node pool.
|
will delete and recreate all nodes in the node pool.
|
||||||
|
Loading…
Reference in New Issue
Block a user