Skip to content
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

refactor: fabric connection and fabric port schema updates #548

Merged
merged 14 commits into from
Feb 2, 2024

Conversation

thogarty
Copy link
Contributor

  • Consolidated+Migrated Fabric Connection Schema to Fabric Connection Resource
  • Refactored Common Schema Elements to internal Package
  • Consolidated+Migrated Fabric Port Schema to Fabric Port Resource
  • Updated Service Profile, Routing Protocol, and Cloud Router Schema to use Common elements
  • Updated Out of Date Documentation to match current changes
  • Moved mapping helpers to their corresponding resource + common mapping helpers to internal package

@codecov-commenter
Copy link

codecov-commenter commented Jan 31, 2024

Codecov Report

Attention: 467 lines in your changes are missing coverage. Please review.

Comparison is base (a60c71f) 44.71% compared to head (1ff8a47) 44.37%.
Report is 27 commits behind head on main.

Files Patch % Lines
...ternal/resources/metal/project_ssh_key/resource.go 0.00% 131 Missing ⚠️
internal/resources/metal/ssh_key/resource.go 0.00% 130 Missing ⚠️
...rnal/resources/metal/project_ssh_key/datasource.go 0.00% 61 Missing ⚠️
...nternal/resources/metal/ssh_key/resource_schema.go 0.00% 45 Missing ⚠️
internal/resources/metal/project_ssh_key/models.go 0.00% 20 Missing ⚠️
equinix/resource_fabric_port.go 95.00% 12 Missing and 6 partials ⚠️
internal/resources/metal/metal_connection/speed.go 0.00% 16 Missing ⚠️
...resources/metal/project_ssh_key/resource_schema.go 0.00% 10 Missing ⚠️
internal/resources/metal/ssh_key/models.go 0.00% 9 Missing ⚠️
equinix/fabric_mapping_helper.go 62.50% 6 Missing ⚠️
... and 5 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #548      +/-   ##
==========================================
- Coverage   44.71%   44.37%   -0.35%     
==========================================
  Files          98       98              
  Lines       19888    18804    -1084     
==========================================
- Hits         8893     8344     -549     
+ Misses      10961    10378     -583     
- Partials       34       82      +48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

srushti-patl
srushti-patl previously approved these changes Feb 1, 2024
Copy link
Contributor

@srushti-patl srushti-patl left a comment

Choose a reason for hiding this comment

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

LGTM!

@thogarty thogarty requested a review from a team February 1, 2024 00:49
@@ -25,15 +25,16 @@ data "equinix_fabric_cloud_router" "cloud_router_data_name" {

### Optional

- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project))
Copy link
Member

@displague displague Feb 1, 2024

Choose a reason for hiding this comment

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

This implies:

data "equinix_fabric_cloud_router" "cloud_router_data_name" {
  project {
     project_id = "<uuid_of_project>"
     # or href = "<href_of_project>"
  }
}

How does a FCR lookup by project work? Is there a one FCR resource per project limitation? Does the datasource error if there are more than one FCR in the selected project? Is that a reasonable launch filter that will need to be augmented with additional filters in the future (name, location, feature based?)

Looking a little closer, it appears that project is not used when looking up FCR resources, only the uuid is used.

Copy link
Member

@displague displague Feb 1, 2024

Choose a reason for hiding this comment

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

I think what is intended is that the datasource would have uuid required (which it is not) and project would be computed (as it is) but not optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch. Agree completely. Will update.

