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

Add import to pulumitest #91

Merged
merged 4 commits into from
Jul 16, 2024
Merged

Add import to pulumitest #91

merged 4 commits into from
Jul 16, 2024

Conversation

VenelinMartinov
Copy link
Contributor

@VenelinMartinov VenelinMartinov commented Jul 15, 2024

Adds an import function to pulumitest

The code was adapted from pulumi/pulumi-aws#3859 through pulumi/pulumi-gcp#1946

This is already used in GCP and AWS, I believe the azure provider needed it too at some point.

This is also needed for tests in the bridge: pulumi/pulumi-terraform-bridge#2180

Copy link

codecov bot commented Jul 15, 2024

Codecov Report

Attention: Patch coverage is 67.56757% with 12 lines in your changes missing coverage. Please review.

Project coverage is 38.38%. Comparing base (3a38438) to head (9f456be).
Report is 5 commits behind head on main.

Files Patch % Lines
pulumitest/import.go 50.00% 5 Missing and 2 partials ⚠️
pulumitest/execCmd.go 78.26% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   37.35%   38.38%   +1.03%     
==========================================
  Files          43       48       +5     
  Lines        2677     2816     +139     
==========================================
+ Hits         1000     1081      +81     
- Misses       1569     1616      +47     
- Partials      108      119      +11     

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

Copy link
Contributor

@thomas11 thomas11 left a comment

Choose a reason for hiding this comment

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

LGTM with one comment.

Also, it's helpful when the PR description states the "why" of the change, intended usage etc.

pulumitest/import_test.go Show resolved Hide resolved
@VenelinMartinov
Copy link
Contributor Author

Thanks, I've added notes on usage in AWS, GCP, Azure and the bridge.

@VenelinMartinov VenelinMartinov merged commit 7387849 into main Jul 16, 2024
4 checks passed
@VenelinMartinov VenelinMartinov deleted the vvm/add_import branch July 16, 2024 11:43
@pulumi-bot
Copy link

This PR has been shipped in release v0.0.14.

@t0yv0
Copy link
Member

t0yv0 commented Jul 16, 2024

@corymhall we were just talking this morning about the need for better import testing facilities. Looks like there is a start here, there's some examples here that write asserts against the generated program source code, but it does not yet help with tasks like taking the generated program and actually running it. Perhaps something that can be of interest to build on.

VenelinMartinov added a commit to pulumi/pulumi-terraform-bridge that referenced this pull request Jul 23, 2024
Fixes an issue with the SDKv2 and PF input extraction. During import we
wrongly return values for properties which are fully computed which
causes invalid programs to be generated.

~The object check in `CastToTypeObject` was wrong for SDKV2 objects:
https://github.com/pulumi/pulumi-terraform-bridge/blob/48fd41bd16e2f7f933bb9390ab7619d52faabb6d/pkg/tfshim/util/types.go#L36~

The `CastToTypeObject` object check is wrong for both SDKv2 and PF. For
the SDKV2 only sets and lists can have a `Resource` `.Elem`. For PF it
list-nested blocks are represented with a `Resource` `.Elem` in the shim
layer, so the check did not catch these. PF details here:
#2231
This fixes the check and adds regression tests for the broken imports
which resulted from 2180.

Test coverage added in
#2224 for sdkv2
and #2225 for pf.
fixes #2180
depends on pulumi/providertest#91
stacked on #2225
@mjeffryes mjeffryes added this to the 0.107 milestone Jul 24, 2024
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.

5 participants