Skip to content

Commit

Permalink
Order the outputs in component model so result is always the same order.
Browse files Browse the repository at this point in the history
  • Loading branch information
blakerouse committed Nov 9, 2022
1 parent d665e66 commit cecd776
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package component
import (
"fmt"
"os"
"sort"
"strings"

"github.com/elastic/elastic-agent-client/v7/pkg/client"
Expand Down Expand Up @@ -164,9 +165,17 @@ func (r *RuntimeSpecs) PolicyToComponents(policy map[string]interface{}) ([]Comp
return nil, nil, err
}

// order output keys; ensures result is always the same order
outputKeys := make([]string, 0, len(outputsMap))
for k := range outputsMap {
outputKeys = append(outputKeys, k)
}
sort.Strings(outputKeys)

var components []Component
componentIdsInputMap := make(map[string]string)
for outputName, output := range outputsMap {
for _, outputName := range outputKeys {
output := outputsMap[outputName]
if !output.enabled {
// skip; not enabled
continue
Expand Down

0 comments on commit cecd776

Please sign in to comment.