Skip to content

Commit

Permalink
add data catalog tag
Browse files Browse the repository at this point in the history
  • Loading branch information
megan07 committed May 26, 2020
1 parent e2afb22 commit 000ef9b
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 7 deletions.
8 changes: 2 additions & 6 deletions products/datacatalog/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,6 @@ objects:
description: |
The display name of the tag template.
output: true
- !ruby/object:Api::Type::String
name: description
description: |
Entry description, which can consist of several sentences or paragraphs that describe entry contents.
- !ruby/object:Api::Type::Map
name: fields
description: |
Expand Down Expand Up @@ -482,5 +478,5 @@ objects:
Resources like Entry can have schemas associated with them. This scope allows users to attach tags to an
individual column based on that schema.
For attaching a tag to a nested column, use . to separate the column names. Example:
outer_column.inner_column
For attaching a tag to a nested column, use `.` to separate the column names. Example:
`outer_column.inner_column`
2 changes: 1 addition & 1 deletion products/datacatalog/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
tag_template_id: "my_template"
- !ruby/object:Provider::Terraform::Examples
name: "data_catalog_entry_tag_full"
primary_resource_id: "basic_entry_tag_full"
primary_resource_id: "basic_tag"
vars:
entry_group_id: "my_entry_group"
entry_id: "my_entry"
Expand Down
119 changes: 119 additions & 0 deletions third_party/terraform/tests/resource_data_catalog_tag_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package google

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccDataCatalogTag_update(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDataCatalogEntryDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataCatalogTag_dataCatalogEntryTagBasicExample(context),
},
{
ResourceName: "google_data_catalog_tag.basic_tag",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDataCatalogTag_dataCatalogEntryTag_update(context),
},
{
ResourceName: "google_data_catalog_tag.basic_tag",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDataCatalogTag_dataCatalogEntryTagBasicExample(context),
},
{
ResourceName: "google_data_catalog_tag.basic_tag",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccDataCatalogTag_dataCatalogEntryTag_update(context map[string]interface{}) string {
return Nprintf(`
resource "google_data_catalog_entry" "entry" {
entry_group = google_data_catalog_entry_group.entry_group.id
entry_id = "tf_test_my_entry%{random_suffix}"
user_specified_type = "my_custom_type"
user_specified_system = "SomethingExternal"
}
resource "google_data_catalog_entry_group" "entry_group" {
entry_group_id = "tf_test_my_entry_group%{random_suffix}"
}
resource "google_data_catalog_tag_template" "tag_template" {
tag_template_id = "tf_test_my_template%{random_suffix}"
region = "us-central1"
display_name = "Demo Tag Template"
fields {
field_id = "source"
display_name = "Source of data asset"
type {
primitive_type = "STRING"
}
is_required = true
}
fields {
field_id = "num_rows"
display_name = "Number of rows in the data asset"
type {
primitive_type = "DOUBLE"
}
}
fields {
field_id = "pii_type"
display_name = "PII type"
type {
enum_type {
allowed_values {
display_name = "EMAIL"
}
allowed_values {
display_name = "SOCIAL SECURITY NUMBER"
}
allowed_values {
display_name = "NONE"
}
}
}
}
}
resource "google_data_catalog_tag" "basic_tag" {
parent = google_data_catalog_entry.entry.id
template = google_data_catalog_tag_template.tag_template.id
fields {
field_name = "source"
string_value = "my-new-string"
}
fields {
field_name = "num_rows"
double_value = 5
}
}
`, context)
}

0 comments on commit 000ef9b

Please sign in to comment.