mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Simplify getOrderedVersions
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
9230cadf2c
commit
2a1e3db02d
@ -26,6 +26,7 @@ import { asLegacyGlobalForExtensionApi } from "../../extensions/as-legacy-global
|
|||||||
import { apiKubeInjectionToken } from "./api-kube";
|
import { apiKubeInjectionToken } from "./api-kube";
|
||||||
import type AbortController from "abort-controller";
|
import type AbortController from "abort-controller";
|
||||||
import loggerInjectable from "../logger.injectable";
|
import loggerInjectable from "../logger.injectable";
|
||||||
|
import { matches } from "lodash/fp";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The options used for creating a `KubeApi`
|
* The options used for creating a `KubeApi`
|
||||||
@ -156,24 +157,12 @@ export interface KubeApiResourceVersionList {
|
|||||||
versions: KubeApiResourceVersion[];
|
versions: KubeApiResourceVersion[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOrderedVersions = (list: KubeApiResourceVersionList): KubeApiResourceVersion[] => {
|
const not = <T>(fn: (val: T) => boolean) => (val: T) => !(fn(val));
|
||||||
const result = [
|
|
||||||
list.preferredVersion,
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const version of list.versions) {
|
const getOrderedVersions = (list: KubeApiResourceVersionList): KubeApiResourceVersion[] => [
|
||||||
if (
|
list.preferredVersion,
|
||||||
version.groupVersion === list.preferredVersion.groupVersion
|
...list.versions.filter(not(matches(list.preferredVersion))),
|
||||||
&& version.version === list.preferredVersion.version
|
];
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.push(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PropagationPolicy = undefined | "Orphan" | "Foreground" | "Background";
|
export type PropagationPolicy = undefined | "Orphan" | "Foreground" | "Background";
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user