Skip to content

Commit

Permalink
Remove MaxItems validation check on Bigtable instance cluster count (#…
Browse files Browse the repository at this point in the history
…4166) (#7713)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Nov 5, 2020
1 parent 669026c commit 03518f4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .changelog/4166.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
7 changes: 2 additions & 5 deletions google/resource_bigtable_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func resourceBigtableInstance() *schema.Resource {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: `A block of cluster configuration options. This can be specified at least once, and up to 4 times.`,
Description: `A block of cluster configuration options. This can be specified at least once.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cluster_id": {
Expand Down Expand Up @@ -382,13 +382,10 @@ func expandBigtableClusters(clusters []interface{}, instanceID string) []bigtabl
func resourceBigtableInstanceClusterReorderTypeList(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error {
oldCount, newCount := diff.GetChange("cluster.#")

// simulate Required:true, MinItems:1, MaxItems:4 for "cluster"
// simulate Required:true, MinItems:1 for "cluster"
if newCount.(int) < 1 {
return fmt.Errorf("config is invalid: Too few cluster blocks: Should have at least 1 \"cluster\" block")
}
if newCount.(int) > 4 {
return fmt.Errorf("config is invalid: Too many cluster blocks: No more than 4 \"cluster\" blocks are allowed")
}

// exit early if we're in create (name's old value is nil)
n, _ := diff.GetChange("name")
Expand Down
44 changes: 0 additions & 44 deletions google/resource_bigtable_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ func TestAccBigtableInstance_cluster(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckBigtableInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccBigtableInstance_clusterMax(instanceName),
ExpectError: regexp.MustCompile("config is invalid: Too many cluster blocks: No more than 4 \"cluster\" blocks are allowed"),
},
{
Config: testAccBigtableInstance_cluster(instanceName, 3),
},
Expand Down Expand Up @@ -250,46 +246,6 @@ resource "google_bigtable_instance" "instance" {
`, instanceName, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes, instanceName, numNodes)
}

func testAccBigtableInstance_clusterMax(instanceName string) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
name = "%s"
cluster {
cluster_id = "%s-a"
zone = "us-central1-a"
num_nodes = 3
storage_type = "HDD"
}
cluster {
cluster_id = "%s-b"
zone = "us-central1-b"
num_nodes = 3
storage_type = "HDD"
}
cluster {
cluster_id = "%s-c"
zone = "us-central1-c"
num_nodes = 3
storage_type = "HDD"
}
cluster {
cluster_id = "%s-d"
zone = "us-central1-f"
num_nodes = 3
storage_type = "HDD"
}
cluster {
cluster_id = "%s-e"
zone = "us-east1-a"
num_nodes = 3
storage_type = "HDD"
}
deletion_protection = false
}
`, instanceName, instanceName, instanceName, instanceName, instanceName, instanceName)
}

func testAccBigtableInstance_clusterReordered(instanceName string, numNodes int) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
Expand Down

0 comments on commit 03518f4

Please sign in to comment.