Adding Terraform support for Model Armor#14349
Adding Terraform support for Model Armor#14349melinath merged 6 commits intoGoogleCloudPlatform:mainfrom srichaitanyab:main
Conversation
|
Hello! I am a robot. Tests will require approval from a repository maintainer to run. Googlers: For automatic test runs see go/terraform-auto-test-runs. @melinath, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
Missing service labelsThe following new resources do not have corresponding service labels:
If you believe this detection to be incorrect please raise the concern with your reviewer. Googlers: This error is safe to ignore once you've completed go/fix-missing-service-labels. |
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
Missing service labelsThe following new resources do not have corresponding service labels:
If you believe this detection to be incorrect please raise the concern with your reviewer. Googlers: This error is safe to ignore once you've completed go/fix-missing-service-labels. |
Tests analyticsTotal tests: 5319 Click here to see the affected service packages
Found 37 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
Tests analyticsTotal tests: 5319 Click here to see the affected service packages
Found 36 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made. Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer. 🔴 Tests failed during RECORDING mode: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made. Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer. 🔴 Tests failed during RECORDING mode: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
|
Hi, the failing tests are actually not from my project or changes. Hence, could you guide me on any changes that I might have to make about them, if any? |
|
you don't need to make changes to failing tests outside of ModelArmor since they're not related to your change; we just can't know that automatically because adding a new service has to touch global files. |
melinath
left a comment
There was a problem hiding this comment.
overall this looks pretty good; I need to take a closer pass before approving though.
| step1Checks := func(ctx map[string]interface{}) []resource.TestCheckFunc { | ||
| return []resource.TestCheckFunc{ | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "labels.test-label", ctx["label_test_label"].(string)), | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.0.advanced_config.0.inspect_template", ctx["filter_config_sdp_settings_advanced_config_inspect_template"].(string)), | ||
| } | ||
| } | ||
|
|
||
| step2Checks := func(ctx map[string]interface{}) []resource.TestCheckFunc { | ||
| checks := []resource.TestCheckFunc{ | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "labels.test-label", ctx["label_test_label"].(string)), | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.rai_settings.0.rai_filters.0.filter_type", ctx["filter_config_rai_settings_rai_filters_0_filter_type"].(string)), | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "template_metadata.0.log_sanitize_operations", "false"), | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.#", "1"), | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.0.basic_config.#", "1"), | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.0.basic_config.0.filter_enforcement", ctx["filter_config_sdp_settings_basic_config_filter_enforcement"].(string)), | ||
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.0.advanced_config.#", "0"), | ||
| } | ||
| return checks | ||
| } |
There was a problem hiding this comment.
| step1Checks := func(ctx map[string]interface{}) []resource.TestCheckFunc { | |
| return []resource.TestCheckFunc{ | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "labels.test-label", ctx["label_test_label"].(string)), | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.0.advanced_config.0.inspect_template", ctx["filter_config_sdp_settings_advanced_config_inspect_template"].(string)), | |
| } | |
| } | |
| step2Checks := func(ctx map[string]interface{}) []resource.TestCheckFunc { | |
| checks := []resource.TestCheckFunc{ | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "labels.test-label", ctx["label_test_label"].(string)), | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.rai_settings.0.rai_filters.0.filter_type", ctx["filter_config_rai_settings_rai_filters_0_filter_type"].(string)), | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "template_metadata.0.log_sanitize_operations", "false"), | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.#", "1"), | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.0.basic_config.#", "1"), | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.0.basic_config.0.filter_enforcement", ctx["filter_config_sdp_settings_basic_config_filter_enforcement"].(string)), | |
| resource.TestCheckResourceAttr("google_model_armor_template.test-resource", "filter_config.0.sdp_settings.0.advanced_config.#", "0"), | |
| } | |
| return checks | |
| } |
Generally speaking we don't rely on explicit attribute checks - instead, we use ImportStateVerify steps. For example: https://github.com/hashicorp/terraform-provider-google/blob/0ca0b4b187c09a36fe427f8cb5d3026c83a94910/google/services/osconfig/resource_os_config_patch_deployment_generated_test.go#L48-L53
This will check that the values on the resource are correct and also exercise the import logic.
| "template_metadata_enforcement_type": "INSPECT_AND_BLOCK", | ||
| } | ||
|
|
||
| const config_template = ` |
There was a problem hiding this comment.
Generally we recommend putting the config in a separate function, similar to https://github.com/hashicorp/terraform-provider-google/blob/0ca0b4b187c09a36fe427f8cb5d3026c83a94910/google/services/osconfig/resource_os_config_patch_deployment_generated_test.go#L46, but this doesn't seem to be causing problems with our test parsing logic so it may be fine.
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
Missing service labelsThe following new resources do not have corresponding service labels:
If you believe this detection to be incorrect please raise the concern with your reviewer. Googlers: This error is safe to ignore once you've completed go/fix-missing-service-labels. |
|
I've added the google_model_armor_* label to the proto, yet it still fails. Please look into this and lmk about any further changes. |
Tests analyticsTotal tests: 5328 Click here to see the affected service packages
Found 33 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made. Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer. 🔴 Tests failed during RECORDING mode: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
melinath
left a comment
There was a problem hiding this comment.
Some minor changes but overall LGTM. Seems like all the fields are tested & the new tests are passing.
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
Missing service labelsThe following new resources do not have corresponding service labels:
If you believe this detection to be incorrect please raise the concern with your reviewer. Googlers: This error is safe to ignore once you've completed go/fix-missing-service-labels. |
|
Service labels will be fixed by #14399 |
Tests analyticsTotal tests: 5333 Click here to see the affected service packages
Found 28 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
Hi, could you please let me know about any other blocking issues?? If none, could you consider merging it? |
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made. Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer. 🔴 Tests failed during RECORDING mode: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
melinath
left a comment
There was a problem hiding this comment.
I was just waiting for the tests to finish running. Looks good; failures are unrelated.
1e00d9f
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
Release Note Template for Downstream PRs (will be copied)
See Write release notes for guidance.