chore: Rename injectables to remove redundancy

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-04-24 10:17:24 -04:00
1 parent 6c3e8e83c0
commit 4716dcc434
7 files changed
+61 -61

No files matched your search

@@ -3,8 +3,8 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import type { CallForResource } from "./call-for-resource.injectable";
import callForResourceInjectable from "./call-for-resource.injectable";
import type { RequestKubeResource } from "./request-kube-resource.injectable";
import requestKubeResourceInjectable from "./request-kube-resource.injectable";
import { waitUntilDefined } from "@k8slens/utilities";
import editResourceTabStoreInjectable from "../store.injectable";
import type { EditingResource, EditResourceTabStore } from "../store";
@@ -12,8 +12,8 @@ import { action, computed, observable, runInAction } from "mobx";
import type { KubeObject, RawKubeObject } from "../../../../../common/k8s-api/kube-object";
import yaml from "js-yaml";
import assert from "assert";
import type { CallForPatchResource } from "./call-for-patch-resource.injectable";
import callForPatchResourceInjectable from "./call-for-patch-resource.injectable";
import type { RequestPatchKubeResource } from "./request-patch-kube-resource.injectable";
import requestPatchKubeResourceInjectable from "./request-patch-kube-resource.injectable";
import { createPatch } from "rfc6902";
import type { ShowNotification } from "../../../notifications";
import showSuccessNotificationInjectable from "../../../notifications/show-success-notification.injectable";
@@ -28,8 +28,8 @@ const editResourceModelInjectable = getInjectable({
const store = di.inject(editResourceTabStoreInjectable);
const model = new EditResourceModel({
callForResource: di.inject(callForResourceInjectable),
callForPatchResource: di.inject(callForPatchResourceInjectable),
callForResource: di.inject(requestKubeResourceInjectable),
callForPatchResource: di.inject(requestPatchKubeResourceInjectable),
showSuccessNotification: di.inject(showSuccessNotificationInjectable),
showErrorNotification: di.inject(showErrorNotificationInjectable),
store,
@@ -50,8 +50,8 @@ const editResourceModelInjectable = getInjectable({
export default editResourceModelInjectable;
interface Dependencies {
callForResource: CallForResource;
callForPatchResource: CallForPatchResource;
callForResource: RequestKubeResource;
callForPatchResource: RequestPatchKubeResource;
waitForEditingResource: () => Promise<EditingResource>;
showSuccessNotification: ShowNotification;
showErrorNotification: ShowNotification;
@@ -3,9 +3,9 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getGlobalOverride } from "@k8slens/test-utils";
import callForResourceInjectable from "./call-for-resource.injectable";
import requestKubeResourceInjectable from "./request-kube-resource.injectable";
export default getGlobalOverride(callForResourceInjectable, () => () => {
export default getGlobalOverride(requestKubeResourceInjectable, () => () => {
throw new Error(
"Tried to call for kube resource without explicit override.",
);
@@ -9,12 +9,12 @@ import type { AsyncResult } from "@k8slens/utilities";
import { getErrorMessage } from "../../../../../common/utils/get-error-message";
import apiKubeInjectable from "../../../../k8s/api-kube.injectable";
export type CallForResource = (selfLink: string) => AsyncResult<KubeObject | undefined>;
export type RequestKubeResource = (selfLink: string) => AsyncResult<KubeObject | undefined>;
const callForResourceInjectable = getInjectable({
id: "call-for-resource",
const requestKubeResourceInjectable = getInjectable({
id: "request-kube-resource",
instantiate: (di): CallForResource => {
instantiate: (di): RequestKubeResource => {
const apiKube = di.inject(apiKubeInjectable);
return async (apiPath: string) => {
@@ -38,4 +38,4 @@ const callForResourceInjectable = getInjectable({
causesSideEffects: true,
});
export default callForResourceInjectable;
export default requestKubeResourceInjectable;
@@ -3,9 +3,9 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getGlobalOverride } from "@k8slens/test-utils";
import callForPatchResourceInjectable from "./call-for-patch-resource.injectable";
import requestPatchKubeResourceInjectable from "./request-patch-kube-resource.injectable";
export default getGlobalOverride(callForPatchResourceInjectable, () => () => {
export default getGlobalOverride(requestPatchKubeResourceInjectable, () => () => {
throw new Error(
"Tried to call patching of kube resource without explicit override.",
);
@@ -10,14 +10,14 @@ import type { KubeObject } from "../../../../../common/k8s-api/kube-object";
import assert from "assert";
import { getErrorMessage } from "../../../../../common/utils/get-error-message";
export type CallForPatchResource = (
export type RequestPatchKubeResource = (
item: KubeObject,
patch: JsonPatch
) => AsyncResult<{ name: string; kind: string }>;
const callForPatchResourceInjectable = getInjectable({
id: "call-for-patch-resource",
instantiate: (di): CallForPatchResource => {
const requestPatchKubeResourceInjectable = getInjectable({
id: "request-patch-kube-resource",
instantiate: (di): RequestPatchKubeResource => {
const apiManager = di.inject(apiManagerInjectable);
return async (item, patch) => {
@@ -46,4 +46,4 @@ const callForPatchResourceInjectable = getInjectable({
causesSideEffects: true,
});
export default callForPatchResourceInjectable;
export default requestPatchKubeResourceInjectable;