-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix reserved_ip_range * add a test * fixes lint error Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
f9ddad4
commit 43c1f1e
Showing
3 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
filestore: fixed `reserved_ip_range` can't be updated on `google_filestore_instance` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,151 @@ | ||
package google | ||
|
||
// Magic Modules doesn't let us remove files - blank out beta-only common-compile files for now. | ||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccFilestoreInstance_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
name := fmt.Sprintf("tf-test-%d", randInt(t)) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckFilestoreInstanceDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFilestoreInstance_update(name), | ||
}, | ||
{ | ||
ResourceName: "google_filestore_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccFilestoreInstance_update2(name), | ||
}, | ||
{ | ||
ResourceName: "google_filestore_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccFilestoreInstance_update(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_filestore_instance" "instance" { | ||
name = "tf-instance-%s" | ||
zone = "us-central1-b" | ||
file_shares { | ||
capacity_gb = 2660 | ||
name = "share" | ||
} | ||
networks { | ||
network = "default" | ||
modes = ["MODE_IPV4"] | ||
} | ||
labels = { | ||
baz = "qux" | ||
} | ||
tier = "PREMIUM" | ||
description = "An instance created during testing." | ||
} | ||
`, name) | ||
} | ||
|
||
func testAccFilestoreInstance_update2(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_filestore_instance" "instance" { | ||
name = "tf-instance-%s" | ||
zone = "us-central1-b" | ||
file_shares { | ||
capacity_gb = 2760 | ||
name = "share" | ||
} | ||
networks { | ||
network = "default" | ||
modes = ["MODE_IPV4"] | ||
} | ||
tier = "PREMIUM" | ||
description = "A modified instance created during testing." | ||
} | ||
`, name) | ||
} | ||
|
||
func TestAccFilestoreInstance_reservedIpRange_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
name := fmt.Sprintf("tf-test-%d", randInt(t)) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckFilestoreInstanceDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFilestoreInstance_reservedIpRange_update(name), | ||
}, | ||
{ | ||
ResourceName: "google_filestore_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccFilestoreInstance_reservedIpRange_update2(name), | ||
}, | ||
{ | ||
ResourceName: "google_filestore_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccFilestoreInstance_reservedIpRange_update(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_filestore_instance" "instance" { | ||
name = "tf-instance-%s" | ||
zone = "us-central1-b" | ||
tier = "BASIC_HDD" | ||
file_shares { | ||
capacity_gb = 1024 | ||
name = "share1" | ||
} | ||
networks { | ||
network = "default" | ||
modes = ["MODE_IPV4"] | ||
reserved_ip_range = "172.19.30.0/29" | ||
} | ||
} | ||
`, name) | ||
} | ||
|
||
func testAccFilestoreInstance_reservedIpRange_update2(name string) string { | ||
return fmt.Sprintf(` | ||
resource "google_filestore_instance" "instance" { | ||
name = "tf-instance-%s" | ||
zone = "us-central1-b" | ||
tier = "BASIC_HDD" | ||
file_shares { | ||
capacity_gb = 1024 | ||
name = "share1" | ||
} | ||
networks { | ||
network = "default" | ||
modes = ["MODE_IPV4"] | ||
reserved_ip_range = "172.19.31.0/29" | ||
} | ||
} | ||
`, name) | ||
} |