Skip to content

Commit

Permalink
populate the map from a slice
Browse files Browse the repository at this point in the history
  • Loading branch information
Liujingfang1 committed Jun 22, 2018
1 parent 636ab87 commit 991ffbb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/resmap/idslice.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ func (a IdSlice) Less(i, j int) bool {
return a[i].Name() < a[j].Name()
}

var typeOrders = map[string]int{
"Namespace": 0,
"CustomResourceDefinition": 1,
"ServiceAccount": 2,
"Role": 3,
"ClusterRole": 4,
"RoleBinding": 5,
"ClusterRoleBinding": 6,
}
var order = []string{"Namespace", "CustomResourceDefinition", "ServiceAccount",
"Role", "ClusterRole", "RoleBinding", "ClusterRoleBinding"}
var typeOrders = func() map[string]int {
m := map[string]int{}
for i, n := range order {
m[n] = i
}
return m
}()

func gvkLess(i, j schema.GroupVersionKind) bool {
indexi, foundi := typeOrders[i.Kind]
Expand Down

0 comments on commit 991ffbb

Please sign in to comment.