mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
27 lines
805 B
TypeScript
27 lines
805 B
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import { parseKubeApi } from "../kube-api-parse";
|
|
import { kubeApiInjectionToken } from "./kube-api-injection-token";
|
|
import type { KubeApi } from "../kube-api";
|
|
|
|
const getKubeApiFromPathInjectable = getInjectable({
|
|
id: "get-kube-api-from-path",
|
|
|
|
instantiate: (di) => {
|
|
const kubeApis = di.injectMany(kubeApiInjectionToken);
|
|
|
|
return (apiPath: string) => {
|
|
const parsed = parseKubeApi(apiPath);
|
|
|
|
const kubeApi = kubeApis.find((api) => api.apiBase === parsed.apiBase);
|
|
|
|
return (kubeApi as KubeApi) || undefined;
|
|
};
|
|
},
|
|
});
|
|
|
|
export default getKubeApiFromPathInjectable;
|