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

add send_secondary_ip_range_if_empty #7961

Conversation

modular-magician
Copy link
Collaborator

part of hashicorp/terraform-provider-google#12824 and hashicorp/terraform-provider-google#17881

adds a virtual field to replace the need to set secondary_ip_range = [] to remove secondary_ip_range explicitly. The virtual field in combination with GetRawConfig().GetAttr("secondary_ip_range") can let us detect when the user has intent to set to an empty list vs intending to let the backend manage the field.

Normally, when removing an Optional+Computed field from config, Terraform will not produce a diff. The sendSecondaryIpRangeIfEmptyDiff checks if the new flag is set and then compares the config value with the state value using GetRawConfig() and GetOk respectively.

The actual update call is handled in a post_update custom code block.

This logic works with and without SchemaConfigModeAttr, allowing an upgrade path in 5.x before removing SchemaConfigModeAttr from secondary_ip_range in 6.0

Release Note Template for Downstream PRs (will be copied)

compute: setting `google_compute_subnetwork.secondary_ip_range = []` to explicitly set a list of empty objects is deprecated and will produce an error in the upcoming major release. Use `send_secondary_ip_range_if_empty` while removing `secondary_ip_range` from config instead.
compute: added `send_secondary_ip_range_if_empty` to `google_compute_subnetwork`

Derived from GoogleCloudPlatform/magic-modules#11410

Co-authored-by: Riley Karson <rileykarson@google.com>

[upstream:4472fffc4067e62b24edb37e22f4fe61dfcc555c]

Signed-off-by: Modular Magician <magic-modules@google.com>
@modular-magician modular-magician merged commit bff22d1 into hashicorp:main Aug 13, 2024
4 checks passed
@modular-magician modular-magician deleted the downstream-pr-4472fffc4067e62b24edb37e22f4fe61dfcc555c branch November 16, 2024 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant