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

Read Bigtable column family from the API #70

Merged
merged 1 commit into from
Oct 31, 2018
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
15 changes: 14 additions & 1 deletion google-beta/resource_bigtable_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ 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("")
return fmt.Errorf("Error retrieving table. Could not find %s in %s. %s", name, instanceName, err)
}

d.Set("project", project)
d.Set("column_family", flattenColumnFamily(table.Families))

return nil
}
Expand Down Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions website/docs/r/bigtable_table.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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

Expand Down