mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Improve the injectability of cluster metadata detection - Remove unnecessary and complex base class Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
33 lines
1017 B
TypeScript
33 lines
1017 B
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
|
|
import { clusterMetadataDetectorInjectionToken } from "./token";
|
|
import { ClusterMetadataKey } from "../../common/cluster-types";
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import requestClusterVersionInjectable from "./request-cluster-version.injectable";
|
|
|
|
const clusterLastSeenDetectorInjectable = getInjectable({
|
|
id: "cluster-last-seen-detector",
|
|
instantiate: (di) => {
|
|
const requestClusterVersion = di.inject(requestClusterVersionInjectable);
|
|
|
|
return {
|
|
key: ClusterMetadataKey.LAST_SEEN,
|
|
detect: async (cluster) => {
|
|
try {
|
|
await requestClusterVersion(cluster);
|
|
|
|
return { value: new Date().toJSON(), accuracy: 100 };
|
|
} catch {
|
|
return null;
|
|
}
|
|
},
|
|
};
|
|
},
|
|
injectionToken: clusterMetadataDetectorInjectionToken,
|
|
});
|
|
|
|
export default clusterLastSeenDetectorInjectable;
|