mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
26 lines
742 B
TypeScript
26 lines
742 B
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { CoreV1Api, KubeConfig } from "@kubernetes/client-node";
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
|
|
export type ListNamespaces = () => Promise<string[]>;
|
|
|
|
export function listNamespaces(config: KubeConfig): ListNamespaces {
|
|
const coreApi = config.makeApiClient(CoreV1Api);
|
|
|
|
return async () => {
|
|
const { body: { items }} = await coreApi.listNamespace();
|
|
|
|
return items.map(ns => ns.metadata.name);
|
|
};
|
|
}
|
|
|
|
const listNamespacesInjectable = getInjectable({
|
|
id: "list-namespaces",
|
|
instantiate: () => listNamespaces,
|
|
});
|
|
|
|
export default listNamespacesInjectable;
|