Skip to content

Commit

Permalink
determinism
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Singer committed Mar 12, 2024
1 parent 9a08362 commit 36f1ab6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/engine/operational_eval/vertex_edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package operational_eval
import (
"errors"
"fmt"
"sort"

construct "github.com/klothoplatform/klotho/pkg/construct"
"github.com/klothoplatform/klotho/pkg/engine/constraints"
Expand Down Expand Up @@ -103,7 +104,21 @@ func (ev *edgeVertex) Evaluate(eval *Evaluator) error {
}

var errs error
for _, rule := range ev.Rules {
rules := make([]knowledgebase.OperationalRule, 0, len(ev.Rules))
// Create a slice for the keys to sort so that we can add the rules in a deterministic order
keys := make([]string, 0, len(ev.Rules))
for k := range ev.Rules {
keys = append(keys, k)
}

// Sort the keys
sort.Strings(keys)

// Create a slice for the sorted values
for _, k := range keys {
rules = append(rules, ev.Rules[k])
}
for _, rule := range rules {
configRules := rule.ConfigurationRules
rule.ConfigurationRules = nil

Expand Down

0 comments on commit 36f1ab6

Please sign in to comment.