Skip to content

Commit

Permalink
Allow for a Type: 'boolean' to validate when property value is a stri…
Browse files Browse the repository at this point in the history
…ngified bool
  • Loading branch information
guineveresaenger committed Oct 28, 2024
1 parent 7dd77ef commit 078e63e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/tfbridge/typechecker/typechecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func (v *TypeChecker) validatePropertyValue(

switch typeSpec.Type {
case "boolean":
if !propertyValue.IsBool() {
// The bridge permits the strings "true" and "false" to read as boolean, so allow strings.
if !propertyValue.IsBool() && !propertyValue.IsString() {
return []Failure{newTypeFailure(propertyPath, typeSpec.Type, propertyValue)}
}
return nil
Expand Down
10 changes: 10 additions & 0 deletions pkg/tfbridge/typechecker/typechecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,11 @@ func TestValidateConfigType(t *testing.T) {
})),
}),
},
{
name: "allows_bool_strings",
inputName: "skipMetadataApiCheck",
input: resource.PropertyValue{V: "true"},
},
}
for _, tc := range testCases {
tc := tc
Expand Down Expand Up @@ -1661,6 +1666,11 @@ func TestValidateConfigType(t *testing.T) {
},
},
},
"skipMetadataApiCheck": {
TypeSpec: pschema.TypeSpec{
Type: "boolean",
},
},
},
},
}
Expand Down

0 comments on commit 078e63e

Please sign in to comment.