-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: Adding Route Aggregation Rule and Connection Route Aggregation Data Sources and Resources #860
feat: Adding Route Aggregation Rule and Connection Route Aggregation Data Sources and Resources #860
Conversation
srushti-patl
commented
Feb 18, 2025
- fabric_route_aggregation_rule Data Sources and Resource added
- fabric_route_aggregation_rules Data Sources and Resource added
- Documentation and Acceptance Tests added for above resources and data sources
…Data Sources and Resources
507dcc4
to
5151372
Compare
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.
Changes requested
} | ||
|
||
// Handle specific API error messages | ||
var apiErr *fabricv4.GenericOpenAPIError |
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 error handling likely is redundant and not necessary. There also should be an easier way to get the errorCode back from the err.
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.
See
terraform-provider-equinix/equinix/resource_fabric_cloud_router.go
Lines 564 to 575 in 4b61c51
_, err := client.CloudRoutersApi.DeleteCloudRouterByUuid(ctx, d.Id()).Execute() | |
if err != nil { | |
if genericError, ok := err.(*fabricv4.GenericOpenAPIError); ok { | |
if fabricErrs, ok := genericError.Model().([]fabricv4.Error); ok { | |
// EQ-3040055 = There is an existing update in REQUESTED state | |
if equinix_errors.HasErrorCode(fabricErrs, "EQ-3040055") { | |
return diags | |
} | |
} | |
} | |
return diag.FromErr(equinix_errors.FormatFabricError(err)) | |
} |
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.
Should still double check for the necessity of this though. It doesn't seem like it should be needed.
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.
We need to fetch the errorCode and I have updated the method based on the above example
|
||
newPrefix, oldPrefix := plan.Prefix.ValueString(), state.Prefix.ValueString() | ||
|
||
if newPrefix == oldPrefix { |
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.
Our lack of plan modification here is going to cause this warning to be triggered every time this happens. Prepare for an update if issues arise.
createWaiter := getCreateUpdateWaiter(ctx, client, routeAggregationID, routeAggregationRule.GetUuid(), createTimeout) | ||
routeAggregationRuleChecked, err := createWaiter.WaitForStateContext(ctx) | ||
if err != nil { | ||
resp.Diagnostics.AddError(fmt.Sprintf("Failed creating Route Aggregation %s", routeAggregationRule.GetUuid()), err.Error()) |
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.
nit: rule
missing from error message
routeAggregationId := rs.Primary.Attributes["route_aggregation_id"] | ||
connectionId := rs.Primary.Attributes["connection_id"] | ||
|
||
if connectionRouteAggregation, _, err := client.RouteAggregationsApi.GetConnectionRouteAggregationByUuid(ctx, routeAggregationId, connectionId).Execute(); err == nil && |
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 pattern is better for a test check delete method.
// deletedMarker is a terraform-provider-only value that is used by the waiter | ||
// to indicate that the resource appears to be deleted successfully based on | ||
// status code or specific error code | ||
deletedMarker := "tf-marker-for-deleted-route-aggregation-rule" |
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.
nit: should be connection route aggregation string instead
Update: true, | ||
Delete: true, | ||
}), | ||
"route_aggregation_id": schema.StringAttribute{ |
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.
If this changes it should force a new resource. Same with connection_id
Description: "UUID of the Route Aggregation to apply this Rule to", | ||
Required: true, | ||
}, | ||
"connection_id": schema.StringAttribute{ |
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.
Should force a new resource if updated
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.
Just need to update the delete checks and then it's good to go 👍
deletedMarker, | ||
}, | ||
Refresh: func() (interface{}, string, error) { | ||
routeAggregationRule, resp, err := client.RouteAggregationRulesApi.GetRouteAggregationRuleByUuid(ctx, routeAggregationID, id).Execute() |
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.
We don't need resp here.
Refresh: func() (interface{}, string, error) { | ||
routeAggregationRule, resp, err := client.RouteAggregationRulesApi.GetRouteAggregationRuleByUuid(ctx, routeAggregationID, id).Execute() | ||
if err != nil { | ||
if resp != nil { |
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.
Can remove resp check. Also, you should add the check for 404 status check back into this if statement and the one for resource_test.go. The simplification was about the conversion to GenericOpenAPIError and not about the status codes. Those were good and important checks.
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.
LGTM. Ship it.
This PR is included in version 3.3.0 🎉 |