Skip to content

Commit

Permalink
Remove explicit singleton as lifecycle for being default
Browse files Browse the repository at this point in the history
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
  • Loading branch information
jansav committed Feb 14, 2022
1 parent 063ffef commit eecd4d5
Show file tree
Hide file tree
Showing 195 changed files with 193 additions and 533 deletions.
3 changes: 1 addition & 2 deletions src/common/app-event-bus/app-event-bus.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { appEventBus } from "./event-bus";

const appEventBusInjectable = getInjectable({
id: "app-event-bus",
instantiate: () => appEventBus,
lifecycle: lifecycleEnum.singleton,
});

export default appEventBusInjectable;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import path from "path";
import directoryForUserDataInjectable from "../directory-for-user-data/directory-for-user-data.injectable";

Expand All @@ -11,8 +11,6 @@ const directoryForBinariesInjectable = getInjectable({

instantiate: (di) =>
path.join(di.inject(directoryForUserDataInjectable), "binaries"),

lifecycle: lifecycleEnum.singleton,
});

export default directoryForBinariesInjectable;
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { appPathsInjectionToken } from "../app-path-injection-token";

const directoryForDownloadsInjectable = getInjectable({
id: "directory-for-downloads",
instantiate: (di) => di.inject(appPathsInjectionToken).downloads,
lifecycle: lifecycleEnum.singleton,
});

export default directoryForDownloadsInjectable;
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { appPathsInjectionToken } from "../app-path-injection-token";

const directoryForExesInjectable = getInjectable({
id: "directory-for-exes",
instantiate: (di) => di.inject(appPathsInjectionToken).exe,
lifecycle: lifecycleEnum.singleton,
});

export default directoryForExesInjectable;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import directoryForUserDataInjectable from "../directory-for-user-data/directory-for-user-data.injectable";
import path from "path";

Expand All @@ -11,8 +11,6 @@ const directoryForKubeConfigsInjectable = getInjectable({

instantiate: (di) =>
path.resolve(di.inject(directoryForUserDataInjectable), "kubeconfigs"),

lifecycle: lifecycleEnum.singleton,
});

export default directoryForKubeConfigsInjectable;
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { appPathsInjectionToken } from "../app-path-injection-token";

const directoryForTempInjectable = getInjectable({
id: "directory-for-temp",
instantiate: (di) => di.inject(appPathsInjectionToken).temp,
lifecycle: lifecycleEnum.singleton,
});

export default directoryForTempInjectable;
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { appPathsInjectionToken } from "../app-path-injection-token";

const directoryForUserDataInjectable = getInjectable({
id: "directory-for-user-data",
instantiate: (di) => di.inject(appPathsInjectionToken).userData,
lifecycle: lifecycleEnum.singleton,
});

export default directoryForUserDataInjectable;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import path from "path";
import directoryForKubeConfigsInjectable from "../directory-for-kube-configs/directory-for-kube-configs.injectable";

Expand All @@ -17,8 +17,6 @@ const getCustomKubeConfigDirectoryInjectable = getInjectable({
directoryName,
);
},

lifecycle: lifecycleEnum.singleton,
});

export default getCustomKubeConfigDirectoryInjectable;
3 changes: 1 addition & 2 deletions src/common/cluster-store/allowed-resources.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { comparer, computed } from "mobx";
import hostedClusterInjectable from "./hosted-cluster.injectable";

Expand All @@ -17,7 +17,6 @@ const allowedResourcesInjectable = getInjectable({
equals: (cur, prev) => comparer.structural(cur, prev),
});
},
lifecycle: lifecycleEnum.singleton,
});

export default allowedResourcesInjectable;
4 changes: 1 addition & 3 deletions src/common/cluster-store/cluster-store.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { ClusterStore } from "./cluster-store";
import { createClusterInjectionToken } from "../cluster/create-cluster-injection-token";

Expand All @@ -13,8 +13,6 @@ const clusterStoreInjectable = getInjectable({
ClusterStore.createInstance({
createCluster: di.inject(createClusterInjectionToken),
}),

lifecycle: lifecycleEnum.singleton,
});

export default clusterStoreInjectable;
4 changes: 1 addition & 3 deletions src/common/cluster-store/hosted-cluster.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { getHostedClusterId } from "../utils";
import clusterStoreInjectable from "./cluster-store.injectable";

Expand All @@ -14,8 +14,6 @@ const hostedClusterInjectable = getInjectable({

return di.inject(clusterStoreInjectable).getById(hostedClusterId);
},

lifecycle: lifecycleEnum.singleton,
});

export default hostedClusterInjectable;
3 changes: 1 addition & 2 deletions src/common/cluster/authorization-review.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { AuthorizationV1Api, KubeConfig, V1ResourceAttributes } from "@kubernetes/client-node";
import logger from "../logger";
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";

export type CanI = (resourceAttributes: V1ResourceAttributes) => Promise<boolean>;

