Skip to content

feat: Adding Route Aggregation Policy Resource and Data Source#850

Merged
srushti-patl merged 11 commits into
mainfrom
CXF-106515-Route-Aggregation-Policy-Resource-DataSource
Feb 25, 2025
Merged

feat: Adding Route Aggregation Policy Resource and Data Source#850
srushti-patl merged 11 commits into
mainfrom
CXF-106515-Route-Aggregation-Policy-Resource-DataSource

Conversation

@srushti-patl
Copy link
Copy Markdown
Contributor

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

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 49.93954% with 414 lines in your changes missing coverage. Please review.

Project coverage is 65.09%. Comparing base (291f58a) to head (4de8b90).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
...rnal/resources/fabric/routeaggregation/resource.go 18.18% 159 Missing and 3 partials ⚠️
...ic/routeaggregation/datasource_all_aggregations.go 10.41% 86 Missing ⚠️
...ternal/resources/fabric/routeaggregation/models.go 0.00% 86 Missing ⚠️
...ernal/resources/fabric/routeaggregation/sweeper.go 0.00% 58 Missing ⚠️
...uteaggregation/datasource_by_routeAggregationId.go 31.25% 22 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@thogarty thogarty added the area/resources/fabric Issues related to Fabric and ECX APIs label Feb 20, 2025
Copy link
Copy Markdown
Contributor

@thogarty thogarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First review completed. See comments.

continue
}

_, resp, err := client.RouteAggregationsApi.GetRouteAggregationByUuid(ctx, rs.Primary.ID).Execute()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

@srushti-patl srushti-patl Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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},
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could keep it on the same line

return diags
}

func parseRouteAggregation(ctx context.Context, routeAggregation *fabricv4.RouteAggregationsData,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as datasources_test comment.

Comment thread docs/index.md Outdated
---

# Equinix Provider
# terraform-provider-equinix Provider
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the description in the resource schema that would appear as the header in this doc.

Copy link
Copy Markdown
Contributor

@thogarty thogarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested.

return
}

if diags.HasError() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole statement needed to be removed. Not just the line before it.

string(fabricv4.ROUTEAGGREGATIONSTATE_DEPROVISIONING),
},
Target: []string{
string(fabricv4.ROUTEAGGREGATIONSTATE_DEPROVISIONED),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to append to resp.Diagnostics before returning.

Copy link
Copy Markdown
Contributor

@thogarty thogarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Ship it.

@srushti-patl srushti-patl merged commit 90a8e38 into main Feb 25, 2025
@srushti-patl srushti-patl deleted the CXF-106515-Route-Aggregation-Policy-Resource-DataSource branch February 25, 2025 01:13
@github-actions
Copy link
Copy Markdown

This PR is included in version 3.3.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/resources/fabric Issues related to Fabric and ECX APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants