Skip to content

Commit

Permalink
Use prefix instead of equal to handle 'resource(matcher)' types
Browse files Browse the repository at this point in the history
  • Loading branch information
gordon-klotho committed Feb 29, 2024
1 parent cd31f21 commit 08667e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/engine/operational_eval/vertex_path_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (v *pathExpandVertex) addDepsFromProps(
var errs error
for k, prop := range tmpl.Properties {
// Only consider properties whose type can even accommodate a resource
if prop.Type() != "resource" {
if !strings.HasPrefix(prop.Type(), "resource") {
continue
}
details := prop.Details()
Expand Down
1 change: 1 addition & 0 deletions pkg/engine/operational_eval/vertex_path_expand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func Test_pathExpandVertex_addDepsFromProps(t *testing.T) {

mockSol.On("RawView").Return(resultGraph).Once()
mockProperty.EXPECT().Validate(resource, construct.ResourceId{Name: "u"}, gomock.Any()).Return(nil).Times(1)
mockProperty.EXPECT().Type().Return("resource").Times(1)
return nil
},
want: graphChanges{
Expand Down
14 changes: 12 additions & 2 deletions pkg/knowledgebase/properties/string_property_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,23 @@ func Test_StringParse(t *testing.T) {
expected: "test",
},
{
name: "non string throws error",
name: "non string converts int",
property: &StringProperty{
PropertyDetails: knowledgebase.PropertyDetails{
Path: "test",
},
},
value: 1,
expected: "1",
},
{
name: "non string fails non-primitive",
property: &StringProperty{
PropertyDetails: knowledgebase.PropertyDetails{
Path: "test",
},
},
value: 1,
value: []string{"hi"},
wantErr: true,
},
}
Expand Down

0 comments on commit 08667e7

Please sign in to comment.