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

azurerm_cosmosdb_sql_container - support for indexing_policy #8461

Merged
merged 5 commits into from
Sep 22, 2020
Merged

azurerm_cosmosdb_sql_container - support for indexing_policy #8461

merged 5 commits into from
Sep 22, 2020

Conversation

marc-sensenich
Copy link
Contributor

@marc-sensenich marc-sensenich commented Sep 14, 2020

Allows for the setting of indexing policies on Cosmos DB SQL Containers. Completes the work from #5546.

Test status as of e06ca00

--- PASS: TestAccAzureRMCosmosDbSqlContainer_basic (1600.44s)
--- PASS: TestAccAzureRMCosmosDbSqlContainer_complete (1713.66s)
--- PASS: TestAccAzureRMCosmosDbSqlContainer_update (1775.82s)
--- PASS: TestAccAzureRMCosmosDbSqlContainer_indexing_policy (1821.13s)
--- PASS: TestAccAzureRMCosmosDbSqlContainer_autoscale (1940.55s)

@@ -0,0 +1,122 @@
package common
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these to common as the Gremlin Graph resource could migrate over to these in the future

Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"path": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only did path here as the indexes field was accepted by the REST API, but did not return the indexes field in response.


func CosmosDbIndexingPolicySchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a suggested pattern for validating TypeList that does cross field validation? In the indexing policy case there are the validations of

  • included_path and excluded_path can't be set when the indexing_mode is None
  • One of included_path or excluded_path must contain the path /*

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best solution is to validate it in create and return an error at that point if it fails

@favoretti

This comment has been minimized.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @marc-sensenich - overall looks good to me! if we can add that validation to the create/update function this should be good to merge 🙁


func CosmosDbIndexingPolicySchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best solution is to validate it in create and return an error at that point if it fails

@marc-sensenich
Copy link
Contributor Author

marc-sensenich commented Sep 20, 2020

@katbyte validation on create and update added in e06ca00

@ghost ghost removed the waiting-response label Sep 20, 2020
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @marc-sensenich - running the tests for the latest changes however and i'm getting:

Test Failed

------- Stdout: -------
=== RUN   TestValidateAzureRmCosmosDbIndexingPolicy
    TestValidateAzureRmCosmosDbIndexingPolicy: indexing_policy_test.go:198: Expected an error but didn't get one for "included_path and excluded_path with /*"
--- FAIL: TestValidateAzureRmCosmosDbIndexingPolicy (0.00s)

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NM @marc-sensenich, ran it again and it passed! thanks for the changes 🙂

@katbyte katbyte changed the title Add indexing policy to Cosmos DB SQL Container azurerm_cosmosdb_sql_container - support for indexing_policy Sep 22, 2020
@katbyte katbyte merged commit 915adb5 into hashicorp:master Sep 22, 2020
katbyte added a commit that referenced this pull request Sep 22, 2020
@ghost
Copy link

ghost commented Oct 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants