feat: support for nested write-only arguments + write-only arguments for google_monitoring_notification_channel#15538
Conversation
fd2c99f to
0d5ec68
Compare
|
When I do a local build, the ExactlyOneOf: []string{"sensitive_labels.0.auth_token", "sensitive_labels.0.password", "sensitive_labels.0.service_key", "sensitive_labels.0.auth_token_wo", "sensitive_labels.0.password_wo", "sensitive_labels.0.service_key_wo"},Let's discuss this feature further on this draft, I would like to validate with you if this aligns a bit with the original idea you had in mind for this feature. |
This comment was marked as outdated.
This comment was marked as outdated.
|
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. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
melinath
left a comment
There was a problem hiding this comment.
yeah this looks like what I was imagining. It looks like the downstream generation worked fine / came out as expected, even for the case where multiple write only fields are added to the same constraint group 👍
Should be good to go once we have tests for the new fields.
Great, I will try to add these tests today! Do we also want to add some documentation about this logic somewhere? At least I can imagine without context reading this code for the first time might be a bit confusing, e.g. "why the ... do they apply this pointer logic?". On the other hand it is also not that big of a change. EDIT: I will see what I can do to make it work. I think it is a unique case in general, because this use-case uses a custom encoder and |
…to nested fields and `url_param_only: true`)
03b0d07 to
c93f109
Compare
I think I managed to address most of this in 8a48fca and ac2487d, unfortunately it is still quite some custom code, but that is also because Tests on latest commit: ➜ make testacc TEST=./google/services/monitoring TESTARGS='-run=TestAccMonitoringNotificationChannel_'
sh -c "'/Users/ramon/go/src/github.com/hashicorp/terraform-provider-google/scripts/gofmtcheck.sh'"
==> Checking that code complies with gofmt requirements...
go vet
TF_ACC_REFRESH_AFTER_APPLY=1 TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google/services/monitoring -v -run=TestAccMonitoringNotificationChannel_ -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"
=== RUN TestAccMonitoringNotificationChannel_notificationChannelBasicExample
=== PAUSE TestAccMonitoringNotificationChannel_notificationChannelBasicExample
=== RUN TestAccMonitoringNotificationChannel_update
=== PAUSE TestAccMonitoringNotificationChannel_update
=== RUN TestAccMonitoringNotificationChannel_updateLabels_slack
resource_monitoring_notification_channel_test.go:57:
--- SKIP: TestAccMonitoringNotificationChannel_updateLabels_slack (0.00s)
=== RUN TestAccMonitoringNotificationChannel_updateLabels
=== PAUSE TestAccMonitoringNotificationChannel_updateLabels
=== RUN TestAccMonitoringNotificationChannel_updateSensitiveLabels_slack
resource_monitoring_notification_channel_test.go:107:
--- SKIP: TestAccMonitoringNotificationChannel_updateSensitiveLabels_slack (0.00s)
=== RUN TestAccMonitoringNotificationChannel_updateSensitiveLabels
=== PAUSE TestAccMonitoringNotificationChannel_updateSensitiveLabels
=== RUN TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo
=== PAUSE TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo
=== RUN TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo_slack
resource_monitoring_notification_channel_test.go:216:
--- SKIP: TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo_slack (0.00s)
=== CONT TestAccMonitoringNotificationChannel_notificationChannelBasicExample
=== CONT TestAccMonitoringNotificationChannel_updateSensitiveLabels
=== CONT TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo
=== CONT TestAccMonitoringNotificationChannel_updateLabels
=== CONT TestAccMonitoringNotificationChannel_update
--- PASS: TestAccMonitoringNotificationChannel_notificationChannelBasicExample (6.64s)
--- PASS: TestAccMonitoringNotificationChannel_updateLabels (8.15s)
--- PASS: TestAccMonitoringNotificationChannel_updateSensitiveLabels (10.79s)
--- PASS: TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo (14.25s)
--- PASS: TestAccMonitoringNotificationChannel_update (14.40s)
PASS
ok github.com/hashicorp/terraform-provider-google/google/services/monitoring 15.182sI only think the documentation for write-only arguments is still not generated fully correct. I think it makes sense to wait a little bit with that before #15385 is merged? We most likely need to add some changes to this file to enable support for the nested write-only docs: https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/templates/terraform/nested_property_documentation.html.markdown.tmpl. |
3b58471 to
0a65d69
Compare
|
Applied the feedback, and reran tests locally: ❯ make testacc TEST=./google/services/monitoring TESTARGS='-run=TestAccMonitoringNotificationChannel_' ─╯
sh -c "'/Users/ramon/go/src/github.com/hashicorp/terraform-provider-google/scripts/gofmtcheck.sh'"
==> Checking that code complies with gofmt requirements...
go vet
TF_ACC_REFRESH_AFTER_APPLY=1 TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google/services/monitoring -v -run=TestAccMonitoringNotificationChannel_ -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"
=== RUN TestAccMonitoringNotificationChannel_notificationChannelBasicExample
=== PAUSE TestAccMonitoringNotificationChannel_notificationChannelBasicExample
=== RUN TestAccMonitoringNotificationChannel_update
=== PAUSE TestAccMonitoringNotificationChannel_update
=== RUN TestAccMonitoringNotificationChannel_updateLabels_slack
resource_monitoring_notification_channel_test.go:57:
--- SKIP: TestAccMonitoringNotificationChannel_updateLabels_slack (0.00s)
=== RUN TestAccMonitoringNotificationChannel_updateLabels
=== PAUSE TestAccMonitoringNotificationChannel_updateLabels
=== RUN TestAccMonitoringNotificationChannel_updateSensitiveLabels_slack
resource_monitoring_notification_channel_test.go:107:
--- SKIP: TestAccMonitoringNotificationChannel_updateSensitiveLabels_slack (0.00s)
=== RUN TestAccMonitoringNotificationChannel_updateSensitiveLabels
=== PAUSE TestAccMonitoringNotificationChannel_updateSensitiveLabels
=== RUN TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo
=== PAUSE TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo
=== RUN TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo_slack
resource_monitoring_notification_channel_test.go:216:
--- SKIP: TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo_slack (0.00s)
=== CONT TestAccMonitoringNotificationChannel_notificationChannelBasicExample
=== CONT TestAccMonitoringNotificationChannel_updateSensitiveLabels
=== CONT TestAccMonitoringNotificationChannel_updateLabels
=== CONT TestAccMonitoringNotificationChannel_update
=== CONT TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo
--- PASS: TestAccMonitoringNotificationChannel_notificationChannelBasicExample (8.05s)
--- PASS: TestAccMonitoringNotificationChannel_updateLabels (9.51s)
--- PASS: TestAccMonitoringNotificationChannel_updateSensitiveLabels (12.35s)
--- PASS: TestAccMonitoringNotificationChannel_updateSensitiveLabelsWo (15.97s)
--- PASS: TestAccMonitoringNotificationChannel_update (16.28s)
PASS
ok github.com/hashicorp/terraform-provider-google/google/services/monitoring 17.084s
Thanks for reviewing! It is a bit of an complicated case, because essentially 3 client-side fields write to the same API field. I have been confused quite a couple of times during this implementation, but I feel like the decoder logic is still needed for sensitiveLabels. My main goal was to add the support for nested write-only arguments, because I think that is the final thing blocking to replace all the At least I think it would be nice if we can have these |
|
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.
|
Non-exercised tests🔴 Tests were added that are skipped in VCR:
Tests analyticsTotal tests: 5988 Click here to see the affected service packages
Action takenFound 2 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. 🟢 All tests passed! |
|
Failures look unrelated. |
I just opened hashicorp/terraform-provider-google#25965 yesterday to track the work to convert write_only_legacy fields. I think we'll still need to make some breaking changes in the major release, but I think this PR is also necessary. |
c387cf0
…for `google_monitoring_notification_channel` (GoogleCloudPlatform#15538) Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
…for `google_monitoring_notification_channel` (GoogleCloudPlatform#15538) Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
…for `google_monitoring_notification_channel` (GoogleCloudPlatform#15538) Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
…for `google_monitoring_notification_channel` (GoogleCloudPlatform#15538) Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
…for `google_monitoring_notification_channel` (GoogleCloudPlatform#15538) Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
…for `google_monitoring_notification_channel` (GoogleCloudPlatform#15538) Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
…for `google_monitoring_notification_channel` (GoogleCloudPlatform#15538) Co-authored-by: Stephen Lewis (Burrows) <stephen.r.burrows@gmail.com>
This PR introduces support for nested write-only fields and adds write-only arguments for the
google_monitoring_notification_channelresource.Closing: hashicorp/terraform-provider-google#21855
Release Note Template for Downstream PRs (will be copied)
See Write release notes for guidance.