Expand Down Expand Up @@ -40,7 +40,6 @@ export function authorizationReview(proxyConfig: KubeConfig): CanI {
const authorizationReviewInjectable = getInjectable({
id: "authorization-review",
instantiate: () => authorizationReview,
lifecycle: lifecycleEnum.singleton,
});

export default authorizationReviewInjectable;
3 changes: 1 addition & 2 deletions src/common/cluster/list-namespaces.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { CoreV1Api, KubeConfig } from "@kubernetes/client-node";
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";

export type ListNamespaces = () => Promise<string[]>;

Expand All @@ -20,7 +20,6 @@ export function listNamespaces(config: KubeConfig): ListNamespaces {
const listNamespacesInjectable = getInjectable({
id: "list-namespaces",
instantiate: () => listNamespaces,
lifecycle: lifecycleEnum.singleton,
});

export default listNamespacesInjectable;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import path from "path";
import directoryForUserDataInjectable from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";

Expand All @@ -14,8 +14,6 @@ const directoryForLensLocalStorageInjectable = getInjectable({
di.inject(directoryForUserDataInjectable),
"lens-local-storage",
),

lifecycle: lifecycleEnum.singleton,
});

export default directoryForLensLocalStorageInjectable;
3 changes: 1 addition & 2 deletions src/common/fs/fs.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import fse from "fs-extra";

const fsInjectable = getInjectable({
id: "fs",
instantiate: () => fse,
causesSideEffects: true,
lifecycle: lifecycleEnum.singleton,
});

export default fsInjectable;
3 changes: 1 addition & 2 deletions src/common/fs/read-dir.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import fsInjectable from "./fs.injectable";

const readDirInjectable = getInjectable({
id: "read-dir",
instantiate: (di) => di.inject(fsInjectable).readdir,
lifecycle: lifecycleEnum.singleton,
});

export default readDirInjectable;
3 changes: 1 addition & 2 deletions src/common/fs/read-file.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import fsInjectable from "./fs.injectable";

const readFileInjectable = getInjectable({
id: "read-file",
instantiate: (di) => di.inject(fsInjectable).readFile,
lifecycle: lifecycleEnum.singleton,
});

export default readFileInjectable;
3 changes: 1 addition & 2 deletions src/common/fs/read-json-file.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import fsInjectable from "./fs.injectable";

const readJsonFileInjectable = getInjectable({
id: "read-json-file",
instantiate: (di) => di.inject(fsInjectable).readJson,
lifecycle: lifecycleEnum.singleton,
});

export default readJsonFileInjectable;
4 changes: 1 addition & 3 deletions src/common/fs/write-json-file.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import type { EnsureOptions, WriteOptions } from "fs-extra";
import path from "path";
import type { JsonValue } from "type-fest";
Expand Down Expand Up @@ -33,8 +33,6 @@ const writeJsonFileInjectable = getInjectable({
ensureDir,
});
},

lifecycle: lifecycleEnum.singleton,
});

export default writeJsonFileInjectable;
3 changes: 1 addition & 2 deletions src/common/hotbar-store.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { HotbarStore } from "./hotbar-store";

const hotbarManagerInjectable = getInjectable({
id: "hotbar-manager",
instantiate: () => HotbarStore.getInstance(),
lifecycle: lifecycleEnum.singleton,
});

export default hotbarManagerInjectable;
3 changes: 1 addition & 2 deletions src/common/user-store/user-store.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { UserStore } from "./user-store";

const userStoreInjectable = getInjectable({
id: "user-store",
instantiate: () => UserStore.createInstance(),
lifecycle: lifecycleEnum.singleton,
});

export default userStoreInjectable;
4 changes: 1 addition & 3 deletions src/common/utils/is-allowed-resource.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import allowedResourcesInjectable from "../cluster-store/allowed-resources.injectable";
import type { KubeResource } from "../rbac";

Expand All @@ -17,8 +17,6 @@ const isAllowedResourceInjectable = getInjectable({

return (resource: KubeResource) => allowedResources.get().has(resource);
},

lifecycle: lifecycleEnum.singleton,
});

export default isAllowedResourceInjectable;
3 changes: 1 addition & 2 deletions src/common/vars/is-linux.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { isLinux } from "../vars";

const isLinuxInjectable = getInjectable({
id: "is-linux",
instantiate: () => isLinux,
lifecycle: lifecycleEnum.singleton,
});

export default isLinuxInjectable;
3 changes: 1 addition & 2 deletions src/common/vars/is-windows.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { getInjectable } from "@ogre-tools/injectable";
import { isWindows } from "../vars";

const isWindowsInjectable = getInjectable({
id: "is-windows",
instantiate: () => isWindows,
lifecycle: lifecycleEnum.singleton,
});

export default isWindowsInjectable;
Loading

0 comments on commit eecd4d5

Please sign in to comment.