Skip to content

Commit

Permalink
Revert "add further todos related to wrong object check"
Browse files Browse the repository at this point in the history
This reverts commit 96a2f0b.
  • Loading branch information
VenelinMartinov committed Jul 16, 2024
1 parent 96a2f0b commit 48fd41b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
1 change: 0 additions & 1 deletion pkg/tfbridge/info/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func (c *infoCheck) checkProperty(path walk.SchemaPath, tfs shim.Schema, ps *Sch
// To prevent confusion, users are barred from specifying information on
// the associated Elem. All information should be specified directly on
// this SchemaInfo.
// TODO: Wrong object check, what is the intention here?
if obj, ok := util.CastToTypeObject(tfs); ok {
if ps.Elem != nil {
c.error(path, errElemForObject)
Expand Down
1 change: 0 additions & 1 deletion pkg/tfbridge/info/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestValidateNameOverride(t *testing.T) {
Type: shim.TypeInt,
}).Shim(),
}).Shim(),
// TODO: This doesn't pass internal validate
"object1": (&schema.Schema{
Type: shim.TypeMap,
Elem: (&schema.Resource{
Expand Down
4 changes: 1 addition & 3 deletions pkg/tfbridge/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"

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

// Detect single-nested blocks (object types).
// TODO: Fix
if obj, isObject := util.CastToTypeObject(schema); isObject {
return schemaPathToPropertyPath(basePath, schemaPath, obj, schemaInfo.Fields)
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/tfshim/util/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package util

import (
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)

// IsOfTypeMap detects schemas indicating a map[string,X] type. Due to a quirky encoding of
Expand All @@ -25,9 +25,6 @@ func IsOfTypeMap(tfs shim.Schema) bool {
if tfs == nil || tfs.Type() != shim.TypeMap {
return false
}

// TODO: Can there be a map nested resource?
// This might be unused though
_, hasResourceElem := tfs.Elem().(shim.Resource)
return !hasResourceElem
}
Expand All @@ -41,8 +38,7 @@ func CastToTypeObject(tfs shim.Schema) (shim.SchemaMap, bool) {
return nil, false
}
res, isRes := tfs.Elem().(shim.Resource)
// TODO: Map nested resources are not a thing, AFAIK
if isRes {
if isRes && tfs.Type() == shim.TypeMap {
return res.Schema(), true
}
return nil, false
Expand Down

0 comments on commit 48fd41b

Please sign in to comment.