Add nexthop parameter to cloudstack_static_route resource#284
Open
bhouse-nexthop wants to merge 7 commits intoapache:mainfrom
Open
Add nexthop parameter to cloudstack_static_route resource#284bhouse-nexthop wants to merge 7 commits intoapache:mainfrom
bhouse-nexthop wants to merge 7 commits intoapache:mainfrom
Conversation
This change adds support for the nexthop parameter in static routes, which allows VPC-based routing without requiring a private gateway. Resource Changes: - Add nexthop and vpc_id optional parameters to schema - nexthop is mutually exclusive with gateway_id - When using nexthop, vpc_id is required - When using gateway_id, nexthop and vpc_id are not allowed - Update resource creation logic to support both routing methods: - Private Gateway routing (gateway_id) - VPC direct routing (nexthop + vpc_id) - Update Read function to maintain plan stability for both modes Test Coverage: - Add comprehensive test coverage for both routing methods - Add testAccPreCheckStaticRouteNexthop helper to check CloudStack version - Automatically skip nexthop tests on CloudStack versions < 4.22.0 - Version check uses CloudStack capabilities API - Tests are skipped (not failed) on older versions for backward compatibility - All acceptance tests passing (2/2) Documentation: - Update documentation with examples for both routing methods - Document mutual exclusivity requirements - Note CloudStack 4.22+ requirement for nexthop support CI/CD: - Add CloudStack 4.22.0.0 to acceptance test matrix - Ensures tests run on both old and new CloudStack versions
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for VPC direct static routing by introducing a nexthop + vpc_id mode in cloudstack_static_route, alongside the existing private gateway (gateway_id) mode.
Changes:
- Extend
cloudstack_static_routeschema and CRUD to supportnexthopandvpc_idwith mutual exclusivity vsgateway_id. - Add acceptance coverage for the new routing mode plus a CloudStack-version precheck helper.
- Update docs/examples and expand the acceptance test matrix to include CloudStack
4.22.0.0.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
cloudstack/resource_cloudstack_static_route.go |
Adds nexthop + vpc_id arguments and wires them into Create/Read. |
cloudstack/resource_cloudstack_static_route_test.go |
Adds acceptance test exercising the nexthop mode. |
cloudstack/provider_test.go |
Adds a precheck helper that skips nexthop tests on older CloudStack versions. |
website/docs/r/static_route.html.markdown |
Documents both routing methods and their mutual exclusivity. |
.github/workflows/acceptance.yml |
Adds CloudStack 4.22.0.0 to the acceptance test matrix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
@bhouse-nexthop Can you check Copilot's comments? |
- Add parseCloudStackVersion() to parse version strings into numeric values - Add getCloudStackVersion() to retrieve version from API - Add requireMinimumCloudStackVersion() for easy version checking in tests - Refactor testAccPreCheckStaticRouteNexthop() to use new helpers - These helpers can now be reused by other tests that need version checks
Document that the nexthop parameter requires CloudStack 4.22.0+
Add TestCheckResourceAttrPair to verify that vpc_id is properly persisted in state and matches the created VPC resource
Add verifyStaticRouteParams() to validate that either gateway_id or (nexthop + vpc_id) is provided before calling the API. This provides clearer error messages at the Terraform level rather than letting invalid configurations fail at the CloudStack API level.
The provider Meta() is not available during PreCheck, so we need to create a CloudStack client directly using the environment variables.
Add test cases to verify that the parameter validation logic works correctly: - Test missing both gateway_id and nexthop - Test nexthop without vpc_id - Test vpc_id without nexthop These tests verify that the schema-level RequiredWith validation and the custom verifyStaticRouteParams function work as expected.
Collaborator
Author
|
@vishesh92 all comments addressed, please re-request Copilot review. |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds support for the nexthop parameter in static routes, which allows VPC-based routing without requiring a private gateway id.
Resource Changes:
Test Coverage:
Documentation:
CI/CD: