Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MaxItems validation check on Bigtable instance cluster count #4166

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions third_party/terraform/resources/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 third_party/terraform/tests/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