diff --git a/pkg/tiller/kind_sorter.go b/pkg/tiller/kind_sorter.go index e0549e2f4..d9c860b93 100644 --- a/pkg/tiller/kind_sorter.go +++ b/pkg/tiller/kind_sorter.go @@ -116,8 +116,12 @@ func (k *kindSorter) Less(i, j int) bool { b := k.manifests[j] first, aok := k.ordering[a.head.Kind] second, bok := k.ordering[b.head.Kind] + // if same kind (including unknown) sub sort alphanumeric if first == second { - // same kind (including unknown) so sub sort alphanumeric + // if both are unknown and of different kind sort by kind alphabetically + if !aok && !bok && a.head.Kind != b.head.Kind { + return a.head.Kind < b.head.Kind + } return a.name < b.name } // unknown kind is last diff --git a/pkg/tiller/kind_sorter_test.go b/pkg/tiller/kind_sorter_test.go index a707176b3..2bb1dc075 100644 --- a/pkg/tiller/kind_sorter_test.go +++ b/pkg/tiller/kind_sorter_test.go @@ -176,7 +176,7 @@ func TestKindSorterSubSort(t *testing.T) { head: &util.SimpleHead{Kind: "ClusterRoleBinding"}, }, { - name: "u3", + name: "u2", head: &util.SimpleHead{Kind: "Unknown"}, }, { @@ -184,8 +184,8 @@ func TestKindSorterSubSort(t *testing.T) { head: &util.SimpleHead{Kind: "Unknown"}, }, { - name: "u2", - head: &util.SimpleHead{Kind: "Unknown"}, + name: "t3", + head: &util.SimpleHead{Kind: "Unknown2"}, }, } for _, test := range []struct { @@ -194,7 +194,7 @@ func TestKindSorterSubSort(t *testing.T) { expected string }{ // expectation is sorted by kind (unknown is last) and then sub sorted alphabetically within each group - {"cm,clusterRole,clusterRoleBinding,Unknown", InstallOrder, "01Aa!zu1u2u3"}, + {"cm,clusterRole,clusterRoleBinding,Unknown,Unknown2", InstallOrder, "01Aa!zu1u2t3"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) {