Skip to content

Commit 48fd41b

Browse files
Revert "add further todos related to wrong object check"
This reverts commit 96a2f0b.
1 parent 96a2f0b commit 48fd41b

File tree

4 files changed

+3
-11
lines changed

4 files changed

+3
-11
lines changed

pkg/tfbridge/info/validate.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ func (c *infoCheck) checkProperty(path walk.SchemaPath, tfs shim.Schema, ps *Sch
116116
// To prevent confusion, users are barred from specifying information on
117117
// the associated Elem. All information should be specified directly on
118118
// this SchemaInfo.
119-
// TODO: Wrong object check, what is the intention here?
120119
if obj, ok := util.CastToTypeObject(tfs); ok {
121120
if ps.Elem != nil {
122121
c.error(path, errElemForObject)

pkg/tfbridge/info/validate_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func TestValidateNameOverride(t *testing.T) {
3939
Type: shim.TypeInt,
4040
}).Shim(),
4141
}).Shim(),
42-
// TODO: This doesn't pass internal validate
4342
"object1": (&schema.Schema{
4443
Type: shim.TypeMap,
4544
Elem: (&schema.Resource{

pkg/tfbridge/walk.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
2323
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
2424

25-
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
25+
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
2626
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/util"
2727
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/walk"
2828
md "github.com/pulumi/pulumi-terraform-bridge/v3/unstable/metadata"
@@ -94,7 +94,6 @@ func propertyPathToSchemaPathInner(
9494
// Detect single-nested blocks (object types).
9595
//
9696
// This is the case where (schema & schema.Elem) ~ {x: T}.
97-
// TODO: Fix - the object type function is wrong.
9897
if res, isRes := util.CastToTypeObject(schema); isRes {
9998
return propertyPathToSchemaPath(basePath, propertyPath, res, schemaInfo.Fields)
10099
}
@@ -215,7 +214,6 @@ func schemaPathToPropertyPathInner(
215214
}
216215

217216
// Detect single-nested blocks (object types).
218-
// TODO: Fix
219217
if obj, isObject := util.CastToTypeObject(schema); isObject {
220218
return schemaPathToPropertyPath(basePath, schemaPath, obj, schemaInfo.Fields)
221219
}

pkg/tfshim/util/types.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package util
1616

1717
import (
18-
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
18+
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
1919
)
2020

2121
// IsOfTypeMap detects schemas indicating a map[string,X] type. Due to a quirky encoding of
@@ -25,9 +25,6 @@ func IsOfTypeMap(tfs shim.Schema) bool {
2525
if tfs == nil || tfs.Type() != shim.TypeMap {
2626
return false
2727
}
28-
29-
// TODO: Can there be a map nested resource?
30-
// This might be unused though
3128
_, hasResourceElem := tfs.Elem().(shim.Resource)
3229
return !hasResourceElem
3330
}
@@ -41,8 +38,7 @@ func CastToTypeObject(tfs shim.Schema) (shim.SchemaMap, bool) {
4138
return nil, false
4239
}
4340
res, isRes := tfs.Elem().(shim.Resource)
44-
// TODO: Map nested resources are not a thing, AFAIK
45-
if isRes {
41+
if isRes && tfs.Type() == shim.TypeMap {
4642
return res.Schema(), true
4743
}
4844
return nil, false

0 commit comments

Comments
 (0)