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

tools/importer-rest-api-specs: refactoring the terraform package to use the standard SDK Types #4248

Merged
merged 15 commits into from
Jul 3, 2024

Conversation

tombuildsstuff
Copy link
Contributor

@tombuildsstuff tombuildsstuff commented Jun 27, 2024

This PR:

  1. Moves the terraform package from ./tools/importer-rest-api-specs/components/terraform into `./tools/importer-rest-api-specs/internal/components/terraform'
  2. Refactors the terraform package to both use and return the SDK Models rather than the legacy resourcemanager models
  3. Starts (note: still work to do in a follow-up PR) documenting this package and it's behaviours
  4. Starts (note: still work to do in a follow-up PR) refactoring this package
  5. Starts (note: still work to do in a follow-up PR) consolidating the logging for this package

In order to make this work, it's been considerably easier to duplicate the package, refactor it, and then to remove the old one - so the diff for this may be a little strange, but this is ultimately copying, refactoring and then removing the old logic - but fundamentally there's little changed here.

Part 13 of #3754

@tombuildsstuff tombuildsstuff force-pushed the refactor/importer-rest-api-specs branch 2 times, most recently from be989d4 to a8ec26a Compare July 1, 2024 07:38
Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

LGTM 🥮

//
// NOTE: this should only be used within the `terraform` package - with the SDK Model `TerraformResourceDefinition`
// used elsewhere.
type WorkInProgressResource struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Whilst it would necessitate more imports, is it worth having nested internal packages here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I wondered the same here tbh, I ended up deciding against it because the paths felt too long? Particularly when bringing in the API Definitions Parser, which is a bunch of nested directories, but perhaps that's something we fix in a follow-up when the Parser logic is refactored too?

…to the new SDK Types/a new directory structure

Trying to refactor this in-place is a bunch more effort than refactoring the existing logic into a new package, so this
temporarily duplicates the files until the entire `terraform` package is refactored, to allow for a cleaner refactor.

This also gives the benefit of writing documentation for these as we go.
…into the Schema package, since it's schema related
… use the SDK Types

This is another clean-cut using only the newer SDK types, the older logic will be cleaned up separately in a bit
…ntification stage

This is where the WIP data is built-up, so it might as well start here
…ge over

Additional refactoring is needed here, as is documentation - but we need the codepaths re-enabled first
…WIPResource, so that we have this information as needed
…ier flattening

The structure may change post-refactoring to simplify this, but it's fine for now
@tombuildsstuff tombuildsstuff force-pushed the refactor/importer-rest-api-specs branch from a8ec26a to 327916f Compare July 3, 2024 10:04
@tombuildsstuff tombuildsstuff merged commit c920ae2 into main Jul 3, 2024
3 checks passed
@tombuildsstuff tombuildsstuff deleted the refactor/importer-rest-api-specs branch July 3, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor tool/importer-rest-api-specs Swagger Data Importer issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants