Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Singer committed Jan 26, 2024
1 parent 01aa539 commit 6b4367b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pkg/knowledge_base2/edge_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type (
Source construct.ResourceId `yaml:"source"`
Target construct.ResourceId `yaml:"target"`

// AlwaysProcess signals that the edge should always be processed even if the source and target exist in the input graph
// currently we dont check edges for operational rules if they previously existed and this flag is set to false
AlwaysProcess bool `yaml:"always_process"`

// DirectEdgeOnly signals that the edge cannot be used within constructing other paths
Expand Down
11 changes: 9 additions & 2 deletions pkg/knowledge_base2/properties/int_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package properties

import (
"fmt"
"math"

construct "github.com/klothoplatform/klotho/pkg/construct2"
knowledgebase "github.com/klothoplatform/klotho/pkg/knowledge_base2"
Expand Down Expand Up @@ -66,9 +67,15 @@ func (i *IntProperty) Parse(value any, ctx knowledgebase.DynamicContext, data kn
return val, nil
}
if val, ok := value.(float32); ok {
return int(val), nil
if float64(val) == math.Trunc(float64(val)) {
return int(val), nil
}
return nil, fmt.Errorf("invalid int value %v, of type %T", value, value)
} else if val, ok := value.(float64); ok {
return int(val), nil
if val == math.Trunc(val) {
return int(val), nil
}
return nil, fmt.Errorf("invalid int value %v, of type %T", value, value)
}
val, err := ParsePropertyRef(value, ctx, data)
if err == nil {
Expand Down
24 changes: 22 additions & 2 deletions pkg/knowledge_base2/properties/int_property_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func Test_IntProperty_Parse(t *testing.T) {
expected: 1,
},
{
name: "float32 property",
name: "valid float32 property",
property: &IntProperty{
PropertyDetails: knowledgebase2.PropertyDetails{
Path: "test",
Expand All @@ -168,7 +168,17 @@ func Test_IntProperty_Parse(t *testing.T) {
expected: 1,
},
{
name: "float64 property",
name: "invalid float32 property",
property: &IntProperty{
PropertyDetails: knowledgebase2.PropertyDetails{
Path: "test",
},
},
value: float32(1.1),
wantErr: true,
},
{
name: "valid float64 property",
property: &IntProperty{
PropertyDetails: knowledgebase2.PropertyDetails{
Path: "test",
Expand All @@ -177,6 +187,16 @@ func Test_IntProperty_Parse(t *testing.T) {
value: float64(1.0),
expected: 1,
},
{
name: "invalid float64 property",
property: &IntProperty{
PropertyDetails: knowledgebase2.PropertyDetails{
Path: "test",
},
},
value: float64(1.1),
wantErr: true,
},
{
name: "non int property",
property: &IntProperty{
Expand Down

0 comments on commit 6b4367b

Please sign in to comment.