Skip to content

Commit

Permalink
Added tag value resource (#4603)
Browse files Browse the repository at this point in the history
* Added tag value resource

* Copied tag key tests and adjusted for values

* Corrected duplicate map keys

* Added validation to shortnames and descriptions

* Renamed tags tests since they're no longer tag-key-only
  • Loading branch information
melinath authored Mar 30, 2021
1 parent a78a003 commit b029983
Show file tree
Hide file tree
Showing 5 changed files with 410 additions and 160 deletions.
56 changes: 56 additions & 0 deletions mmv1/products/tags/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,59 @@ objects:
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
output: true
- !ruby/object:Api::Resource
name: 'TagValue'
min_version: beta
base_url: tagValues
self_link: "tagValues/{{name}}"
update_verb: :PATCH
update_mask: true
description: A TagValue is a child of a particular TagKey. TagValues are used to group cloud resources for the purpose of controlling them using policies.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation':
'https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing'
api: 'https://cloud.google.com/resource-manager/reference/rest/v3/tagValues'
properties:
- !ruby/object:Api::Type::String
name: name
description: |
The generated numeric id for the TagValue.
output: true
- !ruby/object:Api::Type::String
name: parent
description: |
Input only. The resource name of the new TagValue's parent. Must be of the form tagKeys/{tag_key_id}.
input: true
required: true
- !ruby/object:Api::Type::String
name: shortName
description: |
Input only. User-assigned short name for TagValue. The short name should be unique for TagValues within the same parent TagKey.
The short name must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.
input: true
required: true
- !ruby/object:Api::Type::String
name: namespacedName
description: |
Output only. Namespaced name of the TagValue. Will be in the format {organizationId}/{tag_key_short_name}/{shortName}.
output: true
- !ruby/object:Api::Type::String
name: description
description: |
User-assigned description of the TagValue. Must not exceed 256 characters.
- !ruby/object:Api::Type::String
name: createTime
description: |
Output only. Creation time.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
output: true
- !ruby/object:Api::Type::String
name: updateTime
description: |
Output only. Update time.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
output: true
31 changes: 30 additions & 1 deletion mmv1/products/tags/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,43 @@ overrides: !ruby/object:Overrides::ResourceOverrides
properties:
name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
shortName: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.StringLenBetween(1, 63)'
description: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.StringLenBetween(0, 256)'
examples:
- !ruby/object:Provider::Terraform::Examples
name: "tag_key_basic"
min_version: 'beta'
skip_vcr: true
skip_test: true
primary_resource_id: "key"
vars:
short_name: "foo"
test_env_vars:
org_id: :ORG_ID
TagValue: !ruby/object:Overrides::Terraform::ResourceOverride
autogen_async: true
mutex: tagValue/{{parent}}
id_format: "tagValues/{{name}}"
import_format: ["tagValues/{{name}}", "{{name}}"]
properties:
name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
shortName: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.StringLenBetween(1, 63)'
description: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.StringLenBetween(0, 256)'
examples:
- !ruby/object:Provider::Terraform::Examples
name: "tag_value_basic"
min_version: 'beta'
skip_test: true
primary_resource_id: "value"
vars:
short_name: "foo"
test_env_vars:
org_id: :ORG_ID
15 changes: 15 additions & 0 deletions mmv1/templates/terraform/examples/tag_value_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "google_tags_tag_key" "key" {
provider = google-beta

parent = "organizations/<%= ctx[:test_env_vars]['org_id'] %>"
short_name = "keyname"
description = "For a certain set of resources."
}

resource "google_tags_tag_value" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta

parent = "tagKeys/${google_tags_tag_key.key.name}"
short_name = "<%= ctx[:vars]['short_name'] %>"
description = "For <%= ctx[:vars]['short_name'] %> resources.""
}
159 changes: 0 additions & 159 deletions mmv1/third_party/terraform/tests/resource_tags_tag_key_test.go.erb

This file was deleted.

Loading

0 comments on commit b029983

Please sign in to comment.