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: Move Config-related code to internal/config #459

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

t0mk
Copy link
Contributor

@t0mk t0mk commented Nov 14, 2023

This PR moves Config struct and related code to internal/config. It's part of breakdown of the refactor to internal/.

Part of #106

@@ -1228,21 +1226,3 @@ func getCloudRouterUpdateRequest(conn v4.CloudRouter, d *schema.ResourceData) (v
}
return changeOps, nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is needed in Config for some user-agent magic, so I moved it to internal/fabric_utils

@t0mk t0mk marked this pull request as ready for review November 14, 2023 13:34
@t0mk t0mk requested a review from displague November 14, 2023 13:37
@displague
Copy link
Member

displague commented Nov 14, 2023

Could you run goimports -w -l github.com/equinix/terraform-provider-equinix . on this branch.

The TF project imports should be in the group of non-native packages or a third group dedicated to local packages (which is what the above command will do).

@t0mk t0mk self-assigned this Nov 14, 2023
@t0mk t0mk force-pushed the config_to_config/internal branch from 3d123b6 to 3fa9c60 Compare November 14, 2023 13:42
@t0mk
Copy link
Contributor Author

t0mk commented Nov 14, 2023

Could you run goimports -w -l github.com/equinix/terraform-provider-equinix . on this branch.

Done!

@displague
Copy link
Member

displague commented Nov 14, 2023

Could we move internal to the root. While it has the same effect to use equinix/internal, in that we can freely change the go package signatures without worry of breaking third-party dependencies, the intent with this internal/ package will be to park everything there by default. This includes Equinix related code and generic (type juggling) or TF setup/helping code.

@t0mk t0mk force-pushed the config_to_config/internal branch from 3fa9c60 to 95578ce Compare November 14, 2023 13:54
@codecov-commenter
Copy link

Codecov Report

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

Comparison is base (26b2f3d) 60.11% compared to head (3d123b6) 59.46%.
Report is 48 commits behind head on main.

❗ Current head 3d123b6 differs from pull request most recent head 95578ce. Consider uploading reports for the commit 95578ce to get more accurate results

Files Patch % Lines
equinix/fabric_mapping_helper.go 0.00% 33 Missing ⚠️
equinix/resource_fabric_connection.go 0.00% 27 Missing ⚠️
equinix/resource_fabric_cloud_router.go 0.00% 15 Missing ⚠️
equinix/resource_fabric_service_profile.go 0.00% 12 Missing ⚠️
equinix/resource_fabric_routing_protocol.go 0.00% 11 Missing ⚠️
equinix/resource_ecx_l2_connection.go 0.00% 8 Missing ⚠️
equinix/resource_ecx_l2_serviceprofile.go 0.00% 8 Missing ⚠️
equinix/resource_network_acl_template.go 0.00% 8 Missing ⚠️
equinix/resource_network_device.go 0.00% 8 Missing ⚠️
equinix/resource_network_device_link.go 0.00% 8 Missing ⚠️
... and 23 more

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #459      +/-   ##
==========================================
- Coverage   60.11%   59.46%   -0.66%     
==========================================
  Files          99       98       -1     
  Lines       20045    19880     -165     
==========================================
- Hits        12051    11822     -229     
- Misses       7691     7764      +73     
+ Partials      303      294       -9     

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

@@ -0,0 +1,24 @@
package fabric_utils
Copy link
Member

Choose a reason for hiding this comment

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

the package name should avoid utils

Without looking at how this is used.. fabric/correlation ?

If this is only used in one or two files, especially for testing, I'd be tempted to make this a private helper adjacent to the code that needs it.

Copy link
Contributor Author

@t0mk t0mk Nov 15, 2023

Choose a reason for hiding this comment

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

There will be more fabric utils when we migrate further:

fabric_mapping_helper.go
fabric_mapping_service_profile_helper.go
fabric_port_mapping_helper.go

The CorrelationId code was in fabric_mapping_helper.go IIRC. I didn't think about it too much and moved it to fabric_utils originally. However it seems that CorrelationId is not used anywhere but in Config. So I moved it straight to Config.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can move that CorrelationId code into Config but I would create a helper folder under internal, you can add those mapping helpers you mention there and we will also need that also to avoid import cycles #406 (comment) so it should look like
image

Copy link
Member

@displague displague Nov 15, 2023

Choose a reason for hiding this comment

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

@t0mk t0mk force-pushed the config_to_config/internal branch from 95578ce to af00a06 Compare November 15, 2023 10:18
@t0mk t0mk force-pushed the config_to_config/internal branch from af00a06 to 36a8da0 Compare November 15, 2023 10:20
@displague
Copy link
Member

There were an unusually high number of E2E tests that failed in CI for this build, but none look to be related to this change

@displague displague merged commit 60a89b8 into main Nov 15, 2023
4 of 5 checks passed
@displague displague deleted the config_to_config/internal branch November 15, 2023 23:46
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.

4 participants