feat: Adding Route Aggregation Policy Resource and Data Source#850
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #850 +/- ##
===========================================
+ Coverage 34.53% 65.09% +30.55%
===========================================
Files 192 199 +7
Lines 25223 26050 +827
===========================================
+ Hits 8711 16957 +8246
+ Misses 16365 8267 -8098
- Partials 147 826 +679 ☔ View full report in Codecov by Sentry. |
thogarty
left a comment
There was a problem hiding this comment.
First review completed. See comments.
| continue | ||
| } | ||
|
|
||
| _, resp, err := client.RouteAggregationsApi.GetRouteAggregationByUuid(ctx, rs.Primary.ID).Execute() |
There was a problem hiding this comment.
You're making two api calls in this method when 1 will do. You can check various responses separately with the return values from one call.
Also, did you verify that a 400 is going to be a success on deletion? I've put that in streaming because of a design decision that could be a defect. I'm curious if route aggreation has the same.
There was a problem hiding this comment.
Initially during the development, I had confirmed it with Qiong, 400 was a success criteria for Route Aggregation deletion.Recently they have updated it to 200, I have updated the code
| } | ||
|
|
||
| // Handle specific API error messages | ||
| var apiErr *fabricv4.GenericOpenAPIError |
There was a problem hiding this comment.
My intuition is telling me we have a better pattern for retrieving the API error code and doing a check. This seems very large for what it's achieving.
| return | ||
| } | ||
|
|
||
| resp.Diagnostics.Append(diags...) |
There was a problem hiding this comment.
This check doesn't seem to have any value. It's not checking any new diags values and is doing the same as the following statement. Can be removed.
| Op: "replace", | ||
| Path: "/name", | ||
| Value: map[string]interface{}{"": newName}, | ||
| }, |
There was a problem hiding this comment.
nit: could keep it on the same line
| return diags | ||
| } | ||
|
|
||
| func parseRouteAggregation(ctx context.Context, routeAggregation *fabricv4.RouteAggregationsData, |
There was a problem hiding this comment.
We're removing this extra function because it's not being used repeatedly in a way that is effective. See #844 (comment)
| resource.TestCheckResourceAttr("data.equinix_fabric_route_aggregations.data_ras", "pagination.limit", "2"), | ||
| resource.TestCheckResourceAttr("data.equinix_fabric_route_aggregations.data_ras", "pagination.offset", "1"), | ||
| ), | ||
| ExpectNonEmptyPlan: false, |
There was a problem hiding this comment.
This statement actually is already the default so it can be omitted. It's only when we set this value to true that we're giving the test permission to see changes post apply.
| resource.TestCheckResourceAttr("equinix_fabric_route_aggregation.test", "type", "BGP_IPv4_PREFIX_AGGREGATION"), | ||
| resource.TestCheckResourceAttr("equinix_fabric_route_aggregation.test", "description", "Test Route Aggregation"), | ||
| ), | ||
| ExpectNonEmptyPlan: false, |
There was a problem hiding this comment.
Same as datasources_test comment.
| --- | ||
|
|
||
| # Equinix Provider | ||
| # terraform-provider-equinix Provider |
There was a problem hiding this comment.
There's an issue with the make docs run here for some reason. This shouldn't be a change that occurs.
| --- | ||
|
|
||
| # equinix_fabric_route_aggregation (Resource) | ||
|
|
There was a problem hiding this comment.
Missing the description in the resource schema that would appear as the header in this doc.
| return | ||
| } | ||
|
|
||
| if diags.HasError() { |
There was a problem hiding this comment.
This whole statement needed to be removed. Not just the line before it.
| string(fabricv4.ROUTEAGGREGATIONSTATE_DEPROVISIONING), | ||
| }, | ||
| Target: []string{ | ||
| string(fabricv4.ROUTEAGGREGATIONSTATE_DEPROVISIONED), |
There was a problem hiding this comment.
deletedMarker was removed here during your update. Needs to be present.
| m.RouteAggregationID = types.StringValue(routeAggregation.GetUuid()) | ||
| m.ID = types.StringValue(routeAggregation.GetUuid()) | ||
|
|
||
| if routeAggregation != nil { |
There was a problem hiding this comment.
Redo models. Leverage struct embedding principles to leverage a single line parse statement.
| client := r.Meta.NewFabricClientForFramework(ctx, req.ProviderMeta) | ||
|
|
||
| createRequest, diags := buildCreateRequest(ctx, plan) | ||
| if diags.HasError() { |
There was a problem hiding this comment.
Needs to append to resp.Diagnostics before returning.
|
This PR is included in version 3.3.0 🎉 |
Added the following using Terraform Plugin Framework:
equinix_fabric_route_aggregation_ resource
equinix_fabric_route_aggregation_data source
equinix_fabric_route_aggregations_data source
Included automated testing and docs