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

Fix unknown collections of obj #2061

Merged
merged 61 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
63a9bff
unknown tests
VenelinMartinov Jun 4, 2024
1c3797a
rename accidentally repeated test name
VenelinMartinov Jun 4, 2024
9cca15c
add description for the tests
VenelinMartinov Jun 4, 2024
989d6f1
correct test case
VenelinMartinov Jun 5, 2024
d77e1a0
fix proposed new unknown blocks
VenelinMartinov Jun 5, 2024
c76fba8
correct set test
VenelinMartinov Jun 5, 2024
143b87b
remove duplicated known check
VenelinMartinov Jun 5, 2024
8257844
add check test
VenelinMartinov Jun 5, 2024
2146474
fix unknown collection of obj
VenelinMartinov Jun 5, 2024
6ae7900
uncomment test
VenelinMartinov Jun 5, 2024
9ebe339
fix non prc tests
VenelinMartinov Jun 5, 2024
da0353b
Merge branch 'master' into vvm/fix_unknown_collections_of_obj
VenelinMartinov Jun 18, 2024
f596124
support all types of unknowns
VenelinMartinov Jun 25, 2024
a572732
use autogold for the cli output
VenelinMartinov Jun 25, 2024
65e1e4a
Merge branch 'master' into vvm/fix_unknown_collections_of_obj
VenelinMartinov Jun 25, 2024
9a70d46
Merge branch 'master' into vvm/fix_unknown_collections_of_obj
VenelinMartinov Jun 26, 2024
e5f0908
lint
VenelinMartinov Jun 26, 2024
a322aac
add test with unknown and known in a list
VenelinMartinov Jun 26, 2024
d980b07
nested tests
VenelinMartinov Jun 26, 2024
7624356
Merge branch 'master' into vvm/fix_unknown_collections_of_obj
VenelinMartinov Jun 27, 2024
67e2bae
add some more tests, debugging
VenelinMartinov Jun 27, 2024
ff51402
add note about plugin sdk behaviour
VenelinMartinov Jun 27, 2024
6931e6a
more tests for updating with computed
VenelinMartinov Jun 27, 2024
6524b9d
commit tests
VenelinMartinov Jun 27, 2024
3e9a8a8
update tests
VenelinMartinov Jun 27, 2024
e61d153
Merge branch 'vvm/more_unknown_tests' into vvm/fix_unknown_collection…
VenelinMartinov Jun 27, 2024
ac7747f
inline tf unknown
VenelinMartinov Jun 27, 2024
c4dde52
update test
VenelinMartinov Jun 27, 2024
a96ce40
remove debug logging
VenelinMartinov Jun 27, 2024
6b1e2be
remove debug logging
VenelinMartinov Jun 27, 2024
026a0df
update resources
VenelinMartinov Jun 27, 2024
2a6ebd3
update test
VenelinMartinov Jun 27, 2024
68de606
update unused code
VenelinMartinov Jun 27, 2024
480acc6
add todos
VenelinMartinov Jun 27, 2024
bc61456
another todo
VenelinMartinov Jun 27, 2024
a44380f
add note about odd test
VenelinMartinov Jun 27, 2024
ef39d9d
lint
VenelinMartinov Jul 1, 2024
54f438b
fix todo
VenelinMartinov Jul 1, 2024
06929b5
fix needs update check
VenelinMartinov Jul 1, 2024
4b4fc3b
Merge branch 'master' into vvm/fix_unknown_collections_of_obj
VenelinMartinov Jul 1, 2024
8a48049
fix test
VenelinMartinov Jul 1, 2024
f91d224
more lint
VenelinMartinov Jul 2, 2024
725ea59
diff tests for sdkv2
VenelinMartinov Jul 3, 2024
d8395ff
make new config and state for each test
VenelinMartinov Jul 3, 2024
9d05430
separate setup for each test
VenelinMartinov Jul 3, 2024
0573b9b
move schemaconvert
VenelinMartinov Jul 3, 2024
b5177ec
lint
VenelinMartinov Jul 3, 2024
1973687
lint
VenelinMartinov Jul 3, 2024
fc38c75
add a v2 override
VenelinMartinov Jul 3, 2024
f97793e
Merge branch 'vvm/diff_tests_for_sdkv2' into vvm/fix_unknown_collecti…
VenelinMartinov Jul 3, 2024
beea3a3
go mod tidy
VenelinMartinov Jul 3, 2024
8e17f48
rework schema.go to support both strategies for unknowns
VenelinMartinov Jul 3, 2024
bae090b
implement all providers
VenelinMartinov Jul 3, 2024
82616ba
update tests
VenelinMartinov Jul 3, 2024
71cdfd0
Revert "add a v2 override"
VenelinMartinov Jul 3, 2024
faeb1d4
go mod tidy
VenelinMartinov Jul 3, 2024
4692119
Merge branch 'vvm/diff_tests_for_sdkv2' into vvm/fix_unknown_collecti…
VenelinMartinov Jul 3, 2024
3affc4a
lint
VenelinMartinov Jul 3, 2024
d029d6e
lint
VenelinMartinov Jul 3, 2024
c910839
address review comments
VenelinMartinov Jul 17, 2024
ddc6c06
Merge branch 'master' into vvm/fix_unknown_collections_of_obj
VenelinMartinov Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hexops/autogold/v2 v2.2.1
github.com/hexops/valast v1.4.4
github.com/pulumi/providertest v0.0.12
github.com/pulumi/providertest v0.0.13
github.com/pulumi/pulumi-terraform-bridge/v3 v3.80.0
github.com/stretchr/testify v1.9.0
gotest.tools v2.2.0+incompatible
Expand Down Expand Up @@ -65,6 +65,8 @@ require (
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions pkg/tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1911,8 +1911,8 @@ github.com/pulumi/esc v0.9.1 h1:HH5eEv8sgyxSpY5a8yePyqFXzA8cvBvapfH8457+mIs=
github.com/pulumi/esc v0.9.1/go.mod h1:oEJ6bOsjYlQUpjf70GiX+CXn3VBmpwFDxUTlmtUN84c=
github.com/pulumi/inflector v0.1.1 h1:dvlxlWtXwOJTUUtcYDvwnl6Mpg33prhK+7mzeF+SobA=
github.com/pulumi/inflector v0.1.1/go.mod h1:HUFCjcPTz96YtTuUlwG3i3EZG4WlniBvR9bd+iJxCUY=
github.com/pulumi/providertest v0.0.12 h1:UjcFQHHs4AGJyJqxhvC2q8yVQ7Li+UyCyP95HZcK03U=
github.com/pulumi/providertest v0.0.12/go.mod h1:REAoaN+hGOtdWJGirfWYqcSjCejlbGfzyVTUuemJTuE=
github.com/pulumi/providertest v0.0.13 h1:9CAaoviOTuCVHDI15h3znXa5JsKYtXLYHIIdxOCzo3Y=
github.com/pulumi/providertest v0.0.13/go.mod h1:REAoaN+hGOtdWJGirfWYqcSjCejlbGfzyVTUuemJTuE=
github.com/pulumi/pulumi-java/pkg v0.11.0 h1:Jw9gBvyfmfOMq/EkYDm9+zGPxsDAA8jfeMpHmtZ+1oA=
github.com/pulumi/pulumi-java/pkg v0.11.0/go.mod h1:sXAk25P47AQVQL6ilAbFmRNgZykC7og/+87ihnqzFTc=
github.com/pulumi/pulumi-yaml v1.8.0 h1:bhmidiCMMuzsJao5FE0UR69iF3WVKPCFrRkzjotFNn4=
Expand Down
24 changes: 20 additions & 4 deletions pkg/tests/internal/pulcheck/pulcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ import (
"gotest.tools/assert"
)

func resNeedsUpdate(res *schema.Resource) bool {
Copy link
Member

Choose a reason for hiding this comment

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

What does this supposed to compute?

Copy link
Contributor Author

@VenelinMartinov VenelinMartinov Jul 1, 2024

Choose a reason for hiding this comment

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

This is to determine if we should add an Update method - InternalValidate fails for schemas which don't need an update but have it.

Copy link
Member

Choose a reason for hiding this comment

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

The for loop doesn't do anything here. It only has conditional continue statements. If we don't need to check the value of fields, we should remove the for loop and just return res.UpdateContext == nil. Otherwise we need to make sure that resNeedsUpdate is under test for whatever functionality it supports.

for _, s := range res.Schema {
if s.Computed && !s.Optional {
continue
}
if s.ForceNew {
continue
}

return res.UpdateContext == nil
VenelinMartinov marked this conversation as resolved.
Show resolved Hide resolved
}
return false
}

// This is an experimental API.
func EnsureProviderValid(t T, tfp *schema.Provider) {
for _, r := range tfp.ResourcesMap {
Expand All @@ -54,10 +68,12 @@ func EnsureProviderValid(t T, tfp *schema.Provider) {
}
}

r.UpdateContext = func(
ctx context.Context, rd *schema.ResourceData, i interface{},
) diag.Diagnostics {
return diag.Diagnostics{}
if resNeedsUpdate(r) {
VenelinMartinov marked this conversation as resolved.
Show resolved Hide resolved
r.UpdateContext = func(
ctx context.Context, rd *schema.ResourceData, i interface{},
) diag.Diagnostics {
return diag.Diagnostics{}
}
}
}
require.NoError(t, tfp.InternalValidate())
Expand Down
Loading
Loading