Class KubernetesVersionPriority
- java.lang.Object
-
- io.fabric8.kubernetes.client.utils.KubernetesVersionPriority
-
public class KubernetesVersionPriority extends Object
A utility class that allows to deal with Kubernetes versions and their priorities.The Kubernetes specs at Version Priority state the following:
- Entries that follow Kubernetes version patterns are sorted before those that do not.
- For entries that follow Kubernetes version patterns, the numeric portions of the version string is sorted largest to smallest.
- If the strings beta or alpha follow the first numeric portion, they sorted in that order, after the equivalent string without the beta or alpha suffix (which is presumed to be the GA version).
- If another number follows the beta, or alpha, those numbers are also sorted from largest to smallest.
- Strings that don’t fit the above format are sorted alphabetically and the numeric portions are not treated specially. Notice that in the example below, foo1 is sorted above foo10. This is different from the sorting of the numeric portion of entries that do follow the Kubernetes version patterns.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
highestPriority(List<String> versions)
Returns the version with the highest priority for the given list of versions.static <T> List<T>
sortByPriority(List<T> resources, Function<T,String> versionProvider)
Returns a sorted list of resources, for example,CustomResourceDefinitionVersion
s, ordered from highest to lowest priority.
-
-
-
Method Detail
-
highestPriority
public static String highestPriority(List<String> versions)
Returns the version with the highest priority for the given list of versions.- Parameters:
versions
- the versions to pick the version with the highest priority from- Returns:
- the version with the highest priority
- See Also:
CustomResourceDefinitionVersion.getName()
,CustomResourceDefinitionSpec.getVersions()
,KubernetesVersionPriority
-
sortByPriority
public static <T> List<T> sortByPriority(List<T> resources, Function<T,String> versionProvider)
Returns a sorted list of resources, for example,CustomResourceDefinitionVersion
s, ordered from highest to lowest priority.- Type Parameters:
T
- the resource type- Parameters:
resources
- the resources to sortversionProvider
- a function to provide the version from the resource- Returns:
- the sorted list of resources
- See Also:
CustomResourceDefinitionVersion.getName()
,CustomResourceDefinitionSpec.getVersions()
,KubernetesVersionPriority
-
-