Skip to content

Commit

Permalink
fix: add ref mappers for Service selector to possible PodTemplateSpecs
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Oct 7, 2021
1 parent 9145350 commit 1c5c79a
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/kindhandlers/Service.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import navSectionNames from '@constants/navSectionNames';

function createSelectorOutgoingRefMappers(targetResourceKind: string) {
return {
source: {
pathParts: ['spec', 'selector'],
},
target: {
kind: targetResourceKind,
pathParts: ['spec', 'template', 'metadata', 'labels'],
},
matchPairs: true,
};
}

const ServiceHandler: ResourceKindHandler = {
kind: 'Service',
apiVersionMatcher: '**',
Expand All @@ -23,16 +36,12 @@ const ServiceHandler: ResourceKindHandler = {
await k8sCoreV1Api.deleteNamespacedService(name, namespace || 'default');
},
outgoingRefMappers: [
{
source: {
pathParts: ['spec', 'selector'],
},
target: {
kind: 'Deployment',
pathParts: ['spec', 'template', 'metadata', 'labels'],
},
matchPairs: true,
},
createSelectorOutgoingRefMappers('DaemonSet'),
createSelectorOutgoingRefMappers('Deployment'),
createSelectorOutgoingRefMappers('Job'),
createSelectorOutgoingRefMappers('ReplicaSet'),
createSelectorOutgoingRefMappers('ReplicationController'),
createSelectorOutgoingRefMappers('StatefulSet'),
],
};

Expand Down

0 comments on commit 1c5c79a

Please sign in to comment.