Fix editing of kube resource (#5906)

This commit is contained in:
Janne Savolainen authored and GitHub committed 2022-07-27 11:44:11 -04:00
1 parent b94672b5a8
commit e682c7de45
59 files changed
+14123 -298

No files matched your search

@@ -0,0 +1,26 @@
/**
* 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;
@@ -0,0 +1,10 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectionToken } from "@ogre-tools/injectable";
import type { KubeApi } from "../kube-api";
export const kubeApiInjectionToken = getInjectionToken<KubeApi<any, any>>({
id: "kube-api-injection-token",
});