Skip to content

Commit

Permalink
Address feedback in review (mostly minor cleanups).
Browse files Browse the repository at this point in the history
  • Loading branch information
pcostell committed May 3, 2023
1 parent 20bdf6c commit 83b6d9c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
9 changes: 7 additions & 2 deletions mmv1/products/firestore/Field.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,18 @@ properties:
`projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/fields/{{field}}`
- !ruby/object:Api::Type::NestedObject
name: indexConfig
description: |
The single field index configuration for this field.
Creating an index configuration for this field will override any inherited configuration with the
indexes specified. Configuring the index configuration with an empty block disables all indexes on
the field.
send_empty_value: true
custom_expand: templates/terraform/custom_expand/firestore_field_index_config.go.erb
custom_flatten: templates/terraform/custom_flatten/firestore_field_index_config.go.erb
properties:
- !ruby/object:Api::Type::Array
name: indexes
description: The indexes
description: The indexes to configure on the field. Order or array contains must be specified.
is_set: true
item_type: !ruby/object:Api::Type::NestedObject
properties:
Expand All @@ -125,7 +130,7 @@ properties:
- !ruby/object:Api::Type::Enum
name: 'order'
description: |
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=.
Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=, !=.
Only one of `order` and `arrayConfig` can be specified.
values:
- :ASCENDING
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Firestore fields are not deletable. We consider the field deleted if:
// 1) the index configuration has no overrides and matches the ancestor configuration.package custom_check_destroy
// 1) the index configuration has no overrides and matches the ancestor configuration.
// 2) the ttl configuration is unset.

config := GoogleProviderConfig(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d
}

if indexConfig["indexes"] == nil {
// No indexes, return a existing, but empty index config.
// No indexes, return an existing, but empty index config.
return [1]interface{}{nil}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if err := ParseImportId([]string{"(?P<name>.+)"}, d, config); err != nil {
// Re-populate split fields from the name.
re := regexp.MustCompile("^projects/([^/]+)/databases/([^/]+)/collectionGroups/([^/]+)/fields/(.+)$")
match := re.FindStringSubmatch(d.Get("name").(string))
if len(match) > 0{
if len(match) > 0 {
if err := d.Set("project", match[1]); err != nil {
return nil, fmt.Errorf("Error setting project: %s", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resource "google_firestore_field" "<%= ctx[:primary_resource_id] %>" {
collection = "chatrooms_%{random_suffix}"
field = "timestamp"

// Disable all single field indexes for the timestamp property.
index_config {}
ttl_config {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ resource "google_firestore_field" "%{resource_name}" {
order = "ASCENDING"
query_scope = "COLLECTION_GROUP"
}
indexes {
array_config = "CONTAINS"
}
indexes {
array_config = "CONTAINS"
}
indexes {
order = "DESCENDING"
query_scope = "COLLECTION_GROUP"
Expand Down

0 comments on commit 83b6d9c

Please sign in to comment.