Skip to content

Commit 96a2f0b

Browse files
add further todos related to wrong object check
1 parent efe595d commit 96a2f0b

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

pkg/tfbridge/info/validate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ 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?
119120
if obj, ok := util.CastToTypeObject(tfs); ok {
120121
if ps.Elem != nil {
121122
c.error(path, errElemForObject)

pkg/tfbridge/info/validate_test.go

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

pkg/tfbridge/walk.go

Lines changed: 3 additions & 1 deletion
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-
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
25+
shim "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,6 +94,7 @@ 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.
9798
if res, isRes := util.CastToTypeObject(schema); isRes {
9899
return propertyPathToSchemaPath(basePath, propertyPath, res, schemaInfo.Fields)
99100
}
@@ -214,6 +215,7 @@ func schemaPathToPropertyPathInner(
214215
}
215216

216217
// Detect single-nested blocks (object types).
218+
// TODO: Fix
217219
if obj, isObject := util.CastToTypeObject(schema); isObject {
218220
return schemaPathToPropertyPath(basePath, schemaPath, obj, schemaInfo.Fields)
219221
}

pkg/tfshim/util/types.go

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

1717
import (
18-
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
18+
shim "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,6 +25,9 @@ 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
2831
_, hasResourceElem := tfs.Elem().(shim.Resource)
2932
return !hasResourceElem
3033
}
@@ -38,7 +41,8 @@ func CastToTypeObject(tfs shim.Schema) (shim.SchemaMap, bool) {
3841
return nil, false
3942
}
4043
res, isRes := tfs.Elem().(shim.Resource)
41-
if isRes && tfs.Type() == shim.TypeMap {
44+
// TODO: Map nested resources are not a thing, AFAIK
45+
if isRes {
4246
return res.Schema(), true
4347
}
4448
return nil, false

0 commit comments

Comments
 (0)