-
Notifications
You must be signed in to change notification settings - Fork 44
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
Conversation
Codecov ReportAttention:
❗ 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. |
aaf22da
to
d389876
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.
LGTM!
@@ -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)) |
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 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.
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.
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.
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.
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 { |
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 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).
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.
Removing exported functions at a later date is a breaking change
because this project was released at 1.0.0 in the past.
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.
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", |
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.
Curious what this field is used for. The description doesn't provide more information than the name.
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.
Same comment about bandwidth_from_api (and several fields in the adjacent helpers where the description is a s/_/ /
transformation of the name.
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.
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.
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.
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)) |
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.
Curious how we lost the deprecation on this attribute. Users should continue to be encouraged to read from the router
rather than the gateway
.
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.
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" { |
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.
Yay!
@@ -2,7 +2,7 @@ package schema | |||
|
|||
import "reflect" | |||
|
|||
// resourceDataProvider provies interface to schema.ResourceData | |||
// resourceDataProvider proxies interface to schema.ResourceData |
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.
👍
return order | ||
} | ||
|
||
func OrderToTerra(order *v4.Order) *schema.Set { |
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.
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.
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.
Yea, good point. Will make that change.
1b2bc81
to
126c37a
Compare
@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. |
… gateway to terra state
126c37a
to
1ff8a47
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.
👍 on the changes to the common files
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
internal
Packageinternal
package