Skip to content

Commit 078e63e

Browse files
Allow for a Type: 'boolean' to validate when property value is a stringified bool
1 parent 7dd77ef commit 078e63e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pkg/tfbridge/typechecker/typechecker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ func (v *TypeChecker) validatePropertyValue(
161161

162162
switch typeSpec.Type {
163163
case "boolean":
164-
if !propertyValue.IsBool() {
164+
// The bridge permits the strings "true" and "false" to read as boolean, so allow strings.
165+
if !propertyValue.IsBool() && !propertyValue.IsString() {
165166
return []Failure{newTypeFailure(propertyPath, typeSpec.Type, propertyValue)}
166167
}
167168
return nil

pkg/tfbridge/typechecker/typechecker_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,11 @@ func TestValidateConfigType(t *testing.T) {
16311631
})),
16321632
}),
16331633
},
1634+
{
1635+
name: "allows_bool_strings",
1636+
inputName: "skipMetadataApiCheck",
1637+
input: resource.PropertyValue{V: "true"},
1638+
},
16341639
}
16351640
for _, tc := range testCases {
16361641
tc := tc
@@ -1661,6 +1666,11 @@ func TestValidateConfigType(t *testing.T) {
16611666
},
16621667
},
16631668
},
1669+
"skipMetadataApiCheck": {
1670+
TypeSpec: pschema.TypeSpec{
1671+
Type: "boolean",
1672+
},
1673+
},
16641674
},
16651675
},
16661676
}

0 commit comments

Comments
 (0)