@@ -18,6 +19,574 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func FabricConnectionResourceSchema() map[string]*schema.Schema {
Copy link
Member

@displague displague Feb 1, 2024

Choose a reason for hiding this comment

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

This was previously a private in the package: createFabricConnectionResourceSchema. This (lowercase naming) is preferable since we don't want or expect outside Go packages to depend on this function. Removing exported functions at a later date is a breaking change.

In the future migration to internal/resources/fabric/connection/ (perhaps internal/services/fabric/connection/) the function could be exported and shared between other packages in the Terraform provider without including the function in the public signature of the github.com/equinix/terraform-provider-equinix/equinix package. That package will minimally expose the Provider (which Terraform dependent integrations like Pulumi and Crossplane have utilized at some point or another).

Copy link
Member

Choose a reason for hiding this comment

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

Removing exported functions at a later date is a breaking change

because this project was released at 1.0.0 in the past.

https://0ver.org/ 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy that. Heard and will fix here and take that review forward into further Provider changes.

"integration_id": {
Type: schema.TypeString,
Computed: true,
Description: "Integration id",
Copy link
Member

Choose a reason for hiding this comment

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

Curious what this field is used for. The description doesn't provide more information than the name.

Copy link
Member

@displague displague Feb 1, 2024

Choose a reason for hiding this comment

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

Same comment about bandwidth_from_api (and several fields in the adjacent helpers where the description is a s/_/ / transformation of the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this one, and some of the others, the unfortunate answer is that I don't think they actually are useful to the terraform users. They are apart of the Fabric API schema, but are not commonly (if ever) used by a customer to do anything. Difficult to get more information on them but I will double check.

For things like that I would actually like to remove them, but there would be a breaking change as you referenced because we've published v1.0.0 already.

Copy link
Contributor Author

@thogarty thogarty Feb 1, 2024

Choose a reason for hiding this comment

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

Nevermind, I found the details needed to provide a better description. Link here for reference: https://developer.equinix.com/docs?page=/dev-docs/fabric/overview

Updating to reflect it.

@@ -62,15 +63,16 @@ Read-Only:

- `account` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--account))
- `authentication_key` (String)
- **Deprecated** `gateway` Use `router` instead (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--router))
- `router` CloudRouter; Replaces `gateway` attribute (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--router))
- `gateway` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--gateway))
Copy link
Member

@displague displague Feb 1, 2024

Choose a reason for hiding this comment

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

Curious how we lost the deprecation on this attribute. Users should continue to be encouraged to read from the router rather than the gateway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I had fixed that in the resource, but forgot the data_source. Will update. Good comment.

@@ -20,9 +20,6 @@ func SetMap(d *schema.ResourceData, m map[string]interface{}) error {
if f, ok := v.(setFn); ok {
err = f(d, key)
} else {
if key == "router" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay!

@@ -2,7 +2,7 @@ package schema

import "reflect"

// resourceDataProvider provies interface to schema.ResourceData
// resourceDataProvider proxies interface to schema.ResourceData
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

return order
}

func OrderToTerra(order *v4.Order) *schema.Set {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're moving these fabric_common_ files anyway, I recommend creating a separate directory/package for them, perhaps:

  • internal/fabric/schema/mapping.go
  • internal/fabric/schema/schemas.go

Having it in a separate package helps clarify that this OrderToTerra, for example, is only useful in the context of Fabric integrations and should probably not be modified by other teams.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, good point. Will make that change.

@thogarty
Copy link
Contributor Author

thogarty commented Feb 1, 2024

@ctreatma and @displague, responded to feedback. Should be good to go for a follow up review. Appreciate the comments 👍

Additionally, anything that we're missing in here that you would like to have updated. I would like to push that to a fast follow if it can wait a little bit. We're trying to do the refactor first just to get Fabric in order so that we can update attribute behaviors+descriptions in a much lower cognitive overhead environment. Doing the untangling with the precision of improving the missing details has been challenging.

Copy link
Contributor

@ctreatma ctreatma left a comment

Choose a reason for hiding this comment

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

👍 on the changes to the common files

Copy link
Contributor

@srushti-patl srushti-patl left a comment

Choose a reason for hiding this comment

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

LGTM

@thogarty thogarty merged commit aff0633 into main Feb 2, 2024
6 of 9 checks passed
@thogarty thogarty deleted the CXF-83370-schema-updates-port-connection branch February 2, 2024 22:36
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.

None yet

5 participants