Skip to content

Conversation

yellow-shine
Copy link
Collaborator

@yellow-shine yellow-shine commented Aug 28, 2025

This pull request introduces logic to validate and restrict changes to the plan field for clusters, ensuring that only plan upgrades (not downgrades) are permitted. It also adds comprehensive tests to verify this behavior and updates test utilities accordingly.

Plan change validation and enforcement:

  • Added getPlanRank and validatePlanUpgrade helper functions in cluster_resource.go to determine plan hierarchy and prevent downgrades, allowing only plan upgrades. (internal/cluster/cluster_resource.go internal/cluster/cluster_resource.goR427-R463)
  • Updated the Update method in ClusterResource to use the new validation logic when the plan changes, returning an error if a downgrade is attempted. (internal/cluster/cluster_resource.go internal/cluster/cluster_resource.goR491-R502)
  • Added isClusterPlanChanged method to ClusterResourceModel to detect plan changes. (internal/cluster/model.go internal/cluster/model.goR71-R74)

Testing enhancements:

  • Added two new acceptance tests: one to verify successful plan upgrades and another to ensure downgrades are prevented and return appropriate errors. (internal/cluster/cluster_resource_test.go internal/cluster/cluster_resource_test.goR325-R453)
  • Updated the main test runner to include the new plan change tests. (internal/cluster/cluster_resource_test.go internal/cluster/cluster_resource_test.goR20-R24)
  • Updated ImportStateVerifyIgnore lists in relevant tests to include the plan field, preventing false negatives during import state verification. (internal/cluster/cluster_resource_test.go [1] [2] [3]

Test utility import:

@yellow-shine yellow-shine changed the title chore: no operation when plan is upgrade chore: no operation when plan is upgraded Aug 28, 2025
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.

1 participant