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

adopt internal/ layout structure #106

Open
displague opened this issue Mar 2, 2022 · 2 comments
Open

adopt internal/ layout structure #106

displague opened this issue Mar 2, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@displague
Copy link
Member

The number of files in equinix/ has been expanding with recent additions. The developer experience can be improved by compartmentalizing resources into an alternate structure. This practice has become more popular in the past year or so.

Proposed structure:

  • equinix/provider.go
    By maintaining the "provider" package, downstream tooling such as Pulumi, Kubeform, Crossplane, and the OpenShift IPI driver (under development, paused) may continue to import the project
  • internal/services/metal/device/schema.go
    This would combine all schemas into a single file.
    This is a pattern found in Kubebuilder {resourcename}_types.go files for a single resource. In Kubebuilder all resources reside in their own file, packaged by API version.
    Crossplane follows a similar pattern with an extra service path (https://github.com/crossplane-contrib/provider-tf-equinix-metal/tree/main/apis/connection/v1alpha1). An interesting distinction about Crossplane's pattern is that the schema symbols are exported. This may be a requirement for some downstream tooling (I haven't researched or identified this).
  • internal/services/metal/device/resource.go
  • internal/services/metal/device/datasource.go
  • internal/services/networkedge/device/resource.go
  • other common files should flow naturally by refactoring the single resource files today. Each resource could, for example, include flatteners, expanders, converters, and other helpers.
  • internal/migrationtool/
  • A matching _test.go for each file

Considerations:

  • removing exported symbols from equinix/ is a breaking change from a Go and user perspective. I believe we can safely assert from the aforementioned consumers, that most if not all Go consumers are interested in the Provider type, and nothing else.
  • Linode's provider puts the HCL templates used during E2E testing into a separate folder and file for each template. A template builder pattern allows for a functional, chaining, approach to modifying the test template.

Inspiration:

@ocobles
Copy link
Contributor

ocobles commented Mar 5, 2024

Are we ready to close this issue or should it remain open until all resources are fully migrated into internal? I have created another issue to track resources migration to framework where we force move them to internal during migration #612

@displague
Copy link
Member Author

displague commented Mar 12, 2024

Moving to internal/ could be done ahead of Framework migration which can be trickier. I think we should leave this open until the resources are moved to internal and the teams supporting this work should take this step before Framework migration.

displague added a commit that referenced this issue Jun 20, 2024
…#700)

This updates the `metal_virtual_circuit` resource and data source to use
`equinix-sdk-go` instead of `packngo`. As mentioned in #402, the
`packngo` SDK has been deprecated, and moving to `equinix-sdk-go` makes
it possible for these resources to gain new features in the future.

As an added bonus, the affected code has also been moved to
`internal/resources/metal` to align with #106.
ctreatma added a commit that referenced this issue Jul 8, 2024
This replaces `packngo` with `equinix-sdk-go` in the metal_port resource
and datasource as part of #402. While I'm in these files I also opted to
move them into `internal/resources/metal/port` to align with #106.
ctreatma pushed a commit that referenced this issue 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 added a commit that referenced this issue Sep 25, 2024
This moves the device resource and data sources out of the `equinix`
package and into an isolated directory & package to align with #106.
ctreatma added a commit that referenced this issue Oct 30, 2024
To ensure that we continue to make progress on #106, this updates the
`Validate PR` GitHub Actions Workflow to check if new Go files have been
added to the `equinix/` directory.

The workflow only checks for [files with `"added"`
status](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests-files)
that are directly under the `equinix/` directory. This leaves room for
renaming/copying files and for adding new packages in
`equinix/<subdirectory>/`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants