From 26ba086dbc9ddb30e810f847d6add93f9061314f Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 31 Oct 2018 13:21:58 -0700 Subject: [PATCH] Read Bigtable column family from the API (#2378) /cc @rileykarson --- google/resource_bigtable_table.go | 15 ++++++++++++++- website/docs/r/bigtable_table.html.markdown | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/google/resource_bigtable_table.go b/google/resource_bigtable_table.go index 4afeefdd..a42a6564 100644 --- a/google/resource_bigtable_table.go +++ b/google/resource_bigtable_table.go @@ -130,7 +130,7 @@ func resourceBigtableTableRead(d *schema.ResourceData, meta interface{}) error { defer c.Close() name := d.Id() - _, err = c.TableInfo(ctx, name) + table, err := c.TableInfo(ctx, name) if err != nil { log.Printf("[WARN] Removing %s because it's gone", name) d.SetId("") @@ -138,6 +138,7 @@ func resourceBigtableTableRead(d *schema.ResourceData, meta interface{}) error { } d.Set("project", project) + d.Set("column_family", flattenColumnFamily(table.Families)) return nil } @@ -169,3 +170,15 @@ func resourceBigtableTableDestroy(d *schema.ResourceData, meta interface{}) erro return nil } + +func flattenColumnFamily(families []string) []map[string]interface{} { + result := make([]map[string]interface{}, 0, len(families)) + + for _, f := range families { + data := make(map[string]interface{}) + data["family"] = f + result = append(result, data) + } + + return result +} diff --git a/website/docs/r/bigtable_table.html.markdown b/website/docs/r/bigtable_table.html.markdown index e73dceaa..176d715d 100644 --- a/website/docs/r/bigtable_table.html.markdown +++ b/website/docs/r/bigtable_table.html.markdown @@ -3,12 +3,12 @@ layout: "google" page_title: "Google: google_bigtable_table" sidebar_current: "docs-google-bigtable-table" description: |- - Creates a Google Bigtable table inside an instance. + Creates a Google Cloud Bigtable table inside an instance. --- # google_bigtable_table -Creates a Google Bigtable table inside an instance. For more information see +Creates a Google Cloud Bigtable table inside an instance. For more information see [the official documentation](https://cloud.google.com/bigtable/) and [API](https://cloud.google.com/bigtable/docs/go/reference). @@ -50,7 +50,7 @@ The following arguments are supported: `column_family` supports the following arguments: -* `family` - (Optional) Creates a new column family in a table. +* `family` - (Optional) The name of the column family. ## Attributes Reference