Skip to content

Commit

Permalink
Merge pull request #988 from cw-Guo/fluentd-ordered
Browse files Browse the repository at this point in the history
feat: sort custom resources by metadata.name
  • Loading branch information
benjaminhuo committed Nov 14, 2023
2 parents be4da37 + 2454702 commit 08b005b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion apis/fluentd/v1alpha1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"sort"
"strings"

"github.com/fluent/fluent-operator/v2/apis/fluentd/v1alpha1/plugins"
Expand Down Expand Up @@ -120,7 +121,16 @@ func (pgr *PluginResources) PatchAndFilterClusterLevelResources(
cfgResources := NewCfgResources()

errs := make([]string, 0)

// sort all the CRs by metadata.name
sort.SliceStable(clusterInputs[:], func(i, j int) bool {
return clusterInputs[i].Name < clusterInputs[j].Name
})
sort.SliceStable(clusterfilters[:], func(i, j int) bool {
return clusterfilters[i].Name < clusterfilters[j].Name
})
sort.SliceStable(clusteroutputs[:], func(i, j int) bool {
return clusteroutputs[i].Name < clusteroutputs[j].Name
})
// List all inputs matching the label selector.
for _, i := range clusterInputs {
// patch filterId
Expand Down

0 comments on commit 08b005b

Please sign in to comment.