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

chore: refactor networkedge to Internal/ #622

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

displague
Copy link
Member

Part of #106 (experimenting to gauge scope of work)

Build appears fine, tests need more refactoring of constants shared between Fabric and NE.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 46.87500% with 34 lines in your changes are missing coverage. Please review.

Project coverage is 14.43%. Comparing base (93a0cc2) to head (d6b13e7).

Files Patch % Lines
internal/comparisons/comparisons.go 46.87% 34 Missing ⚠️

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

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #622       +/-   ##
===========================================
- Coverage   60.46%   14.43%   -46.04%     
===========================================
  Files         106       45       -61     
  Lines       18760     4018    -14742     
===========================================
- Hits        11344      580    -10764     
+ Misses       6896     3411     -3485     
+ Partials      520       27      -493     

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

@displague
Copy link
Member Author

The best way to advance this PR will be to split out the helper refactorings into separate (easy to review) PRs. This will prevent the creeping in of new code with the patterns we want to move away from.

displague added a commit that referenced this pull request May 10, 2024
Extracted from #622

Also ran goimports for clean up (triggered by stray imports based test
failure)
ctreatma pushed a commit that referenced this pull request May 20, 2024
Remove isStringInSlice in favor of slices.Contains.

Extracted from #622 
Related to #665

Signed-off-by: Marques Johansson <[email protected]>
@displague displague force-pushed the internal_networkedge branch from d6b13e7 to f3b96d7 Compare May 22, 2024 13:19
ctreatma pushed a commit that referenced this pull request Jul 11, 2024
This PR moves the helper functions from provider.go to a new comparisons
package. This package will be used by provider, tests, and resources.
The refactoring will assist with splitting resources into resource
specific packages. #106

The previous helper functions have been deprecated and will be removed
in a future commit.

Extracted from #622 (PR grew to large to maintain. Refactoring is not a
priority and rebasing gets hard as the underlying code changes)

Related to #674
Related to #654

Signed-off-by: Marques Johansson <[email protected]>
@displague displague force-pushed the internal_networkedge branch from f3b96d7 to 20a6b6b Compare July 16, 2024 21:33
@displague
Copy link
Member Author

displague commented Jul 16, 2024

@ctreatma @equinix/governor-ne-network-edge-engineering

I updated this refactor branch andgo test -v ./... is no longer complaining! (no more import cycles in the branch. this was not blocking go build ./... )

The biggest trick was moving the init function in internal/acceptance/acceptance.go to {same}_acc_test.go.

There are a few more rounds of cleanup that could happen to make this PR easier to review:

  • removing/replacing the deprecated helpers in a separate PR
  • unifying the template_acc_test.go helpers which were copy/pasted around to avoid needing a separate package of helpers (or further polluting acceptance as we have done with one or two shared Metal config templates)
  • removing the unused code (this is now required by the linter, along with other linting changes). In particular, the template_acc_test.go copy/paste has unused functions copied around for the previously mentioned reasons.
  • revisiting the commit log (I expected after a rebase that some of the commits would have been removed entirely, this was not the case)
  • the templates_acc_test.go helpers would be better designed as Go templates, or entirely different styles of templating could be introduced. I don't see that as necessary or in scope for this PR.

// from https://stackoverflow.com/a/45428032
func Difference(a, b []string) []string {
mb := make(map[string]struct{}, len(b))
// Difference returns the elements in `a` that aren't in `b`.
Copy link
Member Author

Choose a reason for hiding this comment

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

making Difference use generics doesn't have to be done in this PR.

@displague
Copy link
Member Author

#720 should be merged ahead of this so this PR can rebase and apply the sweeper related changes from that PR

@displague
Copy link
Member Author

displague commented Sep 25, 2024

After the latest rebase to pickup sweeper changes, and some changes to use SetMap (and a diag equivalent) for which more will be needed, there are new errors:

data_source_acc_test.go:25: Test validation error: TestStep 1/1 validation error: Providers must be specified at the TestCase level, or in all TestStep, or in TestStep.ConfigDirectory or TestStep.ConfigFile

I'm wondering if the init() calls in acceptance_test.go are not initializing the provider list correctly for cross-package testing.

…ovider-equinix on networkedge files

Signed-off-by: Marques Johansson <[email protected]>
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.

2 participants