Skip to content

Commit

Permalink
sort CRs by metadata.name
Browse files Browse the repository at this point in the history
Signed-off-by: juicer <[email protected]>
  • Loading branch information
cw-Guo committed Nov 11, 2023
1 parent be4da37 commit 2454702
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 2454702

Please sign in to comment.