Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions pkg/cmds/crdonly.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cmds
import (
"fmt"
"os"
"sort"
"strings"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -65,10 +66,21 @@ func NewCmdGenerateCRDOnlyChart() *cobra.Command {
}
}

// Convert to slice
var crdFiles []*chart.File
for _, file := range crdMap {
crdFiles = append(crdFiles, file)
// Convert to slice in a deterministic order (sorted by group then kind)
// so repeated runs over the same input always produce identical output.
crdKeys := make([]schema.GroupKind, 0, len(crdMap))
for key := range crdMap {
crdKeys = append(crdKeys, key)
}
sort.Slice(crdKeys, func(i, j int) bool {
if crdKeys[i].Group != crdKeys[j].Group {
return crdKeys[i].Group < crdKeys[j].Group
}
return crdKeys[i].Kind < crdKeys[j].Kind
})
crdFiles := make([]*chart.File, 0, len(crdMap))
for _, key := range crdKeys {
crdFiles = append(crdFiles, crdMap[key])
}

var extraFiles []*chart.File
Expand Down
Loading