Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Fix packages sort #1

Merged
merged 2 commits into from
Nov 28, 2019
Merged

Conversation

sebgl
Copy link

@sebgl sebgl commented Nov 28, 2019

We want to compare resource group first, then fallback to resource
version if the group is the same. The previous version of the sort
algorithm did not work as expected in some situations, by comparing
resources version even though their group does not match.

Only the case where groupA < groupB was considered for group comparison,
leading to a version comparison if groupA > groupB.

This commit fixes it by making sure we evaluate version comparison only
if groups are the same.

It is verified by a unit test that does not pass with the previous
version of the sort algorithm.

To properly run a unit test in the same package as main.go, I
had to work around [this issue]{golang/go#31859).

We want to compare resource group first, then fallback to resource
version if the group is the same. The previous version of the sort
algorithm did not work as expected in some situations, by comparing
resources version even though their group does not match.

Only the case where groupA < groupB was considered for group comparison,
leading to a version comparison if groupA > groupB.

This commit fixes it by making sure we evaluate version comparison only
if groups are the same.

It is verified by a unit test that does not pass with the previous
version of the sort algorithm.
An issue prevents unit tests to run if flags are initialized in an
init() function. More details there:
golang/go#31859.

A workaround is to init flags another way (here by calling a function
from main()).
@charith-elastic charith-elastic merged commit fe5dff2 into elastic:master Nov 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants