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 hcl2cdk to read nicer #2826

Merged
merged 6 commits into from
Apr 20, 2023
Merged

chore: Refactor hcl2cdk to read nicer #2826

merged 6 commits into from
Apr 20, 2023

Conversation

mutahhir
Copy link
Contributor

@mutahhir mutahhir commented Apr 20, 2023

Related issue

Fixes #2821
Fixes #2823

Description

During the development of 0.16, we deliberately didn't spend a lot of time to refactor and clean up the monolith that expression.ts was becoming. Now that the release is out, we can start cleaning it up.

This also removes the use of async when converting from the terraform expression AST to TypeScript. That was added in a hurry, but was not really required. This simplifies the code somewhat.

Checklist

  • I have updated the PR title to match CDKTF's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

Signed-off-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
@team-tf-cdk
Copy link
Collaborator

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@team-tf-cdk
Copy link
Collaborator

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@mutahhir mutahhir marked this pull request as ready for review April 20, 2023 08:59
@mutahhir mutahhir requested a review from a team as a code owner April 20, 2023 08:59
@mutahhir mutahhir requested review from ansgarm and Maed223 and removed request for a team April 20, 2023 08:59
@@ -22,6 +23,48 @@ const nodeIds = [
"local.service_name",
];

// Transforms a path with segments into literals describing the path
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved from expression.ts since we weren't using it anywhere else other than in this test suite

@@ -6,6 +6,9 @@ import { logger } from "@cdktf/commons";
import { AttributeType } from "@cdktf/provider-generator";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to consolidate all type related functions to this file rather than them living in expression.ts

@@ -2,33 +2,24 @@
// SPDX-License-Identifier: MPL-2.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Useful to look at this file commit by commit. First commit basically takes out all the functions that aren't related to TF Expr -> TS, and then the subsequent commits clean up the actual conversion

@team-tf-cdk
Copy link
Collaborator

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Copy link
Member

@ansgarm ansgarm left a comment

Choose a reason for hiding this comment

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

Took a bit to go through the commits as Githubs diff view was making changes hard to track, but I really like this clean up 👏

@team-tf-cdk
Copy link
Collaborator

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@mutahhir mutahhir merged commit 705cdc5 into main Apr 20, 2023
37 of 39 checks passed
@mutahhir mutahhir deleted the refactor/hcl2cdk branch April 20, 2023 12:43
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants