-
Notifications
You must be signed in to change notification settings - Fork 207
refactor: Adds invalid update error for delete_on_create_timeout for sdkv2 #3810
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
base: master
Are you sure you want to change the base?
refactor: Adds invalid update error for delete_on_create_timeout for sdkv2 #3810
Conversation
…teOnCreateTimeoutInvalidUpdate
…eateTimeoutInvalidUpdate and its tests + add test step to network peering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds validation to prevent updates to the delete_on_create_timeout attribute in SDKv2 resources (online archive and network peering). The attribute should only be set during resource creation and cannot be modified afterward.
Key changes:
- Implements
DeleteOnCreateTimeoutInvalidUpdatefunction to validate thatdelete_on_create_timeoutcannot be updated after creation - Adds validation logic to the
resourceUpdatefunctions for both online archive and network peering resources - Includes comprehensive test coverage for the new validation behavior
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/common/cleanup/handle_timeout.go | Adds new validation function and error message constant for invalid delete_on_create_timeout updates |
| internal/common/cleanup/handle_timeout_test.go | Adds comprehensive unit tests for the new validation function using mock resources |
| internal/service/onlinearchive/resource.go | Integrates validation check in the update function to prevent invalid attribute changes |
| internal/service/networkpeering/resource.go | Integrates validation check in the update function to prevent invalid attribute changes |
| internal/service/networkpeering/resource_test.go | Adds integration test case to verify the validation error is properly returned and updates import state verification |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const ( | ||
| CleanupWarning = "Failed to create resource. Will run cleanup due to the operation timing out" | ||
| CleanupWarning = "Failed to create resource. Will run cleanup due to the operation timing out" | ||
| DeleteOnCreateTimeoutInvalidErrorMessage = "delete_on_create_timeout cannot be updated or set after import, remove it from the configuration" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: why are we erroring only after it's changed in import but yes on creation?
| // DeleteOnCreateTimeoutInvalidUpdate returns an error if the `delete_on_create_timeout` attribute has been updated to true/false | ||
| // This use case differs slightly from the behavior of TPF customplanmodifier.CreateOnlyBoolWithDefault: | ||
| // - from a given value (true/false) --> `null`. | ||
| // This TPF implementation keeps the state value (UseStateForUnknown behavior). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // This TPF implementation keeps the state value (UseStateForUnknown behavior). | |
| // While the TPF implementation keeps the state value (UseStateForUnknown behavior), |
| // This use case differs slightly from the behavior of TPF customplanmodifier.CreateOnlyBoolWithDefault: | ||
| // - from a given value (true/false) --> `null`. | ||
| // This TPF implementation keeps the state value (UseStateForUnknown behavior). | ||
| // This will set the state value to null (Optional-only attribute). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // This will set the state value to null (Optional-only attribute). | |
| // The SDKv2 implementation will set the state value to null (Optional-only attribute). |
Description
Adds invalid update error for delete_on_create_timeout for sdkv2
Link to any related issue(s): CLOUDP-343190
Type of change:
Required Checklist:
Further comments