mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-03 01:01:06 +00:00
formatting changes for google_compute_instance tests
This commit is contained in:
parent
abea820372
commit
4ee6fc5602
@ -849,7 +849,7 @@ func testAccCheckComputeInstanceHasAddress(instance *compute.Instance, address s
|
||||
|
||||
func testAccComputeInstance_basic_deprecated_network(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -867,12 +867,13 @@ func testAccComputeInstance_basic_deprecated_network(instance string) string {
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_update_deprecated_network(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -889,12 +890,13 @@ func testAccComputeInstance_update_deprecated_network(instance string) string {
|
||||
metadata {
|
||||
bar = "baz"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_basic(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -917,12 +919,13 @@ func testAccComputeInstance_basic(instance string) string {
|
||||
create_timeout = 5
|
||||
|
||||
metadata_startup_script = "echo Hello"
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_basic2(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -940,12 +943,13 @@ func testAccComputeInstance_basic2(instance string) string {
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_basic3(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -960,16 +964,16 @@ func testAccComputeInstance_basic3(instance string) string {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_basic4(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -988,12 +992,13 @@ func testAccComputeInstance_basic4(instance string) string {
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_basic5(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1011,17 +1016,17 @@ func testAccComputeInstance_basic5(instance string) string {
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
// Update zone to ForceNew, and change metadata k/v entirely
|
||||
// Generates diff mismatch
|
||||
func testAccComputeInstance_forceNewAndChangeMetadata(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
zone = "us-central1-b"
|
||||
tags = ["baz"]
|
||||
|
||||
@ -1037,13 +1042,14 @@ func testAccComputeInstance_forceNewAndChangeMetadata(instance string) string {
|
||||
metadata {
|
||||
qux = "true"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
// Update metadata, tags, and network_interface
|
||||
func testAccComputeInstance_update(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1061,16 +1067,17 @@ func testAccComputeInstance_update(instance string) string {
|
||||
metadata {
|
||||
bar = "baz"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_ip(ip, instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_address" "foo" {
|
||||
resource "google_compute_address" "foo" {
|
||||
name = "%s"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1090,19 +1097,20 @@ func testAccComputeInstance_ip(ip, instance string) string {
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, ip, instance)
|
||||
}
|
||||
`, ip, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_disks(disk, instance string, autodelete bool) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_disk" "foobar" {
|
||||
resource "google_compute_disk" "foobar" {
|
||||
name = "%s"
|
||||
size = 10
|
||||
type = "pd-ssd"
|
||||
zone = "us-central1-a"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1123,19 +1131,20 @@ func testAccComputeInstance_disks(disk, instance string, autodelete bool) string
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, disk, instance, autodelete)
|
||||
}
|
||||
`, disk, instance, autodelete)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_disks_encryption(disk, instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_disk" "foobar" {
|
||||
resource "google_compute_disk" "foobar" {
|
||||
name = "%s"
|
||||
size = 10
|
||||
type = "pd-ssd"
|
||||
zone = "us-central1-a"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1156,19 +1165,20 @@ func testAccComputeInstance_disks_encryption(disk, instance string) string {
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, disk, instance)
|
||||
}
|
||||
`, disk, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_attachedDisk(disk, instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_disk" "foobar" {
|
||||
resource "google_compute_disk" "foobar" {
|
||||
name = "%s"
|
||||
size = 10
|
||||
type = "pd-ssd"
|
||||
zone = "us-central1-a"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1184,12 +1194,13 @@ func testAccComputeInstance_attachedDisk(disk, instance string) string {
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, disk, instance)
|
||||
}
|
||||
`, disk, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_noDisk(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1201,12 +1212,13 @@ func testAccComputeInstance_noDisk(instance string) string {
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_local_ssd(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "local-ssd" {
|
||||
resource "google_compute_instance" "local-ssd" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1224,12 +1236,13 @@ func testAccComputeInstance_local_ssd(instance string) string {
|
||||
network = "default"
|
||||
}
|
||||
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_service_account(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1249,12 +1262,13 @@ func testAccComputeInstance_service_account(instance string) string {
|
||||
"storage-ro",
|
||||
]
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_scheduling(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1269,17 +1283,19 @@ func testAccComputeInstance_scheduling(instance string) string {
|
||||
|
||||
scheduling {
|
||||
}
|
||||
}`, instance)
|
||||
}
|
||||
`, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_subnet_auto(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
name = "inst-test-network-%s"
|
||||
auto_create_subnetworks = true
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
auto_create_subnetworks = true
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1293,24 +1309,26 @@ func testAccComputeInstance_subnet_auto(instance string) string {
|
||||
access_config { }
|
||||
}
|
||||
|
||||
}`, acctest.RandString(10), instance)
|
||||
}
|
||||
`, acctest.RandString(10), instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_subnet_custom(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
name = "inst-test-network-%s"
|
||||
auto_create_subnetworks = false
|
||||
}
|
||||
|
||||
resource "google_compute_subnetwork" "inst-test-subnetwork" {
|
||||
auto_create_subnetworks = false
|
||||
}
|
||||
|
||||
resource "google_compute_subnetwork" "inst-test-subnetwork" {
|
||||
name = "inst-test-subnetwork-%s"
|
||||
ip_cidr_range = "10.0.0.0/16"
|
||||
region = "us-central1"
|
||||
network = "${google_compute_network.inst-test-network.self_link}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1324,26 +1342,28 @@ func testAccComputeInstance_subnet_custom(instance string) string {
|
||||
access_config { }
|
||||
}
|
||||
|
||||
}`, acctest.RandString(10), acctest.RandString(10), instance)
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10), instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_subnet_xpn(instance, xpn_host string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
name = "inst-test-network-%s"
|
||||
auto_create_subnetworks = false
|
||||
project = "%s"
|
||||
}
|
||||
|
||||
resource "google_compute_subnetwork" "inst-test-subnetwork" {
|
||||
auto_create_subnetworks = false
|
||||
}
|
||||
|
||||
resource "google_compute_subnetwork" "inst-test-subnetwork" {
|
||||
name = "inst-test-subnetwork-%s"
|
||||
ip_cidr_range = "10.0.0.0/16"
|
||||
region = "us-central1"
|
||||
network = "${google_compute_network.inst-test-network.self_link}"
|
||||
project = "%s"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1358,21 +1378,22 @@ func testAccComputeInstance_subnet_xpn(instance, xpn_host string) string {
|
||||
access_config { }
|
||||
}
|
||||
|
||||
}`, acctest.RandString(10), xpn_host, acctest.RandString(10), xpn_host, instance)
|
||||
}
|
||||
`, acctest.RandString(10), xpn_host, acctest.RandString(10), xpn_host, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_address_auto(instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
name = "inst-test-network-%s"
|
||||
}
|
||||
resource "google_compute_subnetwork" "inst-test-subnetwork" {
|
||||
}
|
||||
resource "google_compute_subnetwork" "inst-test-subnetwork" {
|
||||
name = "inst-test-subnetwork-%s"
|
||||
ip_cidr_range = "10.0.0.0/16"
|
||||
region = "us-central1"
|
||||
network = "${google_compute_network.inst-test-network.self_link}"
|
||||
}
|
||||
resource "google_compute_instance" "foobar" {
|
||||
}
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1386,21 +1407,22 @@ func testAccComputeInstance_address_auto(instance string) string {
|
||||
access_config { }
|
||||
}
|
||||
|
||||
}`, acctest.RandString(10), acctest.RandString(10), instance)
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10), instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_address_custom(instance, address string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
resource "google_compute_network" "inst-test-network" {
|
||||
name = "inst-test-network-%s"
|
||||
}
|
||||
resource "google_compute_subnetwork" "inst-test-subnetwork" {
|
||||
}
|
||||
resource "google_compute_subnetwork" "inst-test-subnetwork" {
|
||||
name = "inst-test-subnetwork-%s"
|
||||
ip_cidr_range = "10.0.0.0/16"
|
||||
region = "us-central1"
|
||||
network = "${google_compute_network.inst-test-network.self_link}"
|
||||
}
|
||||
resource "google_compute_instance" "foobar" {
|
||||
}
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1415,24 +1437,25 @@ func testAccComputeInstance_address_custom(instance, address string) string {
|
||||
access_config { }
|
||||
}
|
||||
|
||||
}`, acctest.RandString(10), acctest.RandString(10), instance, address)
|
||||
}
|
||||
`, acctest.RandString(10), acctest.RandString(10), instance, address)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_private_image_family(disk, image, family, instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_disk" "foobar" {
|
||||
resource "google_compute_disk" "foobar" {
|
||||
name = "%s"
|
||||
zone = "us-central1-a"
|
||||
image = "debian-8-jessie-v20160803"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_image" "foobar" {
|
||||
resource "google_compute_image" "foobar" {
|
||||
name = "%s"
|
||||
source_disk = "${google_compute_disk.foobar.self_link}"
|
||||
family = "%s"
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
@ -1448,12 +1471,13 @@ func testAccComputeInstance_private_image_family(disk, image, family, instance s
|
||||
metadata {
|
||||
foo = "bar"
|
||||
}
|
||||
}`, disk, image, family, instance)
|
||||
}
|
||||
`, disk, image, family, instance)
|
||||
}
|
||||
|
||||
func testAccComputeInstance_invalid_disk(disk, instance string) string {
|
||||
return fmt.Sprintf(`
|
||||
resource "google_compute_instance" "foobar" {
|
||||
resource "google_compute_instance" "foobar" {
|
||||
name = "%s"
|
||||
machine_type = "f1-micro"
|
||||
zone = "us-central1-a"
|
||||
@ -1472,12 +1496,13 @@ func testAccComputeInstance_invalid_disk(disk, instance string) string {
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_disk" "foobar" {
|
||||
resource "google_compute_disk" "foobar" {
|
||||
name = "%s"
|
||||
zone = "us-central1-a"
|
||||
type = "pd-standard"
|
||||
size = "1"
|
||||
}`, instance, disk)
|
||||
}
|
||||
`, instance, disk)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user