From 140cf9d223c67118a6569caa9a30d79515d11184 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 28 Jan 2020 12:47:40 -0500 Subject: [PATCH] Reverting #7266 from the 3.0 release branch and 3.0.3 This fix is dependent on #6842 which is enough of a change to be considered a feature. Due to the dependency order reverting. The change will be part of 3.1.0. Signed-off-by: Matt Farina --- pkg/releaseutil/kind_sorter.go | 9 ++++----- pkg/releaseutil/kind_sorter_test.go | 21 --------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/pkg/releaseutil/kind_sorter.go b/pkg/releaseutil/kind_sorter.go index 41eeae722..f413e258b 100644 --- a/pkg/releaseutil/kind_sorter.go +++ b/pkg/releaseutil/kind_sorter.go @@ -134,13 +134,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 !aok && !bok { - // if both are unknown then sort alphabetically by kind, keep original order if same kind - if a.Head.Kind != b.Head.Kind { + if first == second { + // 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 first < second + return a.Name < b.Name } // unknown kind is last if !aok { diff --git a/pkg/releaseutil/kind_sorter_test.go b/pkg/releaseutil/kind_sorter_test.go index dcc5b847b..93d8ae782 100644 --- a/pkg/releaseutil/kind_sorter_test.go +++ b/pkg/releaseutil/kind_sorter_test.go @@ -245,24 +245,3 @@ func TestKindSorterSubSort(t *testing.T) { }) } } - -func TestKindSorterNamespaceAgainstUnknown(t *testing.T) { - unknown := Manifest{ - Name: "a", - Head: &SimpleHead{Kind: "Unknown"}, - } - namespace := Manifest{ - Name: "b", - Head: &SimpleHead{Kind: "Namespace"}, - } - - manifests := []Manifest{unknown, namespace} - sortByKind(manifests, InstallOrder) - - expectedOrder := []Manifest{namespace, unknown} - for i, manifest := range manifests { - if expectedOrder[i].Name != manifest.Name { - t.Errorf("Expected %s, got %s", expectedOrder[i].Name, manifest.Name) - } - } -}