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

Add tags field to Filestore Instances for TagsR2401 #12441

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions mmv1/products/filestore/Instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,12 @@ properties:
description: |
The number of IOPS to provision for the instance.
max_iops must be in multiple of 1000.
- name: 'tags'
type: KeyValuePairs
description: |
A map of resource manager tags_.
Resource manager tag keys and values have the same definition as resource manager tags.
Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456.
The field is ignored (both PUT & PATCH) when empty.
immutable: true
ignore_read: true
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,54 @@ resource "google_filestore_instance" "instance" {
}
`, name, location, tier)
}

func TestAccFilestoreInstance_tags(t *testing.T) {
t.Parallel()
name := fmt.Sprintf("tf-test-%d", acctest.RandInt(t))
org := envvar.GetTestOrgFromEnv(t)
tagKey := acctest.BootstrapSharedTestTagKey(t, "filestore-instances-tagkey")
tagValue := acctest.BootstrapSharedTestTagValue(t, "filestore-instances-tagvalue", tagKey)

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckFilestoreInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccFileInstanceTags(name, map[string]string{org + "/" + tagKey: tagValue}),
},
{
ResourceName: "google_filestore_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"zone", "location", "networks.0.reserved_ip_range", "tags"},
},
},
})
}

func testAccFileInstanceTags(name string, tags map[string]string) string {
r := fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "tf-instance-%s"
zone = "us-central1-b"
tier = "BASIC_HDD"
file_shares {
capacity_gb = 1024
name = "share1"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
reserved_ip_range = "172.19.31.8/29"
}
tags = {`, name)

l := ""
for key, value := range tags {
l += fmt.Sprintf("%q = %q\n", key, value)
}

l += fmt.Sprintf("}\n}")
return r + l
}
Loading