Skip to content

cli/command/stack: fix faulty sort for sorting stacks - #5212

Merged
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:fix_stack_sorting
Jul 1, 2024
Merged

cli/command/stack: fix faulty sort for sorting stacks#5212
thaJeztah merged 1 commit into
docker:masterfrom
thaJeztah:fix_stack_sorting

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

This code was updated in 7b9580d (#3139), which removed support for using kubernetes as orchestrator, but in doing so made this sort.Slice (probably) not do what it was expected to do ':)

index 412cc2e5ee86..861ae1be2fb9 100644
@@ -75,8 +54,7 @@ func format(dockerCli command.Cli, opts options.List, orchestrator command.Orche
}
sort.Slice(stacks, func(i, j int) bool {
return sortorder.NaturalLess(stacks[i].Name, stacks[j].Name) ||
- !sortorder.NaturalLess(stacks[j].Name, stacks[i].Name) &&- sortorder.NaturalLess(stacks[j].Namespace, stacks[i].Namespace)+ !sortorder.NaturalLess(stacks[j].Name, stacks[i].Name)
})
return formatter.StackWrite(stackCtx, stacks)
}

The extra condition was added in 84241cc (#1031) to support multiple namespaces. This patch removes it, bringing it back to the state it was before that commit.

- A picture of a cute animal (not mandatory but encouraged)

This code was updated in 7b9580d, which
removed support for using kubernetes as orchestrator, but in doing so
made this `sort.Slice` (probably) not do what it was expected to do ':)
index 412cc2e..861ae1b 100644
@@ -75,8 +54,7 @@ func format(dockerCli command.Cli, opts options.List, orchestrator command.Orche
}
sort.Slice(stacks, func(i, j int) bool {
return sortorder.NaturalLess(stacks[i].Name, stacks[j].Name) ||
- !sortorder.NaturalLess(stacks[j].Name, stacks[i].Name) &&
- sortorder.NaturalLess(stacks[j].Namespace, stacks[i].Namespace)
+ !sortorder.NaturalLess(stacks[j].Name, stacks[i].Name)
})
return formatter.StackWrite(stackCtx, stacks)
}
The extra condition was added in 84241cc
to support multiple namespaces. This patch removes it, bringing it back to
the state it was before that commit.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztahthaJeztah added this to the 28.0.0 milestone Jul 1, 2024
@thaJeztah
thaJeztah requested review from a team and silvin-lubecki as code ownersJuly 1, 2024 11:21
@thaJeztahthaJeztah self-assigned this Jul 1, 2024
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.42%. Comparing base (4270341) to head (be14edc).

Additional details and impacted files
@@ Coverage Diff @@## master #5212 +/- ##
==========================================
- Coverage 61.43% 61.42% -0.01% 
==========================================
Files 298 298 Lines 20799 20798 -1 ==========================================
- Hits 12777 12776 -1 
Misses 7109 7109 Partials 913 913 

@thaJeztah
thaJeztah merged commit cd982b1 into docker:masterJul 1, 2024
@thaJeztah
thaJeztah deleted the fix_stack_sorting branch July 1, 2024 13:08
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@thaJeztah@codecov-commenter@Benehiko