Skip to content

Commit

Permalink
Export getPodsByOwnerId to extension API (#7225)
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Co-authored-by: Sebastian Malton <sebastian@malton.name>
  • Loading branch information
apialaviiva and Nokel81 authored Mar 24, 2023
1 parent 3931c90 commit 8dc0177
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/extensions/common-api/k8s-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import type { KubeJsonApi as InternalKubeJsonApi } from "../../common/k8s-api/ku
import createKubeJsonApiInjectable from "../../common/k8s-api/create-kube-json-api.injectable";
import type { RequestInit } from "@k8slens/node-fetch";
import createKubeJsonApiForClusterInjectable from "../../common/k8s-api/create-kube-json-api-for-cluster.injectable";
import getPodsByOwnerIdInjectable from "../../renderer/components/+workloads-pods/get-pods-by-owner-id.injectable";

export const apiManager = asLegacyGlobalForExtensionApi(apiManagerInjectable);
export const forCluster = asLegacyGlobalFunctionForExtensionApi(createKubeApiForClusterInjectable);
export const forRemoteCluster = asLegacyGlobalFunctionForExtensionApi(createKubeApiForRemoteClusterInjectable);
export const createResourceStack = asLegacyGlobalFunctionForExtensionApi(createResourceStackInjectable);
export const getPodsByOwnerId = asLegacyGlobalFunctionForExtensionApi(getPodsByOwnerIdInjectable);

const getKubeApiDeps = (): KubeApiDependencies => {
const di = getLegacyGlobalDiForExtensionApi();
Expand All @@ -50,7 +52,7 @@ const getKubeApiDeps = (): KubeApiDependencies => {
export interface ExternalKubeApiOptions {
/**
* If `true` then on creation of the `KubeApi`instance a call to `apiManager.registerApi` will be
* made. This is `true` by default to maintain backwards compatability.
* made. This is `true` by default to maintain backwards compatibility.
*
* Setting this to `false` might make `KubeObject`'s details drawer stop working.
*
Expand Down Expand Up @@ -200,7 +202,7 @@ export type {
} from "../../common/k8s-api/kube-object.store";

/**
* @deprecated This type is only present for backwards compatable typescript support
* @deprecated This type is only present for backwards compatible typescript support
*/
export interface IgnoredKubeApiOptions {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class DaemonSetStore extends KubeObjectStore<DaemonSet, DaemonSetApi> {
super(dependencies, api, opts);
}

/**
* @deprecated Switch to using `getPodsByOwnerId` directly
*/
getChildPods(daemonSet: DaemonSet): Pod[] {
return this.dependencies.getPodsByOwnerId(daemonSet.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class JobStore extends KubeObjectStore<Job, JobApi> {
super(dependencies, api, opts);
}

/**
* @deprecated Switch to using `getPodsByOwnerId` directly
*/
getChildPods(job: Job): Pod[] {
return this.dependencies.getPodsByOwnerId(job.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class ReplicaSetStore extends KubeObjectStore<ReplicaSet, ReplicaSetApi>
super(dependencies, api, opts);
}

/**
* @deprecated Switch to using `getPodsByOwnerId` directly
*/
getChildPods(replicaSet: ReplicaSet) {
return this.dependencies.getPodsByOwnerId(replicaSet.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class StatefulSetStore extends KubeObjectStore<StatefulSet, StatefulSetAp
super(dependencies, api, opts);
}

/**
* @deprecated Switch to using `getPodsByOwnerId` directly
*/
getChildPods(statefulSet: StatefulSet) {
return this.dependencies.getPodsByOwnerId(statefulSet.getId());
}
Expand Down

0 comments on commit 8dc0177

Please sign in to comment.