Skip to content

Commit

Permalink
Merge pull request #417 from yue9944882/bugfix/order-structs
Browse files Browse the repository at this point in the history
Bugfix: Sort structs by names in apiregister-gen
  • Loading branch information
k8s-ci-robot authored Sep 9, 2019
2 parents 1682dee + 1f42eef commit 35660a9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/apiregister-gen/generators/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"path"
"path/filepath"
"sort"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -593,6 +594,10 @@ func (b *APIsBuilder) ParseStructsAndAliases(apigroup *APIGroup) {
remaining = append(remaining, GenUnversionedType{at, nil})
}
}
sort.Slice(apigroup.Structs, func(i, j int) bool {
// alphabetic sort by struct names
return apigroup.Structs[i].Name < apigroup.Structs[j].Name
})
}

func (apigroup *APIGroup) DoType(t *types.Type) (*Struct, []*types.Type) {
Expand Down

0 comments on commit 35660a9

Please sign in to comment.