-
Notifications
You must be signed in to change notification settings - Fork 44
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
Diff tests for sdkv2 #2158
Diff tests for sdkv2 #2158
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2158 +/- ##
==========================================
+ Coverage 60.65% 60.74% +0.09%
==========================================
Files 350 351 +1
Lines 45930 46026 +96
==========================================
+ Hits 27857 27958 +101
+ Misses 16533 16520 -13
- Partials 1540 1548 +8 ☔ View full report in Codecov by Sentry. |
GH rate limits ❤️ |
I didn't review in detail but this is much needed! 🙇 LMK If you need a detailed review from me. |
This PR has been shipped in release v3.87.0. |
This changes the bridge to correctly return unknowns for objects and collections in sdkv2. fixes #1885 fixes #2032 stacked on #2158 Confirmed that TF sdkv2 supports both unknown blocks and unknown collections of blocks, so we should be fine to pass these into TF providers. The TF sdkv1 does not support unknowns for blocks and collections so we keep the old behaviour of passing empty/ collection of unknown. <details> ```hcl provider "google" { region = "us-central1" } resource "google_storage_bucket" "bucket" { name = "example-bucket12312322312" location = "US" } resource "google_storage_bucket" "bucket1" { name = "example-bucket123123223" location = "US" dynamic "lifecycle_rule" { for_each = google_storage_bucket.bucket.effective_labels content { action { type = lifecycle_rule.value } condition { age = 1 } } } } ``` </details> This returns `"lifecycle_rule":cty.UnknownVal(cty.List(cty.Object))` Our handling of collections containing unknowns and unknown collections is significantly better: Unknown collections: before: ``` + prov:index/test:Test: (create) [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] tests : [ [0]: {} ] ``` after: ``` + prov:index/test:Test: (create) [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] tests : output<string> ``` Note that the array being output as an `output<string>` is an engine limitation. Nested unknown collections: before: ``` + prov:index/nestedTest:NestedTest: (create) [urn=urn:pulumi:test::test::prov:index/nestedTest:NestedTest::mainRes] tests : [ [0]: { nestedProps: [ [0]: { testProps : [ [0]: output<string> ] } ] } ] ``` after: ``` + prov:index/nestedTest:NestedTest: (create) [urn=urn:pulumi:test::test::prov:index/nestedTest:NestedTest::mainRes] tests : [ [0]: { nestedProps: [ [0]: { testProps : output<string> } ] } ] ``` The unknown was being put one level lower than it should be. Quite a few other very wrong outputs in #2140, including diff duplications, missing diffs etc.
This refactors the existing diff tests to work for both sdkv1 and sdkv2 - they were previously v1 only.
To do that I've added a schemaconvert module which takes a v2 schema and converts it to a v1 schema.