cloudflare-go
cloudflare-go copied to clipboard
UpdateLogpushJobParams: Make it possible to remove logpull_options on update
Description
For reference: #1709
Make it possible to remove the logpull_options on update. I think this is still an issue with the Cloudflare API: I would expect a PUT to overwrite the existing resource, not only change the specified values.
Before:
PUT request (TF_LOG=trace output):
PUT /client/v4/zones/[redacted]/logpush/jobs/[redacted] HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform-provider-cloudflare/dev terraform-plugin-sdk/2.32.0 terraform/1.7.5
Content-Type: application/json
Body: {"dataset":"http_requests","enabled":false,"name":"example","output_options":{"field_names":[],"output_type":"ndjson","record_prefix":"{","record_suffix":"}","field_delimiter":",","timestamp_format":"unixnano","sample_rate":1,"CVE-2021-44228":false},"destination_conf":"[redacted]","frequency":"high"}
With this change:
PUT request (TF_LOG=trace output):
PUT /client/v4/zones/[redacted]/logpush/jobs/[redacted] HTTP/1.1
Host: api.cloudflare.com
User-Agent: terraform-provider-cloudflare/dev terraform-plugin-sdk/2.32.0 terraform/1.7.5
Body: {"dataset":"http_requests","enabled":false,"name":"example","logpull_options":"","output_options":{"field_names":[],"output_type":"ndjson","record_prefix":"{","record_suffix":"}","field_delimiter":",","timestamp_format":"unixnano","sample_rate":1,"CVE-2021-44228":false},"destination_conf":"[redacted]","frequency":"high"}
Output of the second terraform plan
No changes. Your infrastructure matches the configuration.
Types of changes
What sort of change does your code introduce/modify?
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] This change is using publicly documented in cloudflare/api-schemas and relies on stable APIs.
changelog detected :white_check_mark:
we shouldn't be sending empty strings to the API in order to remove values when using PUT given it should represent the final state of the resource. the omitempty here is the correct way of handling it so we i can't accept the PR as is.
let me check with the internal team as to which behaviour we are expecting here.
Thanks Jacob! Yeah, I think it would be better to solve this right at the API level. Just let me know in case further details are needed.
@jacobbednarz any update on this getting resolved upstream in the API ?
no further updates at this point. the team have it in their backlog to investigate and look at a fix to maintain compatibility.
the output_options takes precedence over logput_options though so you should be fine defining the newer version and it taking effect.
We've recently opened a support ticket regarding this, as a workaround we keep logpull_options = "" after migrating to output_options in our TF definitions until the API gets fixed.
We've recently opened a support ticket regarding this, as a workaround we keep
logpull_options = ""after migrating tooutput_optionsin our TF definitions until the API gets fixed.
You can also ignore that field, after setting it to "", so that it doesn't show up in plan and apply output, using the lifecycle field:
lifecycle {
ignore_changes = [
logpull_options,
]
}