Skip to content

Commit

Permalink
fix: fixed correct context usage in cluster comparison resource diff
Browse files Browse the repository at this point in the history
  • Loading branch information
olensmar committed Nov 10, 2021
1 parent 8dd625a commit c9e50de
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/redux/services/clusterResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,13 @@ import {K8sResource} from '@models/k8sresource';

import {getResourceKindHandler} from '@src/kindhandlers';

import * as k8s from '@kubernetes/client-node';

export const getClusterResourceText = async (localResource: K8sResource, kubeconfig: string, context: string) => {
try {
const resourceKindHandler = getResourceKindHandler(localResource.kind);
if (!resourceKindHandler) {
throw new Error(`Could not find Kind Handler for resoruce ${localResource.id}`);
}

console.log(`using context ${context}`);

const kc = new k8s.KubeConfig();
kc.loadFromFile(kubeconfig);
if (context && context.length > 0) {
kc.setCurrentContext(context);
}

const handleResource = (res: any) => {
if (res.body) {
delete res.body.metadata?.managedFields;
Expand All @@ -37,7 +27,7 @@ export const getClusterResourceText = async (localResource: K8sResource, kubecon
};

try {
const resourceFromCluster = await getResourceFromCluster(localResource, kubeconfig);
const resourceFromCluster = await getResourceFromCluster(localResource, kubeconfig, context);
return handleResource(resourceFromCluster);
} catch {
return handleRejection();
Expand Down

0 comments on commit c9e50de

Please sign in to comment.